# mohamed8483/task_manager_api architecture

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

- Interactive diagram: https://gitdiagram.com/mohamed8483/task_manager_api
- Repository: https://github.com/mohamed8483/task_manager_api

## Overview

This is an Express REST API for product management and user registration/login, backed by PostgreSQL. The main workflow is HTTP request → mounted route → controller validation/response mapping → service logic → repository query → database result. Product services also check category existence; authentication services validate credentials, hash registration passwords, and compare login passwords. The README documents search, pagination, CRUD, and username-or-email login. Edges follow shown calls or documented wiring; the database schema and API behavior are documented, but no unsampled implementation details are inferred.

Main entry points: [`server.js`](https://github.com/mohamed8483/task_manager_api/blob/main/server.js) (Server startup), [`services/service.auth.js`](https://github.com/mohamed8483/task_manager_api/blob/main/services/service.auth.js) (Auth service), [`controllers/controller.auth.js`](https://github.com/mohamed8483/task_manager_api/blob/main/controllers/controller.auth.js) (Auth controller), [`config/db.js`](https://github.com/mohamed8483/task_manager_api/blob/main/config/db.js) (PostgreSQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_server["Server startup<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
  node_http_status["HTTP status codes<br/>[httpStatus.js]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes<br/>[routes.auth.js]"]
  node_auth_controller["Auth controller<br/>[controller.auth.js]"]
  node_auth_service["Auth service<br/>[service.auth.js]"]
  node_auth_repository["Auth repository<br/>[repository.auth.js]"]
end

subgraph group_products["Product management"]
  node_product_routes["Product routes<br/>[routes.products.js]"]
  node_product_controller["Product controller"]
  node_product_service["Product service"]
  node_product_repository["Product repository"]
end

subgraph group_persistence["Persistence"]
  node_db_pool["PostgreSQL pool<br/>[db.js]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]
node_bcrypt["bcrypt"]
node_validator["Email validator"]

node_client -->|"sends requests"| node_server
node_server -->|"loads app"| node_app
node_server -->|"mounts routes"| node_product_routes
node_server -->|"mounts routes"| node_auth_routes
node_app -->|"parses JSON"| node_server
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_controller -->|"maps status"| node_http_status
node_auth_service -->|"calls"| node_auth_repository
node_auth_service -->|"hashes and compares"| node_bcrypt
node_auth_service -->|"validates email"| node_validator
node_product_routes -->|"dispatches"| node_product_controller
node_product_controller -->|"calls"| node_product_service
node_product_service -->|"calls"| node_product_repository
node_auth_repository -->|"queries"| node_db_pool
node_product_repository -->|"queries"| node_db_pool
node_db_pool -->|"connects to"| node_postgres

click node_server "https://github.com/mohamed8483/task_manager_api/blob/main/server.js"
click node_app "https://github.com/mohamed8483/task_manager_api/blob/main/src/app.js"
click node_http_status "https://github.com/mohamed8483/task_manager_api/blob/main/constants/httpStatus.js"
click node_auth_routes "https://github.com/mohamed8483/task_manager_api/blob/main/routes/routes.auth.js"
click node_auth_controller "https://github.com/mohamed8483/task_manager_api/blob/main/controllers/controller.auth.js"
click node_auth_service "https://github.com/mohamed8483/task_manager_api/blob/main/services/service.auth.js"
click node_auth_repository "https://github.com/mohamed8483/task_manager_api/blob/main/repositories/repository.auth.js"
click node_product_routes "https://github.com/mohamed8483/task_manager_api/blob/main/routes/routes.products.js"
click node_product_controller "https://github.com/mohamed8483/task_manager_api/blob/main/controllers/controller.products.js"
click node_product_service "https://github.com/mohamed8483/task_manager_api/blob/main/services/service.products.js"
click node_product_repository "https://github.com/mohamed8483/task_manager_api/blob/main/repositories/repository.product.js"
click node_db_pool "https://github.com/mohamed8483/task_manager_api/blob/main/config/db.js"

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_server,node_app,node_http_status,node_client toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_auth_repository,node_postgres toneAmber
class node_product_routes,node_product_controller,node_product_service,node_product_repository toneMint
class node_db_pool toneRose
class node_bcrypt,node_validator toneIndigo
```

## Components

### HTTP runtime

- [Server startup](https://github.com/mohamed8483/task_manager_api/blob/main/server.js): `server.js`
- [Express app](https://github.com/mohamed8483/task_manager_api/blob/main/src/app.js): `src/app.js`
- [HTTP status codes](https://github.com/mohamed8483/task_manager_api/blob/main/constants/httpStatus.js): `constants/httpStatus.js`

### Authentication

- [Auth routes](https://github.com/mohamed8483/task_manager_api/blob/main/routes/routes.auth.js): `routes/routes.auth.js`
- [Auth controller](https://github.com/mohamed8483/task_manager_api/blob/main/controllers/controller.auth.js): `controllers/controller.auth.js`
- [Auth service](https://github.com/mohamed8483/task_manager_api/blob/main/services/service.auth.js): `services/service.auth.js`
- [Auth repository](https://github.com/mohamed8483/task_manager_api/blob/main/repositories/repository.auth.js): `repositories/repository.auth.js`

### Product management

- [Product routes](https://github.com/mohamed8483/task_manager_api/blob/main/routes/routes.products.js): `routes/routes.products.js`
- [Product controller](https://github.com/mohamed8483/task_manager_api/blob/main/controllers/controller.products.js): `controllers/controller.products.js`
- [Product service](https://github.com/mohamed8483/task_manager_api/blob/main/services/service.products.js): `services/service.products.js`
- [Product repository](https://github.com/mohamed8483/task_manager_api/blob/main/repositories/repository.product.js): `repositories/repository.product.js`

### Persistence

- [PostgreSQL pool](https://github.com/mohamed8483/task_manager_api/blob/main/config/db.js): `config/db.js`

### Other components

- **API client**
- **PostgreSQL**
- **bcrypt**
- **Email validator**

## Connections

- API client → Server startup: sends requests (evidence: `README.md`)
- Server startup → Express app: loads app (evidence: `server.js`)
- Server startup → Product routes: mounts routes (evidence: `server.js`)
- Server startup → Auth routes: mounts routes (evidence: `server.js`)
- Express app → Server startup: parses JSON (evidence: `src/app.js`)
- Auth routes → Auth controller: dispatches (evidence: `routes/routes.auth.js`)
- Auth controller → Auth service: calls (evidence: `controllers/controller.auth.js`)
- Auth controller → HTTP status codes: maps status (evidence: `controllers/controller.auth.js`)
- Auth service → Auth repository: calls (evidence: `services/service.auth.js`)
- Auth service → bcrypt: hashes and compares (evidence: `services/service.auth.js`)
- Auth service → Email validator: validates email (evidence: `services/service.auth.js`)
- Product routes → Product controller: dispatches (evidence: `routes/routes.products.js`)
- Product controller → Product service: calls (evidence: `controllers/controller.products.js`)
- Product service → Product repository: calls (evidence: `services/service.products.js`)
- Auth repository → PostgreSQL pool: queries (evidence: `repositories/repository.auth.js`)
- Product repository → PostgreSQL pool: queries (evidence: `repositories/repository.product.js`)
- PostgreSQL pool → PostgreSQL: connects to (evidence: `README.md`)
