# veladhanush2004/user_login-api architecture

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

- Interactive diagram: https://gitdiagram.com/veladhanush2004/user_login-api
- Repository: https://github.com/veladhanush2004/user_login-api

## Overview

This is a small full-stack authentication app. Users register or log in through React pages; the browser hashes passwords before sending requests to FastAPI. The backend validates requests, applies registration/login/token rules, and uses repository queries against PostgreSQL. A successful login sets an HttpOnly cookie; the protected profile page requests the current user, and logout clears the cookie. The README documents the main capabilities and PostgreSQL integration; database-session and schema internals were not excerpted, so those links are limited to documented or indexed relationships.

Main entry points: [`src/routers/router.py`](https://github.com/veladhanush2004/user_login-api/blob/main/src/routers/router.py) (User endpoints), [`Frontend/src/App.jsx`](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/App.jsx) (Page routing), [`Frontend/src/api.js`](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/api.js) (API client), [`Frontend/src/pages/Register.jsx`](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Register.jsx) (Registration page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_routes["Page routing<br/>[App.jsx]"]
  node_register["Registration page<br/>[Register.jsx]"]
  node_login["Login page<br/>[Login.jsx]"]
  node_home["Profile page<br/>[Home.jsx]"]
  node_password_hash["Password hashing<br/>[hashPassword.js]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_backend["FastAPI backend"]
  node_app["API application<br/>[main.py]"]
  node_router["User endpoints<br/>[router.py]"]
  node_service["Auth service<br/>[service.py]"]
  node_models["Request models<br/>[models.py]"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_errors["Error handling<br/>[main.py]"]
  node_error_codes["Error codes<br/>[error_codes.py]"]
end

subgraph group_persistence["Persistence"]
  node_repository["User queries<br/>[repository.py]"]
  node_db_session["Database session<br/>[database.py]"]
  node_user_table[("User table<br/>[schema.py]")]
end

node_user(("User"))
node_postgres[("PostgreSQL")]

node_user -->|"opens pages"| node_routes
node_routes -->|"routes to"| node_register
node_routes -->|"routes to"| node_login
node_routes -->|"routes to"| node_home
node_register -->|"hashes password"| node_password_hash
node_login -->|"hashes password"| node_password_hash
node_register -->|"submits registration"| node_api
node_login -->|"submits login"| node_api
node_home -->|"requests profile"| node_api
node_api -->|"calls endpoints"| node_router
node_app -->|"registers routes"| node_router
node_app -->|"handles exceptions"| node_errors
node_errors -->|"formats errors"| node_error_codes
node_router -->|"invokes auth logic"| node_service
node_router -->|"validates requests"| node_models
node_router -->|"depends on session"| node_db_session
node_service -->|"queries users"| node_repository
node_service -->|"uses token config"| node_settings
node_repository -->|"queries table"| node_user_table
node_db_session -.->|"connects to"| node_postgres
node_user_table -.->|"stored in"| node_postgres

click node_routes "https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/App.jsx"
click node_register "https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Register.jsx"
click node_login "https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Login.jsx"
click node_home "https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Home.jsx"
click node_password_hash "https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/hashPassword.js"
click node_api "https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/api.js"
click node_app "https://github.com/veladhanush2004/user_login-api/blob/main/src/main.py"
click node_router "https://github.com/veladhanush2004/user_login-api/blob/main/src/routers/router.py"
click node_service "https://github.com/veladhanush2004/user_login-api/blob/main/src/services/service.py"
click node_models "https://github.com/veladhanush2004/user_login-api/blob/main/src/models/models.py"
click node_settings "https://github.com/veladhanush2004/user_login-api/blob/main/src/settings.py"
click node_errors "https://github.com/veladhanush2004/user_login-api/blob/main/src/main.py"
click node_error_codes "https://github.com/veladhanush2004/user_login-api/blob/main/src/utils/error_codes.py"
click node_repository "https://github.com/veladhanush2004/user_login-api/blob/main/src/repositories/repository.py"
click node_db_session "https://github.com/veladhanush2004/user_login-api/blob/main/src/repositories/database.py"
click node_user_table "https://github.com/veladhanush2004/user_login-api/blob/main/src/repositories/schemas/schema.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_routes,node_register,node_login,node_home,node_password_hash,node_api,node_user toneBlue
class node_app,node_router,node_service,node_models,node_settings,node_errors,node_error_codes,node_postgres toneAmber
class node_repository,node_db_session,node_user_table toneMint
```

## Components

### React frontend

- [Page routing](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Registration page](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Register.jsx): `Frontend/src/pages/Register.jsx`
- [Login page](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Login.jsx): `Frontend/src/pages/Login.jsx`
- [Profile page](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/pages/Home.jsx): `Frontend/src/pages/Home.jsx`
- [Password hashing](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/hashPassword.js): `Frontend/src/hashPassword.js`
- [API client](https://github.com/veladhanush2004/user_login-api/blob/main/Frontend/src/api.js): `Frontend/src/api.js`

### FastAPI backend

- [API application](https://github.com/veladhanush2004/user_login-api/blob/main/src/main.py): `src/main.py`
- [User endpoints](https://github.com/veladhanush2004/user_login-api/blob/main/src/routers/router.py): `src/routers/router.py`
- [Auth service](https://github.com/veladhanush2004/user_login-api/blob/main/src/services/service.py): `src/services/service.py`
- [Request models](https://github.com/veladhanush2004/user_login-api/blob/main/src/models/models.py): `src/models/models.py`
- [Runtime settings](https://github.com/veladhanush2004/user_login-api/blob/main/src/settings.py): `src/settings.py`
- [Error handling](https://github.com/veladhanush2004/user_login-api/blob/main/src/main.py): `src/main.py`
- [Error codes](https://github.com/veladhanush2004/user_login-api/blob/main/src/utils/error_codes.py): `src/utils/error_codes.py`

### Persistence

- [User queries](https://github.com/veladhanush2004/user_login-api/blob/main/src/repositories/repository.py): `src/repositories/repository.py`
- [Database session](https://github.com/veladhanush2004/user_login-api/blob/main/src/repositories/database.py): `src/repositories/database.py`
- [User table](https://github.com/veladhanush2004/user_login-api/blob/main/src/repositories/schemas/schema.py): `src/repositories/schemas/schema.py`

### Other components

- **User**
- **PostgreSQL**

## Connections

- User → Page routing: opens pages (evidence: `Frontend/src/App.jsx`)
- Page routing → Registration page: routes to (evidence: `Frontend/src/App.jsx`)
- Page routing → Login page: routes to (evidence: `Frontend/src/App.jsx`)
- Page routing → Profile page: routes to (evidence: `Frontend/src/App.jsx`)
- Registration page → Password hashing: hashes password (evidence: `Frontend/src/pages/Register.jsx`)
- Login page → Password hashing: hashes password (evidence: `Frontend/src/pages/Login.jsx`)
- Registration page → API client: submits registration (evidence: `Frontend/src/pages/Register.jsx`)
- Login page → API client: submits login (evidence: `Frontend/src/pages/Login.jsx`)
- Profile page → API client: requests profile (evidence: `Frontend/src/pages/Home.jsx`)
- API client → User endpoints: calls endpoints (evidence: `README.md`)
- API application → User endpoints: registers routes (evidence: `src/main.py`)
- API application → Error handling: handles exceptions (evidence: `src/main.py`)
- Error handling → Error codes: formats errors (evidence: `src/main.py`)
- User endpoints → Auth service: invokes auth logic (evidence: `src/routers/router.py`)
- User endpoints → Request models: validates requests (evidence: `src/routers/router.py`)
- User endpoints → Database session: depends on session (evidence: `src/routers/router.py`)
- Auth service → User queries: queries users (evidence: `src/services/service.py`)
- Auth service → Runtime settings: uses token config (evidence: `src/services/service.py`)
- User queries → User table: queries table (evidence: `src/repositories/repository.py`)
- Database session → PostgreSQL: connects to (evidence: `README.md`)
- User table → PostgreSQL: stored in (evidence: `README.md`)
