# pralayeshmukherjee/bookie architecture

> Architecture diagram of the GitHub repository pralayeshmukherjee/bookie, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pralayeshmukherjee/bookie
- Repository: https://github.com/pralayeshmukherjee/bookie

## Overview

##### Project Type and Purpose
- Bookie is a full-stack marketplace application that evolved from a digital library concept.
- It includes a React (Vite) frontend and a Spring Boot backend, with MySQL as the database.
- Core functionalities include user registration and login, book listings, inventory management for sellers, secure payments, and even an AI-powered chatbot for personalized recommendations.

##### Break Down the File Structure
- The project is distinctly separated into two major folders: “frontend” and “Backend.”
- In the backend directory, the structure is organized under a Maven project with defined packages for configuration (e.g., CORSConfig), DTOs, controllers, service layers, repositories, and entities. This clearly defines the MVC (Model-View-Controller) pattern in the backend’s architecture.

##### Key Components
- Frontend:
- User Interface Components: Breaking down components into “Landing,” “Login/Register” (for Librarian, Seller, User), “MainPages,” “ProductSection,” etc.
- Client-Side Routing & State Management: Recognize the role of React’s component hierarchy and context (as seen in the “Contexts” folder).
- Backend:
- Controllers: Multiple REST controllers (e.g., BooksController, LibrarianController, LibraryController, ChatController) that accept incoming HTTP requests.
- Service Layer: Business logic handling (BookService, SellerService, UserService, OTPService, etc.).
- Repository Layer: Data access objects interfacing with the MySQL database.
- DTOs: Data Transfer Objects which encapsulate request and response payloads.
- Entities: Mapping the data model (Book, User, Librarian, Library, etc.).
- Configuration: Important aspects like CORS and database connectivity.
- Database:
- MySQL as the central data store with schema support for books, users, librarians, sellers, etc.

##### Architectural Patterns and Design Principles
- The backend follows the MVC layered architecture with strongly separated concerns (controllers, services, repositories, and DTOs).
- The frontend is componentized using React’s best practices with emphasis on reusability (e.g., multiple login and register components).
- The system leverages RESTful APIs to communicate between the frontend and backend.
- For integration, expect components such as the AI-powered chatbot and upcoming features like payment gateway and map integration that may require external API services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1("Frontend (React Application)"):::frontend
        FE2("UI Components (Landing,Login/Register,MainPages,ProductSection,Maps,..)"):::frontend
        FE3("Theme Context Provider"):::frontend
    end
    FE1 --> FE2
    FE1 --> FE3

    %% REST API Call from Frontend to Backend Controllers
    FE1 -->|"RESTAPICall"| BC1("REST Controllers<br/>(BooksController, LibrarianController, ChatController, LibraryController, ...)"):::backend

    %% Backend Layer - MVC Flow
    BC1 -->|"calls"| BS1("Business Services<br/>(BookService, SellerService, UserService, OtpService, EmailService, GeminiService, ...)"):::backend
    BS1 -->|"queries"| BR1("Data Repositories<br/>(BookRepo, LibrarianRepo, LibraryRepo, SellerRepository, UserRepo, ...)"):::backend
    BR1 -->|"data persistence"| DB("MySQL Database"):::database

    %% DTOs and Entities used in Backend
    BC1 -->|"uses"| DTO("DTOs<br/>(BookAdd, LibrarianLoginDTO, RegisterUser, ...)"):::backend
    BS1 -->|"manipulates"| ENT("Entities<br/>(Book, User, Librarian, Library, Seller, SellerBook, ...)"):::backend

    %% Configuration component linked to Controllers
    CONFIG("Configuration (CORS,DB connectivity)<br/>(CORSConfig)"):::backend
    CONFIG --> BC1

    %% Click Events for Frontend Components
    click FE2 "https://github.com/pralayeshmukherjee/bookie/tree/master/frontend/src/Component"
    click FE3 "https://github.com/pralayeshmukherjee/bookie/blob/master/frontend/src/Contexts/theme.jsx"

    %% Click Events for Backend Components
    click BC1 "https://github.com/pralayeshmukherjee/bookie/tree/master/Backend/src/main/java/com/raj/library/controller"
    click BS1 "https://github.com/pralayeshmukherjee/bookie/tree/master/Backend/src/main/java/com/raj/library/Service"
    click BR1 "https://github.com/pralayeshmukherjee/bookie/tree/master/Backend/src/main/java/com/raj/library/repository"
    click DTO "https://github.com/pralayeshmukherjee/bookie/tree/master/Backend/src/main/java/com/raj/library/DTO"
    click ENT "https://github.com/pralayeshmukherjee/bookie/tree/master/Backend/src/main/java/com/raj/library/entity"
    click CONFIG "https://github.com/pralayeshmukherjee/bookie/blob/master/Backend/src/main/java/com/raj/library/Config/CORSConfig.java"

    %% Styles
    classDef frontend fill:#FFEEAD,stroke:#000,stroke-width:2px;
    classDef backend fill:#B2F7EF,stroke:#000,stroke-width:2px;
    classDef database fill:#C8E6C9,stroke:#000,stroke-width:2px;
```
