# cjavsm/anima architecture

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

- Interactive diagram: https://gitdiagram.com/cjavsm/anima
- Repository: https://github.com/cjavsm/anima

## Overview

##### Project type and purpose
- This is a full-stack web application.
- Frontend (client/) is a React-based single-page application built with Vite.
- Backend (server/) is a Python FastAPI service exposing REST endpoints, using SQLAlchemy to talk to PostgreSQL and calling AWS Rekognition, Spotify API, and SMTP for email.
- database/ holds Docker Compose and init SQL for spinning up the Postgres database.

##### File structure
- Top‐level directories:
- client/ – all React code, styles, tests, config files (vite.config.js, package.json).
- server/ – FastAPI code organized into config, controllers, middlewares, models, routes, schemas, services, utils, tests, plus main.py.
- database/ – docker-compose.yml and init.sql.
- Patterns and layers:
- Frontend: “Services Layer” that makes HTTP calls, “Context API” for global state, “Pages/Components” under src/components.
- Backend: Routes → Controllers → Services → Models (ORM), with an Auth Middleware intercepting requests.
- Deployment/CI: GitHub Actions workflow for Python tests, Docker Compose for DB.

##### README for additional insights
“Cliente – Frontend,” “Servidor – Backend FastAPI,” and “Servicios Externos.”
- Shows how HTTP/REST, SQLAlchemy, boto3, spotipy, smtplib bind the components to external services.

##### Detail without overthinking
- Every logical component from the project tree (e.g., Auth middleware, individual service modules).
- Interaction path explicitly.
- Avoid overcrowding: group related controllers or models under a shared container if needed.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client - React"
        direction TB
        Components["Pages/Components Layer"]:::frontend
        Context["Context API"]:::frontend
        Config["API Configuration"]:::frontend
        ServicesFE["Services Layer"]:::frontend
    end

    %% Server Side
    subgraph "Server - FastAPI"
        direction TB
        AuthMW["Auth Middleware"]:::backend
        Routes["API Routes"]:::backend
        Controllers["Controllers"]:::backend
        ServicesBE["Services Layer"]:::backend
        Models["Models/ORM"]:::backend
        DBConfig["DB Configuration"]:::backend
        Utils["Security Utilities"]:::backend
    end

    %% Database
    subgraph "Database"
        DB["PostgreSQL"]:::database
    end

    %% External Services
    subgraph "External Services"
        Rekognition["AWS Rekognition"]:::external
        SpotifyAuth["Spotify Auth Service"]:::external
        SpotifyData["Spotify Data Service"]:::external
        SpotifyUser["Spotify User Service"]:::external
        SMTP["Gmail SMTP"]:::external
    end

    %% Connections
    ServicesFE -->|"HTTP/REST"| Routes
    AuthMW -.->|intercepts| Routes
    Routes --> Controllers
    Controllers --> ServicesBE
    ServicesBE --> Models
    ServicesBE --> Rekognition
    ServicesBE --> SpotifyAuth
    ServicesBE --> SpotifyData
    ServicesBE --> SpotifyUser
    ServicesBE --> SMTP
    Models -->|"SQLAlchemy"| DB
    DBConfig --> DB

    %% Click Events
    click Components "https://github.com/cjavsm/anima/tree/main/client/src/components/"
    click Context "https://github.com/cjavsm/anima/blob/main/client/src/context/AuthContext.jsx"
    click Config "https://github.com/cjavsm/anima/blob/main/client/src/config/api.js"
    click ServicesFE "https://github.com/cjavsm/anima/tree/main/client/src/services/"
    click AuthMW "https://github.com/cjavsm/anima/blob/main/server/app/middlewares/auth_middleware.py"
    click Routes "https://github.com/cjavsm/anima/tree/main/server/app/routes/"
    click Controllers "https://github.com/cjavsm/anima/tree/main/server/app/controllers/"
    click ServicesBE "https://github.com/cjavsm/anima/tree/main/server/app/services/"
    click Models "https://github.com/cjavsm/anima/tree/main/server/app/models/"
    click DBConfig "https://github.com/cjavsm/anima/blob/main/server/app/config/database.py"
    click Utils "https://github.com/cjavsm/anima/blob/main/server/app/utils/security.py"
    click DB "https://github.com/cjavsm/anima/blob/main/database/docker-compose.yml"
    click DB "https://github.com/cjavsm/anima/blob/main/database/init.sql"
    click Rekognition "https://github.com/cjavsm/anima/blob/main/server/app/services/rekognition_service.py"
    click SpotifyAuth "https://github.com/cjavsm/anima/blob/main/server/app/services/spotify_auth_service.py"
    click SpotifyData "https://github.com/cjavsm/anima/blob/main/server/app/services/spotify_service.py"
    click SpotifyUser "https://github.com/cjavsm/anima/blob/main/server/app/services/spotify_user_service.py"
    click SMTP "https://github.com/cjavsm/anima/blob/main/server/app/services/email_service.py"

    %% Styles
    classDef frontend fill:#61dafb,stroke:#333,stroke-width:1px
    classDef backend fill:#50b2b0,stroke:#333,stroke-width:1px
    classDef database fill:#f58928,stroke:#333,stroke-width:1px,shape:cylinder
    classDef external fill:#b0c4de,stroke:#333,stroke-width:1px,shape:oval
```
