# pycodebr/car_api architecture

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

- Interactive diagram: https://gitdiagram.com/pycodebr/car_api
- Repository: https://github.com/pycodebr/car_api

## Overview

Car API is a FastAPI REST service for accounts, authentication, vehicle brands, and users’ cars. A client sends requests through the application’s registered routers; the handlers validate request and response data, apply domain rules, and use an async SQLAlchemy session to access persisted records. Authentication issues and refreshes JWTs, while protected operations resolve the current user. The README identifies SQLite as the database. The graph reflects sampled handlers and documented capabilities; unsampled settings and migration wiring are not inferred.

Main entry points: [`car_api/core/database.py`](https://github.com/pycodebr/car_api/blob/main/car_api/core/database.py) (Async database sessions), [`car_api/routers/cars.py`](https://github.com/pycodebr/car_api/blob/main/car_api/routers/cars.py) (Car management), [`car_api/core/security.py`](https://github.com/pycodebr/car_api/blob/main/car_api/core/security.py) (JWT and password security), [`car_api/app.py`](https://github.com/pycodebr/car_api/blob/main/car_api/app.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_app["FastAPI application<br/>[app.py]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_security["JWT and password security<br/>[security.py]"]
  node_user_routes["User management<br/>[users.py]"]
  node_user_model["User records<br/>[users.py]"]
  node_user_schemas["User schemas<br/>[users.py]"]
end

subgraph group_catalog["Vehicle catalog"]
  node_brand_routes["Brand management<br/>[brands.py]"]
  node_car_routes["Car management<br/>[cars.py]"]
  node_car_model["Cars and brands<br/>[cars.py]"]
  node_car_schemas["Car schemas<br/>[cars.py]"]
  node_brand_schemas["Brand schemas<br/>[brands.py]"]
end

subgraph group_persistence["Persistence and contracts"]
  node_database["Async database sessions<br/>[database.py]"]
  node_settings["Application settings<br/>[settings.py]"]
  node_sqlite[("SQLite database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"registers routes"| node_auth_routes
node_app -->|"registers routes"| node_user_routes
node_app -->|"registers routes"| node_brand_routes
node_app -->|"registers routes"| node_car_routes
node_auth_routes -->|"authenticates and issues"| node_security
node_auth_routes -->|"validates tokens"| node_user_schemas
node_auth_routes -->|"gets session"| node_database
node_auth_routes -->|"uses current user"| node_user_model
node_security -->|"gets session"| node_database
node_security -->|"queries users"| node_user_model
node_user_routes -->|"hashes passwords"| node_security
node_user_routes -->|"gets session"| node_database
node_user_routes -->|"reads and writes"| node_user_model
node_user_routes -->|"validates and serializes"| node_user_schemas
node_brand_routes -->|"checks access"| node_security
node_brand_routes -->|"gets session"| node_database
node_brand_routes -->|"queries brands and cars"| node_car_model
node_brand_routes -->|"validates and serializes"| node_brand_schemas
node_car_routes -->|"checks access"| node_security
node_car_routes -->|"gets session"| node_database
node_car_routes -->|"reads and writes"| node_car_model
node_car_routes -->|"uses current user"| node_user_model
node_car_routes -->|"validates and serializes"| node_car_schemas
node_database -->|"loads database URL"| node_settings
node_database -->|"connects via engine"| node_sqlite
node_car_schemas -->|"embeds brand data"| node_brand_schemas
node_car_schemas -->|"embeds user data"| node_user_schemas
node_car_model -->|"relates car owner"| node_user_model

click node_app "https://github.com/pycodebr/car_api/blob/main/car_api/app.py"
click node_auth_routes "https://github.com/pycodebr/car_api/blob/main/car_api/routers/auth.py"
click node_security "https://github.com/pycodebr/car_api/blob/main/car_api/core/security.py"
click node_user_routes "https://github.com/pycodebr/car_api/blob/main/car_api/routers/users.py"
click node_user_model "https://github.com/pycodebr/car_api/blob/main/car_api/models/users.py"
click node_user_schemas "https://github.com/pycodebr/car_api/blob/main/car_api/schemas/users.py"
click node_brand_routes "https://github.com/pycodebr/car_api/blob/main/car_api/routers/brands.py"
click node_car_routes "https://github.com/pycodebr/car_api/blob/main/car_api/routers/cars.py"
click node_car_model "https://github.com/pycodebr/car_api/blob/main/car_api/models/cars.py"
click node_car_schemas "https://github.com/pycodebr/car_api/blob/main/car_api/schemas/cars.py"
click node_brand_schemas "https://github.com/pycodebr/car_api/blob/main/car_api/schemas/brands.py"
click node_database "https://github.com/pycodebr/car_api/blob/main/car_api/core/database.py"
click node_settings "https://github.com/pycodebr/car_api/blob/main/car_api/core/settings.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_client toneBlue
class node_auth_routes,node_security,node_user_routes,node_user_model,node_user_schemas toneAmber
class node_brand_routes,node_car_routes,node_car_model,node_car_schemas,node_brand_schemas toneMint
class node_database,node_settings,node_sqlite toneRose
```

## Components

### API routing

- [FastAPI application](https://github.com/pycodebr/car_api/blob/main/car_api/app.py): `car_api/app.py`

### Identity and access

- [Authentication routes](https://github.com/pycodebr/car_api/blob/main/car_api/routers/auth.py): `car_api/routers/auth.py`
- [JWT and password security](https://github.com/pycodebr/car_api/blob/main/car_api/core/security.py): `car_api/core/security.py`
- [User management](https://github.com/pycodebr/car_api/blob/main/car_api/routers/users.py): `car_api/routers/users.py`
- [User records](https://github.com/pycodebr/car_api/blob/main/car_api/models/users.py): `car_api/models/users.py`
- [User schemas](https://github.com/pycodebr/car_api/blob/main/car_api/schemas/users.py): `car_api/schemas/users.py`

### Vehicle catalog

- [Brand management](https://github.com/pycodebr/car_api/blob/main/car_api/routers/brands.py): `car_api/routers/brands.py`
- [Car management](https://github.com/pycodebr/car_api/blob/main/car_api/routers/cars.py): `car_api/routers/cars.py`
- [Cars and brands](https://github.com/pycodebr/car_api/blob/main/car_api/models/cars.py): `car_api/models/cars.py`
- [Car schemas](https://github.com/pycodebr/car_api/blob/main/car_api/schemas/cars.py): `car_api/schemas/cars.py`
- [Brand schemas](https://github.com/pycodebr/car_api/blob/main/car_api/schemas/brands.py): `car_api/schemas/brands.py`

### Persistence and contracts

- [Async database sessions](https://github.com/pycodebr/car_api/blob/main/car_api/core/database.py): `car_api/core/database.py`
- [Application settings](https://github.com/pycodebr/car_api/blob/main/car_api/core/settings.py): `car_api/core/settings.py`
- **SQLite database**

### Other components

- **API client**

## Connections

- API client → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Authentication routes: registers routes (evidence: `car_api/app.py`)
- FastAPI application → User management: registers routes (evidence: `car_api/app.py`)
- FastAPI application → Brand management: registers routes (evidence: `car_api/app.py`)
- FastAPI application → Car management: registers routes (evidence: `car_api/app.py`)
- Authentication routes → JWT and password security: authenticates and issues (evidence: `car_api/routers/auth.py`)
- Authentication routes → User schemas: validates tokens (evidence: `car_api/routers/auth.py`)
- Authentication routes → Async database sessions: gets session (evidence: `car_api/routers/auth.py`)
- Authentication routes → User records: uses current user (evidence: `car_api/routers/auth.py`)
- JWT and password security → Async database sessions: gets session (evidence: `car_api/core/security.py`)
- JWT and password security → User records: queries users (evidence: `car_api/core/security.py`)
- User management → JWT and password security: hashes passwords (evidence: `car_api/routers/users.py`)
- User management → Async database sessions: gets session (evidence: `car_api/routers/users.py`)
- User management → User records: reads and writes (evidence: `car_api/routers/users.py`)
- User management → User schemas: validates and serializes (evidence: `car_api/routers/users.py`)
- Brand management → JWT and password security: checks access (evidence: `car_api/routers/brands.py`)
- Brand management → Async database sessions: gets session (evidence: `car_api/routers/brands.py`)
- Brand management → Cars and brands: queries brands and cars (evidence: `car_api/routers/brands.py`)
- Brand management → Brand schemas: validates and serializes (evidence: `car_api/routers/brands.py`)
- Car management → JWT and password security: checks access (evidence: `car_api/routers/cars.py`)
- Car management → Async database sessions: gets session (evidence: `car_api/routers/cars.py`)
- Car management → Cars and brands: reads and writes (evidence: `car_api/routers/cars.py`)
- Car management → User records: uses current user (evidence: `car_api/routers/cars.py`)
- Car management → Car schemas: validates and serializes (evidence: `car_api/routers/cars.py`)
- Async database sessions → Application settings: loads database URL (evidence: `car_api/core/database.py`)
- Async database sessions → SQLite database: connects via engine (evidence: `README.md`)
- Car schemas → Brand schemas: embeds brand data (evidence: `car_api/schemas/cars.py`)
- Car schemas → User schemas: embeds user data (evidence: `car_api/schemas/cars.py`)
- Cars and brands → User records: relates car owner (evidence: `car_api/models/cars.py`)
