# manastyagigit/fastapi architecture

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

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

## Overview

This repository is a learning-project FastAPI application for user accounts, authenticated posts, and likes. A client request enters the application configured in `app/main.py`, reaches a registered router, and uses schemas, authentication helpers, and database models as needed; results are returned as API responses. The graph reflects the current router-based application, not the older standalone examples. Relationships are limited to those shown in sampled source or the source index; unsampled implementation details are not inferred.

Main entry points: [`app/database.py`](https://github.com/manastyagigit/fastapi/blob/main/app/database.py) (Database sessions), [`app/OAuth2.py`](https://github.com/manastyagigit/fastapi/blob/main/app/OAuth2.py) (Token security), [`app/main.py`](https://github.com/manastyagigit/fastapi/blob/main/app/main.py) (FastAPI app), [`app/routers/auth.py`](https://github.com/manastyagigit/fastapi/blob/main/app/routers/auth.py) (Login route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry and routes"]
  node_entry["FastAPI app<br/>[main.py]"]
  node_auth_route["Login route<br/>[auth.py]"]
  node_user_route["User routes<br/>[user.py]"]
  node_post_route["Post routes<br/>[post.py]"]
  node_like_route["Like route<br/>[like.py]"]
end

subgraph group_identity["Identity and validation"]
  node_oauth["Token security<br/>[OAuth2.py]"]
  node_passwords["Password hashing<br/>[utils.py]"]
  node_schemas["Request responses<br/>[schemas.py]"]
end

subgraph group_domain["Posts and likes"]
  node_post_model["Post model<br/>[models.py]"]
  node_user_model["User model<br/>[models.py]"]
  node_like_model["Like model<br/>[models.py]"]
end

subgraph group_storage["Persistence and configuration"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_settings["Application settings<br/>[config.py]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_entry
node_entry -->|"registers"| node_auth_route
node_entry -->|"registers"| node_user_route
node_entry -->|"registers"| node_post_route
node_entry -->|"registers"| node_like_route
node_entry -->|"creates tables"| node_db_session
node_auth_route -->|"queries"| node_db_session
node_auth_route -->|"checks user"| node_user_model
node_auth_route -->|"verifies password"| node_passwords
node_auth_route -->|"creates token"| node_oauth
node_auth_route -->|"uses token schema"| node_schemas
node_oauth -->|"gets session"| node_db_session
node_oauth -->|"loads user"| node_user_model
node_oauth -->|"builds token data"| node_schemas
node_user_route -->|"queries and writes"| node_db_session
node_user_route -->|"creates and reads"| node_user_model
node_user_route -->|"hashes password"| node_passwords
node_user_route -->|"validates and shapes"| node_schemas
node_post_route -->|"queries and writes"| node_db_session
node_post_route -->|"manages posts"| node_post_model
node_post_route -->|"counts likes"| node_like_model
node_post_route -->|"requires user"| node_oauth
node_post_route -->|"validates and shapes"| node_schemas
node_like_route -->|"queries and writes"| node_db_session
node_like_route -->|"checks post"| node_post_model
node_like_route -->|"adds or removes"| node_like_model
node_like_route -->|"requires user"| node_oauth
node_like_route -->|"validates input"| node_schemas
node_db_session -->|"loads credentials"| node_settings
node_oauth -->|"loads token settings"| node_settings
node_db_session -->|"connects"| node_postgres

click node_entry "https://github.com/manastyagigit/fastapi/blob/main/app/main.py"
click node_auth_route "https://github.com/manastyagigit/fastapi/blob/main/app/routers/auth.py"
click node_user_route "https://github.com/manastyagigit/fastapi/blob/main/app/routers/user.py"
click node_post_route "https://github.com/manastyagigit/fastapi/blob/main/app/routers/post.py"
click node_like_route "https://github.com/manastyagigit/fastapi/blob/main/app/routers/like.py"
click node_oauth "https://github.com/manastyagigit/fastapi/blob/main/app/OAuth2.py"
click node_passwords "https://github.com/manastyagigit/fastapi/blob/main/app/utils.py"
click node_schemas "https://github.com/manastyagigit/fastapi/blob/main/app/schemas.py"
click node_post_model "https://github.com/manastyagigit/fastapi/blob/main/app/models.py"
click node_user_model "https://github.com/manastyagigit/fastapi/blob/main/app/models.py"
click node_like_model "https://github.com/manastyagigit/fastapi/blob/main/app/models.py"
click node_db_session "https://github.com/manastyagigit/fastapi/blob/main/app/database.py"
click node_settings "https://github.com/manastyagigit/fastapi/blob/main/app/config.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_entry,node_auth_route,node_user_route,node_post_route,node_like_route,node_client toneBlue
class node_oauth,node_passwords,node_schemas,node_postgres toneAmber
class node_post_model,node_user_model,node_like_model toneMint
class node_db_session,node_settings toneRose
```

## Components

### API entry and routes

- [FastAPI app](https://github.com/manastyagigit/fastapi/blob/main/app/main.py): `app/main.py`
- [Login route](https://github.com/manastyagigit/fastapi/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [User routes](https://github.com/manastyagigit/fastapi/blob/main/app/routers/user.py): `app/routers/user.py`
- [Post routes](https://github.com/manastyagigit/fastapi/blob/main/app/routers/post.py): `app/routers/post.py`
- [Like route](https://github.com/manastyagigit/fastapi/blob/main/app/routers/like.py): `app/routers/like.py`

### Identity and validation

- [Token security](https://github.com/manastyagigit/fastapi/blob/main/app/OAuth2.py): `app/OAuth2.py`
- [Password hashing](https://github.com/manastyagigit/fastapi/blob/main/app/utils.py): `app/utils.py`
- [Request responses](https://github.com/manastyagigit/fastapi/blob/main/app/schemas.py): `app/schemas.py`

### Posts and likes

- [Post model](https://github.com/manastyagigit/fastapi/blob/main/app/models.py): `app/models.py`
- [User model](https://github.com/manastyagigit/fastapi/blob/main/app/models.py): `app/models.py`
- [Like model](https://github.com/manastyagigit/fastapi/blob/main/app/models.py): `app/models.py`

### Persistence and configuration

- [Database sessions](https://github.com/manastyagigit/fastapi/blob/main/app/database.py): `app/database.py`
- [Application settings](https://github.com/manastyagigit/fastapi/blob/main/app/config.py): `app/config.py`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → FastAPI app: sends requests (evidence: `app/main.py`)
- FastAPI app → Login route: registers (evidence: `app/main.py`)
- FastAPI app → User routes: registers (evidence: `app/main.py`)
- FastAPI app → Post routes: registers (evidence: `app/main.py`)
- FastAPI app → Like route: registers (evidence: `app/main.py`)
- FastAPI app → Database sessions: creates tables (evidence: `app/main.py`)
- Login route → Database sessions: queries (evidence: `app/routers/auth.py`)
- Login route → User model: checks user (evidence: `app/routers/auth.py`)
- Login route → Password hashing: verifies password (evidence: `app/routers/auth.py`)
- Login route → Token security: creates token (evidence: `app/routers/auth.py`)
- Login route → Request responses: uses token schema (evidence: `app/routers/auth.py`)
- Token security → Database sessions: gets session (evidence: `app/OAuth2.py`)
- Token security → User model: loads user (evidence: `app/OAuth2.py`)
- Token security → Request responses: builds token data (evidence: `app/OAuth2.py`)
- User routes → Database sessions: queries and writes (evidence: `app/routers/user.py`)
- User routes → User model: creates and reads (evidence: `app/routers/user.py`)
- User routes → Password hashing: hashes password (evidence: `app/routers/user.py`)
- User routes → Request responses: validates and shapes (evidence: `app/routers/user.py`)
- Post routes → Database sessions: queries and writes (evidence: `app/routers/post.py`)
- Post routes → Post model: manages posts (evidence: `app/routers/post.py`)
- Post routes → Like model: counts likes (evidence: `app/routers/post.py`)
- Post routes → Token security: requires user (evidence: `app/routers/post.py`)
- Post routes → Request responses: validates and shapes (evidence: `app/routers/post.py`)
- Like route → Database sessions: queries and writes (evidence: `app/routers/like.py`)
- Like route → Post model: checks post (evidence: `app/routers/like.py`)
- Like route → Like model: adds or removes (evidence: `app/routers/like.py`)
- Like route → Token security: requires user (evidence: `app/routers/like.py`)
- Like route → Request responses: validates input (evidence: `app/routers/like.py`)
- Database sessions → Application settings: loads credentials (evidence: `app/database.py`)
- Token security → Application settings: loads token settings (evidence: `app/OAuth2.py`)
- Database sessions → PostgreSQL: connects (evidence: `app/database.py`)
