# jneiras/tm-fastapi architecture

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

- Interactive diagram: https://gitdiagram.com/jneiras/tm-fastapi
- Repository: https://github.com/jneiras/tm-fastapi

## Overview

##### Project type and purpose
- This is a backend REST API built with Python and FastAPI.
- It follows a layered (onion/hexagonal) architecture: interface (API), application (use-cases), business services, domain, and infrastructure.
- It persists data via SQLAlchemy to a SQLite database.

##### File structure
- src/interface/api.py: FastAPI app and route definitions (API layer).
- src/application/use_cases.py: orchestrates business logic (Application layer).
- src/services/*.py: core business services for tasks and users.
- src/domain: domain models, DTO schemas, and exceptions (Domain layer).
- src/infrastructure: persistence setup, repository interfaces and implementations, ORM models (Infrastructure layer).
- main.py: likely the entrypoint that boots the FastAPI app.

##### README for additional insights
- Minimal description (“API .”) but mentions installation steps with npm—this seems a template error; real stack is Python.

## Diagram (Mermaid)

```mermaid
flowchart TD
  classDef external fill:#f9f,stroke:#333;
  classDef api fill:#bbf,stroke:#333;
  classDef app fill:#bfb,stroke:#333;
  classDef service fill:#ffb,stroke:#333;
  classDef domain fill:#fbb,stroke:#333;
  classDef infra fill:#ddd,stroke:#333;
  classDef db fill:#cab,stroke:#333;

  Client["External Client"]:::external

  subgraph "Interface / API Layer"
    FastAPI["FastAPI App (main.py)"]:::api
    API["API Routers (src/interface/api.py)"]:::api
  end

  subgraph "Application Layer"
    UseCases["Use-Cases (src/application/use_cases.py)"]:::app
  end

  subgraph "Business Services"
    TaskService["TaskService (src/services/task_services.py)"]:::service
    UserService["UserService (src/services/user_services.py)"]:::service
  end

  subgraph "Domain Layer"
    Entities["Models (src/domain/models.py)"]:::domain
    Schemas["DTOs (src/domain/schemas.py)"]:::domain
    Exceptions["Exceptions (src/domain/exceptions.py)"]:::domain
  end

  subgraph "Infrastructure Layer"
    DBSetup["DB Engine/Session (src/infrastructure/persistence/db.py)"]:::infra
    ORM["SQLAlchemy Models (src/infrastructure/sqlalchemy_models.py)"]:::infra
    ReposIF["Repo Interfaces (src/infrastructure/repositories.py)"]:::infra
    TaskRepo["TaskRepo Impl. (src/infrastructure/task_repository.py)"]:::infra
  end

  Database["SQLite Database"]:::db

  Client -->|HTTP Request| FastAPI
  FastAPI -->|routes defined| API
  API -->|calls| UseCases
  UseCases -->|invoke| TaskService
  UseCases -->|invoke| UserService
  TaskService -->|uses| Entities
  TaskService -->|validates| Schemas
  TaskService -->|throws| Exceptions
  TaskService -->|calls| ReposIF
  ReposIF -->|implemented by| TaskRepo
  TaskRepo -->|uses ORM| ORM
  TaskRepo -->|executes SQL| DBSetup
  DBSetup -->|connects| Database

  click FastAPI "https://github.com/jneiras/tm-fastapi/blob/master/main.py"
  click API "https://github.com/jneiras/tm-fastapi/blob/master/src/interface/api.py"
  click UseCases "https://github.com/jneiras/tm-fastapi/blob/master/src/application/use_cases.py"
  click TaskService "https://github.com/jneiras/tm-fastapi/blob/master/src/services/task_services.py"
  click UserService "https://github.com/jneiras/tm-fastapi/blob/master/src/services/user_services.py"
  click Entities "https://github.com/jneiras/tm-fastapi/blob/master/src/domain/models.py"
  click Schemas "https://github.com/jneiras/tm-fastapi/blob/master/src/domain/schemas.py"
  click Exceptions "https://github.com/jneiras/tm-fastapi/blob/master/src/domain/exceptions.py"
  click DBSetup "https://github.com/jneiras/tm-fastapi/blob/master/src/infrastructure/persistence/db.py"
  click ORM "https://github.com/jneiras/tm-fastapi/blob/master/src/infrastructure/sqlalchemy_models.py"
  click ReposIF "https://github.com/jneiras/tm-fastapi/blob/master/src/infrastructure/repositories.py"
  click TaskRepo "https://github.com/jneiras/tm-fastapi/blob/master/src/infrastructure/task_repository.py"
```
