# vandanabasavarajpatil/fastapi architecture

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

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

## Overview

This is a FastAPI backend for user accounts, authenticated post management, and post voting. A client sends requests through the application’s mounted routers; account creation stores a password hash, login verifies credentials and issues a JWT, and protected post and vote operations resolve that token to a user before accessing PostgreSQL. Post listings include vote counts, and post mutations enforce ownership. The source excerpts show the main routers and persistence/authentication layers; no README capabilities were available to verify beyond them.

Main entry points: [`app/database.py`](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/database.py) (Session provider), [`app/routers/auth.py`](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/auth.py) (Login endpoint), [`app/oauth2.py`](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/oauth2.py) (JWT authentication), [`app/models.py`](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/models.py) (ORM models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_main["Application entry<br/>[main.py]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Login endpoint<br/>[auth.py]"]
  node_users["User endpoints<br/>[user.py]"]
  node_oauth["JWT authentication<br/>[oauth2.py]"]
  node_passwords["Password hashing<br/>[utils.py]"]
end

subgraph group_content["Posts and voting"]
  node_posts["Post endpoints<br/>[post.py]"]
  node_votes["Vote endpoint<br/>[vote.py]"]
end

subgraph group_persistence["Persistence and contracts"]
  node_schemas["Request responses<br/>[schemas.py]"]
  node_models["ORM models<br/>[models.py]"]
  node_database["Session provider<br/>[database.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

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

node_client -->|"sends requests"| node_main
node_main -->|"mounts router"| node_posts
node_main -->|"mounts router"| node_users
node_main -->|"mounts router"| node_auth
node_main -->|"mounts router"| node_votes
node_auth -->|"requests session"| node_database
node_auth -->|"queries users"| node_models
node_auth -->|"verifies password"| node_passwords
node_auth -->|"creates token"| node_oauth
node_users -->|"requests session"| node_database
node_users -->|"stores user"| node_models
node_users -->|"hashes password"| node_passwords
node_posts -->|"resolves user"| node_oauth
node_votes -->|"resolves user"| node_oauth
node_oauth -->|"requests session"| node_database
node_oauth -->|"loads user"| node_models
node_auth -->|"uses token schemas"| node_schemas
node_users -->|"validates and formats"| node_schemas
node_posts -->|"validates and formats"| node_schemas
node_votes -->|"validates vote"| node_schemas
node_posts -->|"requests session"| node_database
node_posts -->|"queries and mutates"| node_models
node_votes -->|"requests session"| node_database
node_votes -->|"queries and mutates"| node_models
node_database -->|"provides base"| node_models
node_database -->|"reads settings"| node_config
node_oauth -->|"reads settings"| node_config
node_database -->|"connects and persists"| node_postgres

click node_main "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/main.py"
click node_auth "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/auth.py"
click node_users "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/user.py"
click node_oauth "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/oauth2.py"
click node_passwords "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/utils.py"
click node_posts "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/post.py"
click node_votes "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/vote.py"
click node_schemas "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/schemas.py"
click node_models "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/models.py"
click node_database "https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/database.py"
click node_config "https://github.com/vandanabasavarajpatil/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_main,node_client toneBlue
class node_auth,node_users,node_oauth,node_passwords,node_postgres toneAmber
class node_posts,node_votes toneMint
class node_schemas,node_models,node_database,node_config toneRose
```

## Components

### API routing

- [Application entry](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/main.py): `app/main.py`

### Identity and access

- [Login endpoint](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [User endpoints](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/user.py): `app/routers/user.py`
- [JWT authentication](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/oauth2.py): `app/oauth2.py`
- [Password hashing](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/utils.py): `app/utils.py`

### Posts and voting

- [Post endpoints](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/post.py): `app/routers/post.py`
- [Vote endpoint](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/routers/vote.py): `app/routers/vote.py`

### Persistence and contracts

- [Request responses](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/schemas.py): `app/schemas.py`
- [ORM models](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/models.py): `app/models.py`
- [Session provider](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/database.py): `app/database.py`
- [Runtime settings](https://github.com/vandanabasavarajpatil/fastapi/blob/main/app/config.py): `app/config.py`

### Other components

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

## Connections

- API client → Application entry: sends requests
- Application entry → Post endpoints: mounts router
- Application entry → User endpoints: mounts router
- Application entry → Login endpoint: mounts router
- Application entry → Vote endpoint: mounts router
- Login endpoint → Session provider: requests session
- Login endpoint → ORM models: queries users
- Login endpoint → Password hashing: verifies password
- Login endpoint → JWT authentication: creates token
- User endpoints → Session provider: requests session
- User endpoints → ORM models: stores user
- User endpoints → Password hashing: hashes password
- Post endpoints → JWT authentication: resolves user
- Vote endpoint → JWT authentication: resolves user
- JWT authentication → Session provider: requests session
- JWT authentication → ORM models: loads user
- Login endpoint → Request responses: uses token schemas
- User endpoints → Request responses: validates and formats
- Post endpoints → Request responses: validates and formats
- Vote endpoint → Request responses: validates vote
- Post endpoints → Session provider: requests session
- Post endpoints → ORM models: queries and mutates
- Vote endpoint → Session provider: requests session
- Vote endpoint → ORM models: queries and mutates
- Session provider → ORM models: provides base
- Session provider → Runtime settings: reads settings
- JWT authentication → Runtime settings: reads settings
- Session provider → PostgreSQL: connects and persists
