Skip to content

A modern, production-ready Spring Boot REST API powering the ByteChronicle blogging platform. Built with Java 17 and Spring Boot 3.2, this backend provides a robust foundation for content management with complete CRUD operations, advanced search functionality, tag-based organization, and flexible data layer supporting H2 and MySQL detabases

Notifications You must be signed in to change notification settings

Prasadkotkar/ByteChronicle-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

ByteChronicle Backend

Spring Boot REST API for the ByteChronicle blogging platform.

🛠️ Tech Stack

  • Java 17 - Modern Java features and performance
  • Spring Boot 3.2 - Enterprise-grade framework
  • Spring Data JPA - Data persistence layer
  • Spring Web - RESTful web services
  • H2 Database - In-memory database for development
  • MuSQL Database - Relational database for production
  • Maven - Dependency management and build tool
  • Hibernate - ORM framework
  • Jackson - JSON serialization/deserialization

🚀 Getting Started

Installation & Setup

  1. Navigate to backend directory
    cd backend
  2. Run the application
    ./mvnw spring-boot:run
  3. Alternative: Build and run JAR
    ./mvnw clean package
    java -jar target/blog-backend-0.0.1-SNAPSHOT.jar

The application runs on http://localhost:8080 by default.

Key configuration in application.properties:

server.port=8080
spring.datasource.url=jdbc:mysql://${DB_HOST:}:${DB_PORT:}/${DB_NAME:}
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.username=${DB_USERNAME:}
spring.datasource.password=${DB_PASSWORD:}

📚 API Endpoints

Blog Management

GET    /api/blogs              # Get all blogs (paginated)
GET    /api/blogs/{id}         # Get blog by ID
POST   /api/blogs              # Create new blog
PUT    /api/blogs/{id}         # Update existing blog
DELETE /api/blogs/{id}         # Delete blog

Search & Tags

GET    /api/blogs/search?keyword={keyword}  # Search blogs
GET    /api/blogs/tags                      # Get all unique tags
GET    /api/blogs/tag/{tag}                 # Get blogs by tag

Sample Data

POST   /api/blogs/sample       # Load sample blog posts

Entity Structure

Blog Entity:

@Entity
public class Blog {
    private Long id;
    private String title;
    private String content;
    private String summary;
    private String author;
    private List<String> tags;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
}

🔧 Development

Project Structure

backend/
├── src/main/java/com/bytechronicle/blog/
│   ├── BlogApplication.java           # Main application class
│   ├── controller/
│   │   └── BlogController.java        # REST endpoints
│   ├── model/
│   │   └── Blog.java                  # Blog entity
│   ├── repository/
│   │   └── BlogRepository.java        # Data access layer
│   └── service/
│       └── BlogService.java           # Business logic
├── src/main/resources/
│   ├── application.properties         # Configuration
│   └── data.sql                       # Sample data (optional)
└── pom.xml                           # Maven dependencies

Building for Production

./mvnw clean package -DskipTests

🔍 API Testing

Using cURL

# Get all blogs
curl http://localhost:8080/api/blogs

# Create a new blog
curl -X POST http://localhost:8080/api/blogs \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My First Blog",
    "content": "This is the content of my first blog post.",
    "summary": "A brief summary",
    "author": "John Doe",
    "tags": ["tech", "programming"]
  }'

# Search blogs
curl "http://localhost:8080/api/blogs/search?keyword=programming"

📝 Logging

Logs are configured in application.properties:

logging.level.com.bytechronicle.blog=DEBUG
logging.level.org.springframework.web=INFO

🚀 Deployment

Docker

FROM openjdk:17-jdk-slim
COPY target/blog-backend-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]

About

A modern, production-ready Spring Boot REST API powering the ByteChronicle blogging platform. Built with Java 17 and Spring Boot 3.2, this backend provides a robust foundation for content management with complete CRUD operations, advanced search functionality, tag-based organization, and flexible data layer supporting H2 and MySQL detabases

Topics

Resources

Stars

Watchers

Forks

Languages