# elioenaijs/crud-fastapi architecture

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

- Interactive diagram: https://gitdiagram.com/elioenaijs/crud-fastapi
- Repository: https://github.com/elioenaijs/crud-fastapi

## Overview

##### Project type and purpose
- This is a backend-only REST API written in Python (FastAPI, served via Uvicorn) with a MySQL database managed through Docker Compose.
- It implements a classic layered (MVC-inspired) architecture to manage “tasks” (create, read, update, delete).

##### File structure
- Top-level entrypoint: `main.py` (bootstraps FastAPI/Uvicorn).
- `controllers/` houses request‐handling logic (TaskController).
- `services/` contains business logic (TaskService).
- `db/` holds low-level database configuration and connection (db/db.py).
- `models/` defines ORM models (Task model).
- `schemas/` defines Pydantic schemas for validation and serialization.
- `docker-compose.yml` orchestrates a MySQL container.
- `requirements.txt` pins Python dependencies.

##### README for additional insights
- Uses a virtual environment, installs dependencies, boots MySQL via Docker, then runs `uvicorn app.main:app`.
- Exposes Swagger docs at `/docs`.
- Core stack: FastAPI, Uvicorn, Pydantic, MySQL (Docker).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    User["Client\n(Browser/Postman/Mobile)"]:::client

    %% API Server Layer
    subgraph "API Server: FastAPI/Uvicorn"
        direction TB
        Entry["Entry Point\n- main.py"]:::backend
        Controllers["Controllers\n- task_controller.py"]:::backend
        Schemas["Schemas\n- schemas.py"]:::backend
        Services["Services\n- task_service.py"]:::backend
        subgraph "Data Access / ORM"
            direction TB
            DBConfig["DB Config\n- db/db.py"]:::backend
            ORM["ORM Models\n- task.py"]:::backend
        end
        Req["Dependencies\n- requirements.txt"]:::config
    end

    %% Database Container
    subgraph "Docker Network"
        direction TB
        MySQL[(MySQL Container\nPort: 3306)]:::database
    end

    %% Connections
    User -->|"JSON over HTTP"| Entry
    Entry -->|"route to"| Controllers
    Controllers -->|"validate input"| Schemas
    Controllers -->|"call service"| Services
    Services -->|"use models"| ORM
    Services -->|"CRUD operations"| DBConfig
    DBConfig -->|"SQL queries"| MySQL
    MySQL -->|"query results"| DBConfig
    DBConfig -->|"data objects"| Services
    Services -->|"business response"| Controllers
    Controllers -->|"JSON response"| User
    Entry -->|"loads deps"| Req

    %% Click Events
    click Entry "https://github.com/elioenaijs/crud-fastapi/blob/main/main.py"
    click Controllers "https://github.com/elioenaijs/crud-fastapi/blob/main/controllers/task_controller.py"
    click Services "https://github.com/elioenaijs/crud-fastapi/blob/main/services/task_service.py"
    click DBConfig "https://github.com/elioenaijs/crud-fastapi/blob/main/db/db.py"
    click ORM "https://github.com/elioenaijs/crud-fastapi/blob/main/models/task.py"
    click Schemas "https://github.com/elioenaijs/crud-fastapi/blob/main/schemas/schemas.py"
    click MySQL "https://github.com/elioenaijs/crud-fastapi/blob/main/docker-compose.yml"
    click Req "https://github.com/elioenaijs/crud-fastapi/blob/main/requirements.txt"

    %% Styles
    classDef client fill:#ACE,stroke:#000,stroke-width:1px
    classDef backend fill:#CEF,stroke:#036,stroke-width:1px
    classDef database fill:#FC9,stroke:#933,stroke-width:1px,stroke-dasharray: 5 5
    classDef config fill:#EEE,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2
```
