# benatbarrueta/tfg architecture

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

- Interactive diagram: https://gitdiagram.com/benatbarrueta/tfg
- Repository: https://github.com/benatbarrueta/tfg

## Overview

##### Project type and purpose
- This is a full-stack, containerized microservices application.
- Frontend: A React single-page app built under web/ and served via nginx.
- Backend: Two Python microservices (microservicioAuth, microservicioConsultas) plus a lightweight “db” microservice (ecotrackdb) that exposes the SQLite database.
- Orchestration & deployment: Docker and docker-compose at the root.

##### File structure
- Top-level files:
- docker-compose.yml: brings up nginx (serving the web UI) and the three microservice containers.
- ecotrackdb/: Dockerfile, SQLite file, db.py — the persistence layer.
- microservicioAuth/: Dockerfile + main.py — handles authentication flows (token issuance, callbacks).
- microservicioConsultas/: Dockerfile + main.py — handles data queries.
- web/: React code, nginx.conf, Dockerfile, static assets under public/ (Leaflet map), source under src/.

##### README for additional insights
- The README focuses on how to install Docker, set up SSH keys, clone the repo, and run docker-compose for nginx and the project.

##### Key reminders
- Be detailed: include each service as a separate component.
- Docker-compose services and their interactions.
- Keep labels concise but informative (e.g., “Auth Service (Python/Flask)”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Client["Browser (User)"]:::client

    %% API Gateway / Static Server
    ApiGateway["Nginx API Gateway\n& Static Server"]:::gateway

    %% Frontend Layer
    ReactApp["React SPA"]:::frontend
    NginxConf["nginx.conf"]:::frontend

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        AuthService["Auth Service\n(Python/Flask)"]:::backend
        ConsultasService["Consultas Service\n(Python/Flask)"]:::backend
    end

    %% Database Layer
    subgraph "Data Layer"
        direction TB
        DbService["Database Service\n(SQLite)"]:::db
        DbFile["ecotrack.db"]:::db
    end

    %% Orchestration File
    Compose["docker-compose.yml"]:::orchestration

    %% Connections
    Client -->|"HTTPS"| ApiGateway
    ApiGateway -->|"Serves React UI"| ReactApp
    ApiGateway -->|"Routes /api/auth/*"| AuthService
    ApiGateway -->|"Routes /api/consultas/*"| ConsultasService

    AuthService -->|"Internal REST"| DbService
    ConsultasService -->|"Internal REST"| DbService
    DbService -->|"Reads/Writes"| DbFile

    %% Click Events for Component Mapping
    click ReactApp "https://github.com/benatbarrueta/tfg/tree/main/web/"
    click NginxConf "https://github.com/benatbarrueta/tfg/blob/main/web/nginx.conf"
    click ApiGateway "https://github.com/benatbarrueta/tfg/blob/main/docker-compose.yml"
    click Client "https://github.com/benatbarrueta/tfg/blob/main/docker-compose.yml"
    click AuthService "https://github.com/benatbarrueta/tfg/tree/main/microservicioAuth/"
    click AuthService "https://github.com/benatbarrueta/tfg/blob/main/microservicioAuth/main.py"
    click AuthService "https://github.com/benatbarrueta/tfg/tree/main/microservicioAuth/Dockerfile"
    click AuthService "https://github.com/benatbarrueta/tfg/blob/main/microservicioAuth/requirements.txt"
    click ConsultasService "https://github.com/benatbarrueta/tfg/tree/main/microservicioConsultas/"
    click ConsultasService "https://github.com/benatbarrueta/tfg/blob/main/microservicioConsultas/main.py"
    click ConsultasService "https://github.com/benatbarrueta/tfg/tree/main/microservicioConsultas/Dockerfile"
    click ConsultasService "https://github.com/benatbarrueta/tfg/blob/main/microservicioConsultas/requirements.txt"
    click DbService "https://github.com/benatbarrueta/tfg/tree/main/ecotrackdb/"
    click DbService "https://github.com/benatbarrueta/tfg/blob/main/ecotrackdb/db.py"
    click DbService "https://github.com/benatbarrueta/tfg/tree/main/ecotrackdb/Dockerfile"
    click DbService "https://github.com/benatbarrueta/tfg/blob/main/ecotrackdb/requirements.txt"
    click DbFile "https://github.com/benatbarrueta/tfg/blob/main/ecotrackdb/data/ecotrack.db"
    click Compose "https://github.com/benatbarrueta/tfg/blob/main/docker-compose.yml"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef frontend fill:#B0E0E6,stroke:#333,stroke-width:1px;
    classDef gateway fill:#FFD700,stroke:#333,stroke-width:1px;
    classDef backend fill:#98FB98,stroke:#333,stroke-width:1px;
    classDef db fill:#F5DEB3,stroke:#333,stroke-width:1px;
    classDef orchestration fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
