# tt1125/gabaithon202502saga2 architecture

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

- Interactive diagram: https://gitdiagram.com/tt1125/gabaithon202502saga2
- Repository: https://github.com/tt1125/gabaithon202502saga2

## Overview

##### Project Overview
- This is a full-stack application with a clear separation between a Python-based backend (located in app/back) and a Next.js/React-based frontend (located in app/front).
- The README focuses on connecting to a CloudSQL PostgreSQL instance, which means that database connectivity (using Cloud SQL Auth Proxy) is an important part of the system.

##### Main Components
a. Client (Browser):
- Represents the end-user’s web browser, which interacts with the frontend.

b. Frontend:
- Located in app/front.
- Built using Next.js with a component-based structure, hooks, and context providers.
- Responsible for user interface, routing, and calling backend APIs.

c. Backend:
- Located in app/back.
- Written in Python, with libraries such as embedding.py, gpt.py, and places.py.
- Likely handles business logic, API endpoints, and integration with external services such as GPT and potentially geospatial components.

d. Database:
- Cloud SQL PostgreSQL serves as the primary database.
- The README describes the use of the Cloud SQL Auth Proxy for secure connection.

e. Infrastructure & Deployment:
- Dockerfile and docker-compose.yml indicate containerization, so a container layer should be shown for both frontend and backend services.
- Cloud SQL proxy (and possibly cloud-sql-proxy executable files) as a dedicated component or service that facilitates database connectivity.

##### Relationships and Data Flow
- Cloud SQL Auth Proxy as a mediator between the backend container and the external PostgreSQL database.

## Diagram (Mermaid)

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

    %% Frontend
    Frontend["Frontend (Next.js/React)"]:::service

    %% Backend and its Modules
    subgraph "Backend Services"
        Backend["Backend (Python API)"]:::service
        Embedding["Embedding Module"]:::module
        GPT["GPT Module"]:::module
        Places["Places Module"]:::module
    end

    %% Database
    Database["Database (Cloud SQL PostgreSQL)"]:::db

    %% Infrastructure & Deployment
    subgraph "Infrastructure & Deployment"
        Dockerfile["Dockerfile"]:::infra
        DockerCompose["Docker Compose"]:::infra
        ProxyLinux["Cloud SQL Auth Proxy (Linux)"]:::infra
        ProxyWindows["Cloud SQL Auth Proxy (Windows)"]:::infra
    end

    %% Connections
    Client -->|"HTTP/HTTPS"| Frontend
    Frontend -->|"API_call"| Backend

    %% Backend Modules relations
    Backend -->|"uses"| Embedding
    Backend -->|"uses"| GPT
    Backend -->|"uses"| Places

    %% Database connection via Proxy
    Backend -->|"DB_query"| ProxyLinux
    ProxyLinux -->|"secure_conn"| Database

    %% Infrastructure orchestration
    Dockerfile -->|"used_by"| DockerCompose
    DockerCompose -->|"orchestrates"| Frontend
    DockerCompose -->|"orchestrates"| Backend
    DockerCompose -->|"manages"| ProxyLinux

    %% Styles
    classDef client fill:#ffcccc,stroke:#333,stroke-width:1px;
    classDef service fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef module fill:#e6e6fa,stroke:#333,stroke-width:1px;
    classDef db fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef infra fill:#fff2cc,stroke:#333,stroke-width:1px;

    %% Click Events
    click Frontend "https://github.com/tt1125/gabaithon202502saga2/tree/develop/app/front"
    click Backend "https://github.com/tt1125/gabaithon202502saga2/tree/develop/app/back"
    click Embedding "https://github.com/tt1125/gabaithon202502saga2/blob/develop/app/back/lib/embedding.py"
    click GPT "https://github.com/tt1125/gabaithon202502saga2/blob/develop/app/back/lib/gpt.py"
    click Places "https://github.com/tt1125/gabaithon202502saga2/blob/develop/app/back/lib/places.py"
    click Database "https://github.com/tt1125/gabaithon202502saga2/tree/develop/sql"
    click Dockerfile "https://github.com/tt1125/gabaithon202502saga2/tree/develop/Dockerfile"
    click DockerCompose "https://github.com/tt1125/gabaithon202502saga2/blob/develop/docker-compose.yml"
    click ProxyLinux "https://github.com/tt1125/gabaithon202502saga2/tree/develop/cloud-sql-proxy"
    click ProxyWindows "https://github.com/tt1125/gabaithon202502saga2/blob/develop/cloud-sql-proxy.exe"
```
