# novpngt/book-social-app architecture

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

- Interactive diagram: https://gitdiagram.com/novpngt/book-social-app
- Repository: https://github.com/novpngt/book-social-app

## Overview

##### Main Components
- API Gateway: This module (located in the "api-gateway" directory) is the entry point for client requests. It includes configurations (like AuthenticationFilter and WebClientConfiguration) that handle security and forward requests to the appropriate microservices.
- Identity Service: Found under "identity-service", this service manages user authentication, authorization, and user-related data. It contains controllers (e.g., AuthenticationController, UserController), services, repositories, DTOs, and security configurations.
- Notification Service: Located in the "notification-service" directory, this service handles notifications (e.g., sending emails). It also sets up security similar to other services and contains HTTP client configurations to interact with external email services.
- Profile Service: Under "profile-service", this microservice deals with user profiles and related data, with its controllers, services, and repositories.
- Web Application (Web-App): The "web-app" folder holds the frontend code—likely a single-page application (React) given the presence of JSX files—acting as the client that interacts with the API gateway and, by extension, the microservices.

##### Relationships and Interactions
- Client Interaction: The web-app sends HTTP requests (e.g., login, profile update) to the API Gateway.
- API Routing: The API Gateway then distinguishes between services (identity, notification, profile) and forwards the requests appropriately.
- Interservice Communication: Depending on the business logic, some microservices (for example, identity service and profile service) might communicate with each other or use asynchronous events (as hinted by the event packages in identity and notification services) to notify for changes or updates.
- Shared Security & Authentication: Across the microservices, similar configurations (custom JWT decoders, security filters) suggest a centralized or uniform security approach.

##### Architectural Patterns and Design Principles
- Microservices Architecture: Each service is an independently deployable artifact that encapsulates a specific business functionality.
- API Gateway Pattern: The gateway centralizes common concerns like authentication, rate limiting, and routing, reducing client coupling with individual services.
- Event-Driven Communication: The presence of event and DTO packages in the identity and notification services indicate that events (such as notification triggers) might be used for asynchronous, decoupled communication.
- Separation of Concerns: Each service is organized in a layered fashion (controllers, services, repositories, configurations) which points to a clean separation of concerns.

##### Relevant Technologies and Frameworks
- Backend: Java with Spring Boot is evident in each service. Maven is used for build management.
- Security: JWT-related classes and configurations appear across multiple services.
- Frontend: The “web-app” is built using JavaScript/React (package.json, JSX components) with HTTP client configurations to interact with the backend.
- Containerization & Deployment: Dockerfiles and docker-compose files are maintained in services like identity-service and notification-service, indicating deployment containerization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        webApp["Web-App"]:::frontend
    end

    subgraph "Backend Layer"
        apiGateway["API Gateway\n(Authentication & Routing)"]:::gateway
        subgraph "Microservices"
            identity["Identity Service\n(User Auth & Security)"]:::service
            notification["Notification Service\n(Notification Emails)"]:::service
            profile["Profile Service\n(User Profiles)"]:::service
        end
    end

    webApp -->|"HTTP_requests"| apiGateway
    apiGateway -->|"routes_to"| identity
    apiGateway -->|"routes_to"| notification
    apiGateway -->|"routes_to"| profile
    identity -->|"user_update_event"| profile
    identity -->|"notification_trigger"| notification

    click webApp "https://github.com/novpngt/book-social-app/tree/main/web-app/"
    click apiGateway "https://github.com/novpngt/book-social-app/tree/main/api-gateway/"
    click identity "https://github.com/novpngt/book-social-app/tree/main/identity-service/"
    click notification "https://github.com/novpngt/book-social-app/tree/main/notification-service/"
    click profile "https://github.com/novpngt/book-social-app/tree/main/profile-service/"

    classDef frontend fill:#9fdfbf,stroke:#333,stroke-width:2px;
    classDef gateway fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef service fill:#ace4f8,stroke:#333,stroke-width:2px;
```
