# diegitfk/cloud_proyect architecture

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

- Interactive diagram: https://gitdiagram.com/diegitfk/cloud_proyect
- Repository: https://github.com/diegitfk/cloud_proyect

## Overview

##### Overall Project Components
- Frontend: A Next.js application (indicated by the “frontend” folder structure with pages, api routes, components, and configuration files such as next.config.mjs and tsconfig.json). This represents the user interface, handling file management (upload, download, folder structure, trash, etc.) and the interaction with backend APIs.
- Backend: Split into two main services under the “backend” directory:
- Authentication Service (“backend/auth”): Implements login and user management using FastAPI and integrates with MongoDB (through the Beanie ODM). It manages user identity and maintains user folder data.
- Cloud Service (“backend/cloud”): Implements file handling functionalities like uploads, downloads, sharing, resource transfers, and even webhook handling. Like auth, it’s built on FastAPI with additional routers and utility modules.
- Nginx: Acts as a reverse proxy and load balancer (configured in “backend/nginx/nginx.conf”), routing incoming HTTP requests to the appropriate backend services.
- Docker/Docker Compose: The project uses Docker containers for deployment, as seen from Dockerfiles in subdirectories (both in auth and cloud) and a docker-compose.yml file which orchestrates the containers. This provides isolation, scalability, and a consistent deployment environment.
- MongoDB (logical component): Although not directly present in the file tree, the README and the ODM layer (Beanie framework) indicate that this database is used to store authentication data and users’ folder metadata.

##### Architectural Patterns and Design Principles
- Microservices/Multi-service Backend Architecture: The clear separation between auth and cloud services indicates a modular and scalable design.
- API Gateway/Reverse Proxy Pattern: Nginx is used to centralize request routing, load balancing, and potentially security enforcement before traffic reaches the backend containers.
- Containerization: Docker is used to encapsulate backend services which implies portability and easy reproducibility of environments.
- Data Modeling: Usage of Beanie ODM for MongoDB suggests an object-oriented approach in data management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["External Client"]:::client
    FFE["Next.js Frontend\n(React, TypeScript)"]:::frontend
    NG["Nginx\n(Reverse Proxy)"]:::nginx

    U -->|"HTTP-Request"| FFE
    FFE -->|"HTTP-Request"| NG

    subgraph "Docker Environment"
        direction TB
        Auth["Authentication Service\n(FastAPI, Docker)"]:::backend
        Cloud["Cloud/File Management Service\n(FastAPI, Docker)"]:::backend
    end

    NG -->|"Routes"| Auth
    NG -->|"Routes"| Cloud
    Auth -->|"DBOperations"| DB["MongoDB\n(Persistence)"]:::database
    Cloud -->|"DBOperations"| DB
    Auth ---|"InterService"| Cloud

    subgraph "Containerization & Orchestration"
        direction TB
        DC["Docker Compose"]:::docker
        Gestor["Gestor Compose Script"]:::docker
        AuthDF["Auth Dockerfile"]:::docker
        CloudDF["Cloud Dockerfile"]:::docker
    end

    DC ---|"Orchestrates"| Auth
    DC ---|"Orchestrates"| Cloud
    Gestor ---|"Supports"| DC
    AuthDF ---|"Builds"| Auth
    CloudDF ---|"Builds"| Cloud

    click FFE "https://github.com/diegitfk/cloud_proyect/tree/main/frontend"
    click Auth "https://github.com/diegitfk/cloud_proyect/tree/main/backend/auth"
    click Cloud "https://github.com/diegitfk/cloud_proyect/tree/main/backend/cloud"
    click NG "https://github.com/diegitfk/cloud_proyect/blob/main/backend/nginx/nginx.conf"
    click DC "https://github.com/diegitfk/cloud_proyect/blob/main/backend/docker-compose.yml"
    click Gestor "https://github.com/diegitfk/cloud_proyect/blob/main/backend/gestor-compose.sh"
    click AuthDF "https://github.com/diegitfk/cloud_proyect/tree/main/backend/auth/Dockerfile"
    click CloudDF "https://github.com/diegitfk/cloud_proyect/tree/main/backend/cloud/Dockerfile"

    classDef client fill:#FFE4B5,stroke:#000,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef nginx fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef docker fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
