# dawar-shafaque/library-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/dawar-shafaque/library-management-system
- Repository: https://github.com/dawar-shafaque/library-management-system

## Overview

##### Project type and purpose
- This is a microservices-based library management system implemented in Java/Spring Boot.
- The goal is to manage users, books, and library operations via a set of independently deployable services behind an API gateway and a service registry.

##### File structure
- Top-level modules:
- user-service
- book-service
- library-service
- library-api-gateway
- library-server
- Each service is a Spring Boot application (has `Application.java`, `controller/`, `service/`, `model/`, `repository/` or `dto/`).
- `library-service` uses Feign clients (`feign/BookInterface`, `feign/UserInterface`) to call other services.
- `library-api-gateway` likely uses Spring Cloud Gateway or Zuul for routing.
- `library-server` is the service registry (Eureka or similar).
- Common files: `application.properties` in each, Maven wrapper, POMs.

##### README
- Project title: “library-management-system.”

##### Main components and interactions
a. Components:
- Client (e.g., Web or Mobile)
- API Gateway (`library-api-gateway`)
- Service Registry (`library-server`)
- User Service (`user-service`)
- Book Service (`book-service`)
- Library Service (`library-service`)
- Databases (one per service or shared, depending on config)
- (Optional) Message broker or config server if present later
b. Relationships / Data flows:
- Client → API Gateway for all external calls
- API Gateway → Registers with Service Registry to discover downstream services
- API Gateway routes calls to User, Book or Library Service
- Library Service uses Feign clients to call User Service (to fetch user details) and Book Service (to fetch book info)
c. Architectural patterns / principles:
- Microservices with single responsibility (user, book, library)
- API Gateway pattern for ingress routing and cross-cutting concerns (auth, logging)
- Service Registry for dynamic discovery
- Declarative REST clients (Feign) for inter-service communication
- Each service has its own data store (database per service)
d. Key technologies:
- Java 11+ / Spring Boot
- Spring Cloud Netflix (Eureka, Zuul/Gateway, Feign)
- Maven build system
- REST controllers, DTOs, Repositories (Spring Data JPA)
- H2 or MySQL/PostgreSQL as persistent store (configured in `application.properties`)

##### Elements
- Clear labels: service names, database labels (e.g., User-DB, Book-DB, Library-DB), “API Gateway,” “Service Registry.”
- Client → API Gateway
- API Gateway → User Service, Book Service, Library Service
- Library Service → User Service, Library Service → Book Service
- Each service → its own database
- Rectangles for microservices
- Diamond or server rack for Service Registry

##### Step-by-step approach for the principal software engineer
1. Client at the left.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Client["Client (Web/Mobile)"]:::client

    %% API Gateway and Service Registry
    Gateway["API Gateway"]:::gateway
    ServiceRegistry["Service Registry<br>(Eureka)"]:::registry

    %% Microservices
    subgraph "Services"
        direction TB
        UserService["User Service"]:::service
        BookService["Book Service"]:::service
        LibraryService["Library Service"]:::service
    end

    %% Databases
    UserDB["User-DB"]:::db
    BookDB["Book-DB"]:::db
    LibraryDB["Library-DB"]:::db

    %% Client to Gateway
    Client -->|REST/HTTP| Gateway

    %% Gateway to Services
    Gateway -->|REST/HTTP| UserService
    Gateway -->|REST/HTTP| BookService
    Gateway -->|REST/HTTP| LibraryService

    %% Services register with Registry
    Gateway -->|register| ServiceRegistry
    UserService -->|register| ServiceRegistry
    BookService -->|register| ServiceRegistry
    LibraryService -->|register| ServiceRegistry

    %% Library Service to other services via Feign
    LibraryService -->|Feign call| UserService
    LibraryService -->|Feign call| BookService

    %% Services to their DBs
    UserService -->|JPA/SQL| UserDB
    BookService -->|JPA/SQL| BookDB
    LibraryService -->|JPA/SQL| LibraryDB

    %% Click Events
    click Gateway "https://github.com/dawar-shafaque/library-management-system/blob/main/library-api-gateway/src/main/java/com/epam/libraryApiGateway/LibraryApiGatewayApplication.java"
    click ServiceRegistry "https://github.com/dawar-shafaque/library-management-system/blob/main/library-server/src/main/java/com/epam/libraryServer/LibraryServerApplication.java"
    click UserService "https://github.com/dawar-shafaque/library-management-system/blob/main/user-service/src/main/java/com/example/userService/UserServiceApplication.java"
    click BookService "https://github.com/dawar-shafaque/library-management-system/blob/main/book-service/src/main/java/com/epam/bookService/BookServiceApplication.java"
    click LibraryService "https://github.com/dawar-shafaque/library-management-system/blob/main/library-service/src/main/java/com/epam/libraryService/LibraryServiceApplication.java"

    %% Styles
    classDef client fill:#96CEB4,stroke:#333,stroke-width:1px;
    classDef gateway fill:#FF6F69,stroke:#333,stroke-width:1px;
    classDef registry fill:#88D8B0,stroke:#333,stroke-width:1px;
    classDef service fill:#D0E6A5,stroke:#333,stroke-width:1px;
    classDef db fill:#FFCC5C,stroke:#333,stroke-width:1px;
```
