# bambadiagne/simple_blog architecture

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

- Interactive diagram: https://gitdiagram.com/bambadiagne/simple_blog
- Repository: https://github.com/bambadiagne/simple_blog

## Overview

##### Main Components
- Frontend: The Angular application housed in the “frontend” directory.
- Backend: The NestJS API in the “backend” directory structured with several modules (e.g., Auth, Posts, Comments, Users, Database, Logger, Code Verification, Common services including mailing and storage).
- Database: PostgreSQL as referenced in the README with Prisma migrations and schema located in backend/prisma/.
- External Services:
- AWS S3 (Storage service)
- AWS SES (Mailing service)
- Docker environment for container orchestration (docker-compose file).
- Additional Configurations: Environment variables, Dockerfiles, and configuration files which support deployment and runtime configurations.

##### Representing the Relationships and Interactions
- The Frontend communicates with the Backend via HTTP calls (REST/JSON).
- The Backend handles authentication (JWT, refresh tokens) and routes user requests to the respective controllers (e.g., posts, comments, users).
- The Backend uses Prisma to interact with the PostgreSQL database.
- The mailing service (using AWS SES) and file storage service (using AWS S3) are invoked by dedicated modules/services within the backend.
- Docker containers encapsulate the frontend, backend, and database dependencies, enabling a consistent deployment environment.
- The authentication module in the backend interacts with guards and strategies for JWT and local authentication.

##### Architectural Patterns and Design Principles
- Modular Architecture: Both projects are separated into modules; each module encapsulates features (Authentication, Posts, Comments, etc.), facilitating separation of concerns.
- MVC-like Separation within NestJS: Controllers handle HTTP requests, services implement business logic, and modules orchestrate the application.
- Containerization and Deployment: Dockerfiles for both frontend and backend, along with docker-compose, underscore the use of containerization for deployment consistency.
- Use of SOLID Principles: The backend clearly separates services, controllers, strategies, and DTOs to adhere to best practices for maintainability and testability.

##### Relevant Technologies and Frameworks
- Angular: For the frontend UI and client-side routing.
- NestJS: For the backend API, controllers, services, and module-based architecture.
- PostgreSQL and Prisma: For the database layer and database migrations.
- AWS (S3 & SES): For external storage and email services.
- Docker: For containerization, with individual Dockerfiles and a docker-compose configuration.
- Various code quality tools like ESLint and Prettier that enforce best practices.

- Frontend → Backend: API requests/responses.
- Backend ↔ Database: CRUD operations.
- Backend → AWS S3/SES: External service calls.
- Docker container boundaries showing each component's deployment context.
- Presentation layer (Angular),
- Application layer (NestJS modules and services),
- Data layer (PostgreSQL/Prisma), and
- External services (AWS S3, AWS SES).
- Annotations: Optionally annotate to highlight design aspects (e.g., "JWT Authentication", "REST API endpoints", "Service Modules").

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Docker Environment
    subgraph "Docker Environment"
        subgraph "Frontend Container"
            FE["Angular Frontend"]:::frontend
        end
        subgraph "Backend Container"
            BE["NestJS Backend"]:::backend
            subgraph "Modules in Backend"
                AUTH["Authentication Module (JWT)"]:::module
                POSTS["Posts Module"]:::module
                COMMENTS["Comments Module"]:::module
                USERS["Users Module"]:::module
                CODE["Code Verification Module"]:::module
                LOGGER["Logger Module"]:::module
                COMMON["Common Services"]:::module
                DBMOD["Database Module (Prisma)"]:::module
                MAIL["Mailing Service"]:::module
                STORAGE["File Storage Service"]:::module
            end
        end
        subgraph "Database Container"
            DB["PostgreSQL Database (Prisma)"]:::database
        end
    end

    %% External Services
    S3["AWS S3 (File Storage)"]:::external
    SES["AWS SES (Mailing Service)"]:::external

    %% Docker Configuration Node
    DC["Docker Configuration"]:::docker

    %% Connections between Containers
    FE -->|"API_calls"| BE
    BE -->|"Prisma_CRUD"| DB

    %% Internal Backend Module connections
    BE --> AUTH
    BE --> POSTS
    BE --> COMMENTS
    BE --> USERS
    BE --> CODE
    BE --> LOGGER
    BE --> COMMON
    BE --> DBMOD
    BE --> MAIL
    BE --> STORAGE

    %% External Service interactions from Backend Modules
    MAIL -->|"uses"| SES
    STORAGE -->|"uses"| S3

    %% Docker Configuration influences all containers
    DC --> FE
    DC --> BE
    DC --> DB

    %% Click Events
    click FE "https://github.com/bambadiagne/simple_blog/tree/master/frontend/"
    click BE "https://github.com/bambadiagne/simple_blog/tree/master/backend/"
    click AUTH "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/auth/"
    click POSTS "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/posts/"
    click COMMENTS "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/comments/"
    click USERS "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/users/"
    click CODE "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/code-verification/"
    click DBMOD "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/database/"
    click MAIL "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/common/services/mailing/"
    click STORAGE "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/common/services/storage/"
    click COMMON "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/common/"
    click LOGGER "https://github.com/bambadiagne/simple_blog/tree/master/backend/src/logger/"
    click DB "https://github.com/bambadiagne/simple_blog/tree/master/backend/prisma/"
    click DC "https://github.com/bambadiagne/simple_blog/blob/master/docker-compose.yml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef backend fill:#FFB6C1,stroke:#FF0000,stroke-width:2px;
    classDef module fill:#FFFF99,stroke:#FF9900,stroke-width:2px;
    classDef database fill:#C1FFC1,stroke:#008000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef docker fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
```
