Skip to content

PrashanthPremchand/book-social-network-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Java Spring Boot Docker CI/CD PostgreSQL

πŸ“š Book Social Network – Backend API

A production-grade Spring Boot backend for a Book Social Network platform featuring JWT authentication, email verification, book borrowing workflows, feedback system, Dockerized deployment, and a fully automated CI/CD pipeline using GitHub Actions.

⚠️ Important: This project is designed to run via CI/CD pipelines and Docker, not via simple mvn spring-boot:run.


🎯 Why This Project?

This project was built to demonstrate how real-world backend systems are designed and deployed in production environments, including:

  • Secure Authentication: Implementation of stateless security using JWT.
  • Email-based Activation: Realistic user onboarding with token-based verification.
  • Clean Architecture: Separation of concerns using a layered, maintainable structure.
  • Containerization: Fully Dockerized environment for consistency across stages.
  • CI/CD Driven: Automated delivery pipeline using GitHub Actions to reflect enterprise-grade practices.

It intentionally avoids hardcoded secrets and local shortcuts to reflect enterprise-grade practices.


πŸš€ Tech Stack (ATS Optimized)

Backend

  • Java 17
  • Spring Boot 3
  • Spring Security (JWT)
  • Spring Data JPA
  • Hibernate
  • Validation (Jakarta)
  • Thymeleaf (Email Templates)

Database

  • PostgreSQL (Production)
  • H2 (Testing)

DevOps & Infrastructure

  • Docker & Docker Compose
  • GitHub Actions (CI/CD)
  • Self-hosted GitHub Runner
  • MailDev (Local Email Testing)

Tools

  • Swagger / OpenAPI
  • Maven
  • Postman

✨ Core Features

  • πŸ” JWT-based Authentication & Authorization
  • πŸ“§ Email Account Activation (Token-based)
  • πŸ“š Book Management (CRUD, Shareable, Archive)
  • πŸ”„ Book Borrow & Return Workflow
  • ⭐ Feedback & Rating System
  • πŸ“„ Pagination & Filtering
  • 🧾 Global Exception Handling
  • 🐳 Fully Dockerized Setup
  • βš™οΈ Automated CI/CD Pipeline

🧱 Clean Architecture Overview

This project follows Clean Architecture + Layered Architecture principles.


Controller β†’ Service β†’ Repository β†’ Database
↓
Mapper / DTO

πŸ“¦ Package Structure


com.prashanth.book
β”œβ”€β”€ auth          # Authentication & JWT logic
β”œβ”€β”€ book          # Book domain (entity, service, repo)
β”œβ”€β”€ feedback      # Feedback & ratings
β”œβ”€β”€ history       # Book transaction history
β”œβ”€β”€ user          # User & roles
β”œβ”€β”€ security      # JWT filter & security config
β”œβ”€β”€ email         # Email service & templates
β”œβ”€β”€ file          # File storage utilities
β”œβ”€β”€ common        # BaseEntity, PageResponse
β”œβ”€β”€ handler       # Global exception handling
└── config        # Beans, OpenAPI, auditing


πŸ—οΈ Architecture Diagrams

1️⃣ Monolithic Architecture (Current)

graph TD
    subgraph Client_Layer [Client Layer]
        A[Postman / Frontend]
    end

    subgraph Spring_Boot_App [Spring Boot Application]
        B[Security Filter / JWT]
        C[Auth Module]
        D[Book Module]
        E[Feedback Module]
        F[Email Module]
    end

    subgraph Data_Layer [Data Layer]
        G[(PostgreSQL)]
    end

    A --> B
    B --> C
    B --> D
    B --> E
    C --> F
    C & D & E --> G

Loading

Why Monolith?

  • Faster development
  • Easier debugging
  • Ideal for early-stage systems
  • Clean separation allows future migration

2️⃣ Microservices (Future Scope)

graph TD
    GW[API Gateway] --> Auth[Auth Service]
    GW --> Book[Book Service]
    GW --> Feed[Feedback Service]
    GW --> Noti[Notification Service]
    
    Auth --> DB1[(PostgreSQL)]
    Book --> DB2[(PostgreSQL)]
    Feed --> DB3[(PostgreSQL)]
    Noti --> DB4[(PostgreSQL)]

Loading

The current design intentionally supports easy migration to microservices.


πŸ—ƒοΈ ER Diagram (High-Level)

erDiagram
    USER ||--o{ BOOK : owns
    USER ||--o{ BOOK_TRANSACTION_HISTORY : borrows
    BOOK ||--o{ FEEDBACK : receives
    BOOK ||--o{ BOOK_TRANSACTION_HISTORY : tracked_in
    USER ||--o{ FEEDBACK : writes

    USER {
        string email
        string password
        boolean accountLocked
        boolean enabled
    }
    BOOK {
        string title
        string authorName
        boolean archieved
        boolean shareable
    }
    FEEDBACK {
        double note
        string comment
    }

Loading

Key Relationships

  • User ↔ Book (Owner)
  • User ↔ BookTransactionHistory (Borrower)
  • Book ↔ Feedback (Ratings & Reviews)

πŸ“˜ API Documentation (Swagger)

Once deployed, Swagger UI is available at: http://<HOST>:8088/swagger-ui/index.html


πŸ”„ CI/CD Pipeline (GitHub Actions)

  1. Compile
  2. Unit Tests
  3. Build JAR
  4. Build & Push Docker Image
  5. Deploy via Docker Compose (Self-hosted Runner)

🐳 Docker & Deployment

⚠️ Local Execution Disclaimer (Important)

❌ This project cannot run fully locally out-of-the-box because environment variables are injected via GitHub Secrets and Docker images are pulled dynamically. This is intentional to reflect production best practices.


πŸ“Œ Project Status

Status: βœ… Stable & Functional


πŸ‘¨β€πŸ’» Author

Prashanth P Java Backend Developer

πŸ“§ Email: prashanthpremchand@gmail.com