# gauti1409/fastapi_project architecture

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

- Interactive diagram: https://gitdiagram.com/gauti1409/fastapi_project
- Repository: https://github.com/gauti1409/fastapi_project

## Overview

This FastAPI social-media API supports user registration and login, JWT-authenticated ORM post operations, and voting, alongside a separate direct-SQL posts API. Its main request path runs from FastAPI router dispatch through route handlers to PostgreSQL, with schemas shaping inputs and outputs. The graph also retains user and authentication flows and the two distinct persistence styles. Evidence is limited to the README (empty) and supplied excerpts; unsampled user routes and several implementation details are represented only where the source index establishes their imports.

Main entry points: [`app/main_files/database.py`](https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/database.py) (Database access), [`app/main.py`](https://github.com/gauti1409/fastapi_project/blob/main/app/main.py) (FastAPI app), [`app/routers/oauth2.py`](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/oauth2.py) (JWT security), [`app/routers/auth.py`](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/auth.py) (Login route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["API runtime"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_config["Settings<br/>[config.py]"]
end

subgraph group_identity["Identity and users"]
  node_auth["Login route<br/>[auth.py]"]
  node_oauth["JWT security<br/>[oauth2.py]"]
  node_userorm["ORM user routes<br/>[users_orm.py]"]
  node_users["Direct-SQL user routes<br/>[users.py]"]
  node_passwords["Password hashing<br/>[utils.py]"]
end

subgraph group_content["Posts and votes"]
  node_ormposts["ORM post routes<br/>[post_orm.py]"]
  node_sqlposts["Direct-SQL posts<br/>[post.py]"]
  node_votes["Voting routes<br/>[vote.py]"]
  node_calculations["Calculations<br/>[calculations.py]"]
end

subgraph group_persistence["Persistence and contracts"]
  node_schemas["Request/response schemas<br/>[schemas.py]"]
  node_models["ORM models<br/>[models.py]"]
  node_database["Database access<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_fastapi
node_fastapi -->|"routes to"| node_auth
node_fastapi -->|"routes to"| node_sqlposts
node_fastapi -->|"routes to"| node_users
node_fastapi -->|"routes to"| node_ormposts
node_fastapi -->|"routes to"| node_userorm
node_fastapi -->|"routes to"| node_votes
node_fastapi -->|"creates tables"| node_database
node_fastapi -->|"loads settings"| node_config
node_database -->|"reads credentials"| node_config
node_database -->|"connects to"| node_postgres
node_models -->|"uses Base"| node_database
node_auth -->|"gets session"| node_database
node_auth -->|"queries user"| node_models
node_auth -->|"verifies password"| node_passwords
node_auth -->|"creates token"| node_oauth
node_auth -->|"uses schemas"| node_schemas
node_oauth -->|"gets session"| node_database
node_oauth -->|"loads user"| node_models
node_oauth -->|"validates token data"| node_schemas
node_oauth -->|"reads JWT settings"| node_config
node_userorm -->|"hashes password"| node_passwords
node_userorm -->|"writes user"| node_models
node_userorm -->|"uses session"| node_database
node_userorm -->|"validates and returns"| node_schemas
node_users -->|"uses database"| node_database
node_ormposts -->|"requires current user"| node_oauth
node_ormposts -->|"uses session"| node_database
node_ormposts -->|"queries and writes"| node_models
node_ormposts -->|"uses schemas"| node_schemas
node_sqlposts -->|"executes SQL"| node_database
node_sqlposts -->|"uses schemas"| node_schemas
node_votes -->|"requires current user"| node_oauth
node_votes -->|"uses session"| node_database
node_votes -->|"checks and writes votes"| node_models
node_votes -->|"accepts vote schema"| node_schemas

click node_fastapi "https://github.com/gauti1409/fastapi_project/blob/main/app/main.py"
click node_config "https://github.com/gauti1409/fastapi_project/blob/main/app/config.py"
click node_auth "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/auth.py"
click node_oauth "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/oauth2.py"
click node_userorm "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/users_orm.py"
click node_users "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/users.py"
click node_passwords "https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/utils.py"
click node_ormposts "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/post_orm.py"
click node_sqlposts "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/post.py"
click node_votes "https://github.com/gauti1409/fastapi_project/blob/main/app/routers/vote.py"
click node_calculations "https://github.com/gauti1409/fastapi_project/blob/main/app/calculations.py"
click node_schemas "https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/schemas.py"
click node_models "https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/models.py"
click node_database "https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/database.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_fastapi,node_config,node_client toneBlue
class node_auth,node_oauth,node_userorm,node_users,node_passwords toneAmber
class node_ormposts,node_sqlposts,node_votes,node_calculations toneMint
class node_schemas,node_models,node_database,node_postgres toneRose
```

## Components

### API runtime

- [FastAPI app](https://github.com/gauti1409/fastapi_project/blob/main/app/main.py): `app/main.py`
- [Settings](https://github.com/gauti1409/fastapi_project/blob/main/app/config.py): `app/config.py`

### Identity and users

- [Login route](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [JWT security](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/oauth2.py): `app/routers/oauth2.py`
- [ORM user routes](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/users_orm.py): `app/routers/users_orm.py`
- [Direct-SQL user routes](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/users.py): `app/routers/users.py`
- [Password hashing](https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/utils.py): `app/main_files/utils.py`

### Posts and votes

- [ORM post routes](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/post_orm.py): `app/routers/post_orm.py`
- [Direct-SQL posts](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/post.py): `app/routers/post.py`
- [Voting routes](https://github.com/gauti1409/fastapi_project/blob/main/app/routers/vote.py): `app/routers/vote.py`
- [Calculations](https://github.com/gauti1409/fastapi_project/blob/main/app/calculations.py): `app/calculations.py`

### Persistence and contracts

- [Request/response schemas](https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/schemas.py): `app/main_files/schemas.py`
- [ORM models](https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/models.py): `app/main_files/models.py`
- [Database access](https://github.com/gauti1409/fastapi_project/blob/main/app/main_files/database.py): `app/main_files/database.py`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `app/main.py`)
- FastAPI app → Login route: routes to (evidence: `app/main.py`)
- FastAPI app → Direct-SQL posts: routes to (evidence: `app/main.py`)
- FastAPI app → Direct-SQL user routes: routes to (evidence: `app/main.py`)
- FastAPI app → ORM post routes: routes to (evidence: `app/main.py`)
- FastAPI app → ORM user routes: routes to (evidence: `app/main.py`)
- FastAPI app → Voting routes: routes to (evidence: `app/main.py`)
- FastAPI app → Database access: creates tables (evidence: `app/main.py`)
- FastAPI app → Settings: loads settings (evidence: `app/main.py`)
- Database access → Settings: reads credentials (evidence: `app/main_files/database.py`)
- Database access → PostgreSQL: connects to (evidence: `app/main_files/database.py`)
- ORM models → Database access: uses Base (evidence: `app/main_files/models.py`)
- Login route → Database access: gets session (evidence: `app/routers/auth.py`)
- Login route → ORM models: queries user (evidence: `app/routers/auth.py`)
- Login route → Password hashing: verifies password (evidence: `app/routers/auth.py`)
- Login route → JWT security: creates token (evidence: `app/routers/auth.py`)
- Login route → Request/response schemas: uses schemas (evidence: `app/routers/auth.py`)
- JWT security → Database access: gets session (evidence: `app/routers/oauth2.py`)
- JWT security → ORM models: loads user (evidence: `app/routers/oauth2.py`)
- JWT security → Request/response schemas: validates token data (evidence: `app/routers/oauth2.py`)
- JWT security → Settings: reads JWT settings (evidence: `app/routers/oauth2.py`)
- ORM user routes → Password hashing: hashes password (evidence: `app/routers/users_orm.py`)
- ORM user routes → ORM models: writes user (evidence: `app/routers/users_orm.py`)
- ORM user routes → Database access: uses session (evidence: `app/routers/users_orm.py`)
- ORM user routes → Request/response schemas: validates and returns (evidence: `app/routers/users_orm.py`)
- Direct-SQL user routes → Database access: uses database (evidence: `app/routers/users.py`)
- ORM post routes → JWT security: requires current user (evidence: `app/routers/post_orm.py`)
- ORM post routes → Database access: uses session (evidence: `app/routers/post_orm.py`)
- ORM post routes → ORM models: queries and writes (evidence: `app/routers/post_orm.py`)
- ORM post routes → Request/response schemas: uses schemas (evidence: `app/routers/post_orm.py`)
- Direct-SQL posts → Database access: executes SQL (evidence: `app/routers/post.py`)
- Direct-SQL posts → Request/response schemas: uses schemas (evidence: `app/routers/post.py`)
- Voting routes → JWT security: requires current user (evidence: `app/routers/vote.py`)
- Voting routes → Database access: uses session (evidence: `app/routers/vote.py`)
- Voting routes → ORM models: checks and writes votes (evidence: `app/routers/vote.py`)
- Voting routes → Request/response schemas: accepts vote schema (evidence: `app/routers/vote.py`)
