# linhnguyen411/3dscene architecture

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

- Interactive diagram: https://gitdiagram.com/linhnguyen411/3dscene
- Repository: https://github.com/linhnguyen411/3dscene

## Overview

##### Main Components
- Frontend Application:
- The README shows that the frontend is accessible via http://localhost:8081/.
- Backend Application:
- The "backend" directory reveals a Python backend structured with clear separation into API endpoints (api/api_v1), CRUD operations, models, schemas, configuration, and even logs.
- Includes documentation via Swagger (http://localhost:8083/docs) and exposes endpoints for authentication, user/todo management, etc.
- Integration with Celery is evident (celery_app.py) to handle asynchronous tasks, with Flower accessible for monitoring these tasks.
- Reverse-Proxy Service:
- The "reverse-proxy" directory indicates the use of an nginx-based proxy container which likely manages and routes incoming requests to the proper frontend or backend containers.
- Supporting Services:
- MailHog is used for capturing and viewing emails sent by the application (visible on http://localhost:8085/).
- PGAdmin is provided to manage and inspect the database (likely a PostgreSQL instance) with its interface at http://localhost:8086/.
- Additionally, there are Docker-related files and docker-compose configurations that encapsulate the setup into separate containers.

##### Relationships and Interactions
- External Client/User Requests:
- They start at the reverse-proxy which then directs traffic to either the Frontend (React application) or the Backend (FastAPI API endpoints).
- Frontend – Backend Communication:
- The React frontend communicates with the backend through RESTful API calls to handle user authentication, data retrieval, and manipulation (todos, user profiles, etc.).
- Backend and Asynchronous Processing:
- The backend offloads tasks to Celery workers (managed by celery_app.py) which are monitored via Flower.
- Backend Email Service:
- The backend uses predefined email templates to send emails, with MailHog intercepting these mails for development and testing purposes.
- Database Interaction:
- The backend interacts with a database through its ORM layer and session management (indicated by the "db" subfolder). PGAdmin is available as an external viewer for the database contents.

##### Architectural Patterns & Design Principles
- Modular organization by separating concerns (frontend, backend, reverse proxy, testing, etc.).
- Containerization via Docker ensuring consistency across different environments.
- Use of API versioning (api_v1) within the backend promotes scalability and maintainability.
- Incorporation of asynchronous task handling (Celery) for long-running or background jobs.
- Clear separation between presentation (React) and business logic/data (backend) layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User/Client"]:::external

    %% Reverse Proxy Layer
    RP["Reverse Proxy (nginx)"]:::proxy

    %% Frontend Layer
    FE["Frontend Application (React)"]:::frontend

    %% Backend Layer
    BE["Backend Application (FastAPI)"]:::backend

    %% Backend Subcomponents
    API["API Endpoints (v1)"]:::backendChild
    Celery["Celery Task Queue"]:::celery
    Email["Email Service (MailHog)"]:::email
    DB["Database (PostgreSQL)"]:::database
    Testing["Testing Suite"]:::testing

    %% User flow
    User -->|"sends request"| RP

    %% Reverse Proxy routing logic
    RP -->|"routes to"| FE
    RP -->|"routes to"| BE

    %% Frontend and Backend communication
    FE <-->|"RESTful API calls"| BE

    %% Backend internal interactions
    BE -->|"handles"| API
    BE -->|"offloads tasks to"| Celery
    BE -->|"sends emails via"| Email
    BE -->|"performs ORM calls to"| DB
    BE -->|"runs"| Testing

    %% Click Events
    click FE "https://github.com/linhnguyen411/3dscene/tree/main/frontend/"
    click BE "https://github.com/linhnguyen411/3dscene/tree/main/backend/"
    click API "https://github.com/linhnguyen411/3dscene/tree/main/backend/app/api/api_v1/"
    click Celery "https://github.com/linhnguyen411/3dscene/blob/main/backend/app/core/celery_app.py"
    click RP "https://github.com/linhnguyen411/3dscene/tree/main/reverse-proxy/"
    click Email "https://github.com/linhnguyen411/3dscene/tree/main/backend/app/email-templates/"
    click DB "https://github.com/linhnguyen411/3dscene/tree/main/backend/app/db/"
    click Testing "https://github.com/linhnguyen411/3dscene/tree/main/backend/app/tests/"

    %% Styles and Color Definitions
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef proxy fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef frontend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef backend fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef backendChild fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef celery fill:#c0ffc0,stroke:#333,stroke-width:2px;
    classDef email fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef database fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef testing fill:#dda0dd,stroke:#333,stroke-width:2px;
```
