# arthurhenrique/cookiecutter-fastapi architecture

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

- Interactive diagram: https://gitdiagram.com/arthurhenrique/cookiecutter-fastapi
- Repository: https://github.com/arthurhenrique/cookiecutter-fastapi

## Overview

##### Main Components

A. Template Generation Layer
- Cookiecutter Engine
- Template Configuration (cookiecutter.json)
- Project Template Structure

B. Generated Project Architecture
- FastAPI Application Layer
- Machine Learning Layer
- Service Layer
- Infrastructure Layer

**[Cookiecutter CLI] → [Template Config] → [Project Generator] → [Generated Project]**

- API Layer (FastAPI)
- ML Pipeline
- Data Processing
- Feature Engineering
- Model Serving
- Services
- Infrastructure

##### Component Details

A. API Layer (app/):
- Core components (config, events, errors)
- Prediction endpoints

B. ML Pipeline (ml/):
- Data processing pipeline
- Feature engineering components
- Model serving infrastructure

C. Services Layer:
- Prediction service
- Error handling
- Logging system

D. Infrastructure:
- Docker container
- CI/CD pipeline
- Environment configuration

##### Key Relationships to Highlight

- How the API routes connect to the ML services
- Data flow from input through the ML pipeline
- Demonstrate how the prediction service integrates with the API
- Infrastructure dependencies

##### Additional Elements

- Version information and key dependencies
- Configuration flow
- Error handling paths

##### How the generated project will be structured

This will help developers understand both the template system and the resulting application architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Template_Generation
        CC[Cookiecutter CLI]
        TC[Template Config]:::config
        PG[Project Generator]
        GP[Generated Project Structure]:::structure
    end

    subgraph Generated_Project
        subgraph API_Layer
            FA[FastAPI App]:::api
            RE["API Routes"]:::api
            PE["Prediction Endpoint"]:::api
            CC_["Core Components"]:::api
        end

        subgraph ML_Layer
            DP[Data Processing]:::ml
            FE[Feature Engineering]:::ml
            MS[Model Storage]:::ml
            ME[Model Examples]:::ml
        end

        subgraph Service_Layer
            PS[Prediction Service]:::service
            EH[Error Handler]:::service
            LS[Logging System]:::service
        end

        subgraph Infrastructure_Layer
            DC[Docker Config]:::infra
            DCP[Docker Compose]:::infra
            CI[CI/CD Pipeline]:::infra
            ENV[Environment Config]:::infra
        end
    end

    %% Template Generation Flow
    CC --> TC
    TC --> PG
    PG --> GP

    %% API Layer Connections
    FA --> RE
    RE --> PE
    FA --> CC_

    %% ML Layer Flow
    DP --> FE
    FE --> MS
    MS --> ME

    %% Service Integration
    PE --> PS
    PS --> MS
    PS --> EH
    PS --> LS

    %% Infrastructure Dependencies
    DC --> FA
    DCP --> DC
    CI --> DCP
    ENV --> FA

    %% Click Events
    click TC "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/cookiecutter.json"
    click GP "https://github.com/arthurhenrique/cookiecutter-fastapi/tree/main/{{cookiecutter.project_slug}}/"
    click FA "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/app/main.py"
    click RE "https://github.com/arthurhenrique/cookiecutter-fastapi/tree/main/{{cookiecutter.project_slug}}/app/api/routes/"
    click PE "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/app/api/routes/predictor.py"
    click CC_ "https://github.com/arthurhenrique/cookiecutter-fastapi/tree/main/{{cookiecutter.project_slug}}/app/core/"
    click DP "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/ml/data/make_dataset.py"
    click FE "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/ml/features/build_features.py"
    click MS "https://github.com/arthurhenrique/cookiecutter-fastapi/tree/main/{{cookiecutter.project_slug}}/ml/model/"
    click ME "https://github.com/arthurhenrique/cookiecutter-fastapi/tree/main/{{cookiecutter.project_slug}}/ml/model/examples/"
    click PS "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/app/services/predict.py"
    click EH "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/app/core/errors.py"
    click LS "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/app/core/logging.py"
    click DC "https://github.com/arthurhenrique/cookiecutter-fastapi/tree/main/{{cookiecutter.project_slug}}/Dockerfile"
    click DCP "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/docker-compose.yml"
    click CI "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/.github/workflows/ci.yaml"
    click ENV "https://github.com/arthurhenrique/cookiecutter-fastapi/blob/main/{{cookiecutter.project_slug}}/.env.example"

    %% Styling
    classDef api fill:#2374ab
    classDef ml fill:#57a773
    classDef service fill:#ffc857
    classDef infra fill:#929292
    classDef config fill:#ff8c42
    classDef structure fill:#c2c2c2

    %% Legend
    subgraph Legend
        L1[API Component]:::api
        L2[ML Component]:::ml
        L3[Service Component]:::service
        L4[Infrastructure Component]:::infra
        L5[Template Config]:::config
        L6[Project Structure]:::structure
    end
```
