# sanjaymehar/fastapitask architecture

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

- Interactive diagram: https://gitdiagram.com/sanjaymehar/fastapitask
- Repository: https://github.com/sanjaymehar/fastapitask

## Overview

This is a FastAPI employee-management API. Users authenticate for JWTs, then role-guarded routes expose user, employee, and salary operations; salary submission records inputs and schedules a monthly-salary update. The graph includes the API wiring, controllers, authentication, ORM models, and PostgreSQL session layer. Other documented capabilities such as migrations are omitted from this runtime map. Relationships are based on the README or shown imports and calls; unsampled migration behavior is not inferred.

Main entry points: [`app/database.py`](https://github.com/sanjaymehar/fastapitask/blob/main/app/database.py) (Database sessions), [`app/utils/auth.py`](https://github.com/sanjaymehar/fastapitask/blob/main/app/utils/auth.py) (JWT and RBAC), [`app/api/api_v1/endpoints/user_router.py`](https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/user_router.py) (User routes), [`app/api/api_v1/endpoints/salary_router.py`](https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/salary_router.py) (Salary routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_app_entry["Application entry<br/>[main.py]"]
  node_api_v1["Route registration<br/>[api.py]"]
  node_user_routes["User routes<br/>[user_router.py]"]
  node_employee_routes["Employee routes<br/>[employee_router.py]"]
  node_salary_routes["Salary routes<br/>[salary_router.py]"]
end

subgraph group_domain["Domain operations"]
  node_user_ops["User operations<br/>[user_controller.py]"]
  node_employee_ops["Employee operations"]
  node_salary_ops["Salary operations"]
end

subgraph group_security["Identity and access"]
  node_auth["JWT and RBAC<br/>[auth.py]"]
end

subgraph group_persistence["Persistence and configuration"]
  node_settings["Settings<br/>[config.py]"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_user_model["User model<br/>[user_table.py]"]
  node_employee_model["Employee model<br/>[employee_table.py]"]
  node_salary_model["Salary model<br/>[salary_table.py]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]
node_background_tasks["FastAPI background tasks"]

node_client -->|"sends requests"| node_app_entry
node_app_entry -->|"initializes routes"| node_api_v1
node_api_v1 -->|"registers routes"| node_user_routes
node_api_v1 -->|"registers routes"| node_employee_routes
node_api_v1 -->|"registers routes"| node_salary_routes
node_user_routes -->|"calls operations"| node_user_ops
node_employee_routes -->|"calls operations"| node_employee_ops
node_salary_routes -->|"calls operations"| node_salary_ops
node_salary_routes -->|"schedules calculation"| node_background_tasks
node_background_tasks -->|"runs calculation"| node_salary_ops
node_salary_ops -->|"looks up employee"| node_employee_ops
node_user_routes -->|"authenticates login"| node_auth
node_user_routes -->|"requires admin"| node_auth
node_employee_routes -->|"checks access"| node_auth
node_salary_routes -->|"requires admin"| node_auth
node_user_ops -->|"hashes passwords"| node_auth
node_user_ops -->|"queries and writes"| node_user_model
node_employee_ops -->|"queries and writes"| node_employee_model
node_employee_ops -->|"checks user role"| node_user_model
node_salary_ops -->|"queries and writes"| node_salary_model
node_auth -->|"loads user"| node_user_model
node_auth -->|"reads JWT settings"| node_settings
node_auth -->|"gets database session"| node_db_session
node_user_routes -->|"gets database session"| node_db_session
node_employee_routes -->|"gets database session"| node_db_session
node_salary_routes -->|"gets database session"| node_db_session
node_user_ops -->|"uses session"| node_db_session
node_employee_ops -->|"uses session"| node_db_session
node_salary_ops -->|"uses session"| node_db_session
node_db_session -->|"loads connection settings"| node_settings
node_db_session -->|"connects to"| node_postgres
node_user_model -->|"uses ORM base"| node_db_session
node_employee_model -->|"uses ORM base"| node_db_session
node_salary_model -->|"uses ORM base"| node_db_session

click node_app_entry "https://github.com/sanjaymehar/fastapitask/blob/main/app/main.py"
click node_api_v1 "https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/api.py"
click node_user_routes "https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/user_router.py"
click node_employee_routes "https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/employee_router.py"
click node_salary_routes "https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/salary_router.py"
click node_user_ops "https://github.com/sanjaymehar/fastapitask/blob/main/app/controllers/user_controller.py"
click node_employee_ops "https://github.com/sanjaymehar/fastapitask/blob/main/app/controllers/employee_controller.py"
click node_salary_ops "https://github.com/sanjaymehar/fastapitask/blob/main/app/controllers/salary_controller.py"
click node_auth "https://github.com/sanjaymehar/fastapitask/blob/main/app/utils/auth.py"
click node_settings "https://github.com/sanjaymehar/fastapitask/blob/main/app/config.py"
click node_db_session "https://github.com/sanjaymehar/fastapitask/blob/main/app/database.py"
click node_user_model "https://github.com/sanjaymehar/fastapitask/blob/main/app/models/user_table.py"
click node_employee_model "https://github.com/sanjaymehar/fastapitask/blob/main/app/models/employee_table.py"
click node_salary_model "https://github.com/sanjaymehar/fastapitask/blob/main/app/models/salary_table.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_entry,node_api_v1,node_user_routes,node_employee_routes,node_salary_routes,node_client toneBlue
class node_user_ops,node_employee_ops,node_salary_ops,node_postgres toneAmber
class node_auth toneMint
class node_settings,node_db_session,node_user_model,node_employee_model,node_salary_model,node_background_tasks toneRose
```

## Components

### API surface

- [Application entry](https://github.com/sanjaymehar/fastapitask/blob/main/app/main.py): `app/main.py`
- [Route registration](https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/api.py): `app/api/api_v1/api.py`
- [User routes](https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/user_router.py): `app/api/api_v1/endpoints/user_router.py`
- [Employee routes](https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/employee_router.py): `app/api/api_v1/endpoints/employee_router.py`
- [Salary routes](https://github.com/sanjaymehar/fastapitask/blob/main/app/api/api_v1/endpoints/salary_router.py): `app/api/api_v1/endpoints/salary_router.py`

### Domain operations

- [User operations](https://github.com/sanjaymehar/fastapitask/blob/main/app/controllers/user_controller.py): `app/controllers/user_controller.py`
- [Employee operations](https://github.com/sanjaymehar/fastapitask/blob/main/app/controllers/employee_controller.py): `app/controllers/employee_controller.py`
- [Salary operations](https://github.com/sanjaymehar/fastapitask/blob/main/app/controllers/salary_controller.py): `app/controllers/salary_controller.py`

### Identity and access

- [JWT and RBAC](https://github.com/sanjaymehar/fastapitask/blob/main/app/utils/auth.py): `app/utils/auth.py`

### Persistence and configuration

- [Settings](https://github.com/sanjaymehar/fastapitask/blob/main/app/config.py): `app/config.py`
- [Database sessions](https://github.com/sanjaymehar/fastapitask/blob/main/app/database.py): `app/database.py`
- [User model](https://github.com/sanjaymehar/fastapitask/blob/main/app/models/user_table.py): `app/models/user_table.py`
- [Employee model](https://github.com/sanjaymehar/fastapitask/blob/main/app/models/employee_table.py): `app/models/employee_table.py`
- [Salary model](https://github.com/sanjaymehar/fastapitask/blob/main/app/models/salary_table.py): `app/models/salary_table.py`

### Other components

- **API client**
- **PostgreSQL**
- **FastAPI background tasks**

## Connections

- API client → Application entry: sends requests (evidence: `README.md`)
- Application entry → Route registration: initializes routes (evidence: `app/main.py`)
- Route registration → User routes: registers routes (evidence: `app/api/api_v1/api.py`)
- Route registration → Employee routes: registers routes (evidence: `app/api/api_v1/api.py`)
- Route registration → Salary routes: registers routes (evidence: `app/api/api_v1/api.py`)
- User routes → User operations: calls operations (evidence: `app/api/api_v1/endpoints/user_router.py`)
- Employee routes → Employee operations: calls operations (evidence: `app/api/api_v1/endpoints/employee_router.py`)
- Salary routes → Salary operations: calls operations (evidence: `app/api/api_v1/endpoints/salary_router.py`)
- Salary routes → FastAPI background tasks: schedules calculation (evidence: `app/api/api_v1/endpoints/salary_router.py`)
- FastAPI background tasks → Salary operations: runs calculation
- Salary operations → Employee operations: looks up employee (evidence: `app/controllers/salary_controller.py`)
- User routes → JWT and RBAC: authenticates login (evidence: `app/api/api_v1/endpoints/user_router.py`)
- User routes → JWT and RBAC: requires admin (evidence: `app/api/api_v1/endpoints/user_router.py`)
- Employee routes → JWT and RBAC: checks access (evidence: `app/api/api_v1/endpoints/employee_router.py`)
- Salary routes → JWT and RBAC: requires admin (evidence: `app/api/api_v1/endpoints/salary_router.py`)
- User operations → JWT and RBAC: hashes passwords (evidence: `app/controllers/user_controller.py`)
- User operations → User model: queries and writes (evidence: `app/controllers/user_controller.py`)
- Employee operations → Employee model: queries and writes (evidence: `app/controllers/employee_controller.py`)
- Employee operations → User model: checks user role (evidence: `app/controllers/employee_controller.py`)
- Salary operations → Salary model: queries and writes (evidence: `app/controllers/salary_controller.py`)
- JWT and RBAC → User model: loads user (evidence: `app/utils/auth.py`)
- JWT and RBAC → Settings: reads JWT settings (evidence: `app/utils/auth.py`)
- JWT and RBAC → Database sessions: gets database session (evidence: `app/utils/auth.py`)
- User routes → Database sessions: gets database session (evidence: `app/api/api_v1/endpoints/user_router.py`)
- Employee routes → Database sessions: gets database session (evidence: `app/api/api_v1/endpoints/employee_router.py`)
- Salary routes → Database sessions: gets database session (evidence: `app/api/api_v1/endpoints/salary_router.py`)
- User operations → Database sessions: uses session (evidence: `app/controllers/user_controller.py`)
- Employee operations → Database sessions: uses session (evidence: `app/controllers/employee_controller.py`)
- Salary operations → Database sessions: uses session (evidence: `app/controllers/salary_controller.py`)
- Database sessions → Settings: loads connection settings (evidence: `app/database.py`)
- Database sessions → PostgreSQL: connects to (evidence: `README.md`)
- User model → Database sessions: uses ORM base (evidence: `app/models/user_table.py`)
- Employee model → Database sessions: uses ORM base (evidence: `app/models/employee_table.py`)
- Salary model → Database sessions: uses ORM base (evidence: `app/models/salary_table.py`)
