# somaiyassine/tasks-api architecture

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

- Interactive diagram: https://gitdiagram.com/somaiyassine/tasks-api
- Repository: https://github.com/somaiyassine/tasks-api

## Overview

tasks-api is an Express REST API for accounts, project ownership, and task tracking. Clients register or log in, then use a JWT to access protected project and task operations; role and ownership checks govern visibility and changes. Controllers implement CRUD, filtering, assignment, and project-deletion cleanup over MongoDB models, with shared query helpers for search and sorting. The README documents the full route capabilities; some controllers and database wiring were not excerpted, so only documented or indexed relationships are shown.

Main entry points: [`src/app.js`](https://github.com/somaiyassine/tasks-api/blob/main/src/app.js) (Express application), [`src/controllers/taskController.js`](https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/taskController.js) (Task operations), [`src/routes/authRoutes.js`](https://github.com/somaiyassine/tasks-api/blob/main/src/routes/authRoutes.js) (Auth routes), [`src/routes/taskRoutes.js`](https://github.com/somaiyassine/tasks-api/blob/main/src/routes/taskRoutes.js) (Task routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_application["Express application<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_project_routes["Project routes<br/>[projectRoutes.js]"]
  node_task_routes["Task routes<br/>[taskRoutes.js]"]
  node_error_handling["Error handling<br/>[errorHandler.js]"]
  node_server["Server startup<br/>[server.js]"]
end

subgraph group_identity["Identity and Access"]
  node_auth_controller["Account operations<br/>[authController.js]"]
  node_jwt_auth["JWT authentication<br/>[auth.js]"]
  node_role_access["Role access<br/>[roles.js]"]
  node_user_model[("User records<br/>[User.js]")]
end

subgraph group_projects["Project Management"]
  node_project_controller["Project operations"]
  node_project_model[("Project records<br/>[Project.js]")]
end

subgraph group_tasks["Task Management"]
  node_task_controller["Task operations<br/>[taskController.js]"]
  node_task_model[("Task records<br/>[Task.js]")]
end

subgraph group_data["Persistence and Query"]
  node_query_helpers["Search and sorting<br/>[query.js]"]
  node_mongo_connection["MongoDB connection<br/>[db.js]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_application
node_application -->|"mounts routes"| node_auth_routes
node_application -->|"mounts routes"| node_project_routes
node_application -->|"mounts routes"| node_task_routes
node_application -->|"forwards errors"| node_error_handling
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_project_routes -->|"dispatches requests"| node_project_controller
node_task_routes -->|"dispatches requests"| node_task_controller
node_auth_routes -->|"protects profile"| node_jwt_auth
node_project_routes -->|"protects routes"| node_jwt_auth
node_task_routes -->|"protects routes"| node_jwt_auth
node_auth_routes -->|"restricts users"| node_role_access
node_task_routes -->|"restricts assignment"| node_role_access
node_auth_controller -->|"reads and writes"| node_user_model
node_jwt_auth -->|"loads identity"| node_user_model
node_project_controller -->|"reads and writes"| node_project_model
node_project_controller -->|"deletes project tasks"| node_task_model
node_project_controller -->|"builds list queries"| node_query_helpers
node_task_controller -->|"reads and writes"| node_task_model
node_task_controller -->|"checks project access"| node_project_model
node_task_controller -->|"checks assignees"| node_user_model
node_task_controller -->|"builds list queries"| node_query_helpers
node_server -->|"starts app"| node_application
node_server -->|"connects database"| node_mongo_connection

click node_application "https://github.com/somaiyassine/tasks-api/blob/main/src/app.js"
click node_auth_routes "https://github.com/somaiyassine/tasks-api/blob/main/src/routes/authRoutes.js"
click node_project_routes "https://github.com/somaiyassine/tasks-api/blob/main/src/routes/projectRoutes.js"
click node_task_routes "https://github.com/somaiyassine/tasks-api/blob/main/src/routes/taskRoutes.js"
click node_error_handling "https://github.com/somaiyassine/tasks-api/blob/main/src/middlewares/errorHandler.js"
click node_auth_controller "https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/authController.js"
click node_jwt_auth "https://github.com/somaiyassine/tasks-api/blob/main/src/middlewares/auth.js"
click node_role_access "https://github.com/somaiyassine/tasks-api/blob/main/src/middlewares/roles.js"
click node_user_model "https://github.com/somaiyassine/tasks-api/blob/main/src/models/User.js"
click node_project_controller "https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/projectController.js"
click node_project_model "https://github.com/somaiyassine/tasks-api/blob/main/src/models/Project.js"
click node_task_controller "https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/taskController.js"
click node_task_model "https://github.com/somaiyassine/tasks-api/blob/main/src/models/Task.js"
click node_query_helpers "https://github.com/somaiyassine/tasks-api/blob/main/src/utils/query.js"
click node_mongo_connection "https://github.com/somaiyassine/tasks-api/blob/main/src/config/db.js"
click node_server "https://github.com/somaiyassine/tasks-api/blob/main/src/server.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_application,node_auth_routes,node_project_routes,node_task_routes,node_error_handling,node_server,node_client toneBlue
class node_auth_controller,node_jwt_auth,node_role_access,node_user_model toneAmber
class node_project_controller,node_project_model toneMint
class node_task_controller,node_task_model toneRose
class node_query_helpers,node_mongo_connection toneIndigo
```

## Components

### HTTP API

- [Express application](https://github.com/somaiyassine/tasks-api/blob/main/src/app.js): `src/app.js`
- [Auth routes](https://github.com/somaiyassine/tasks-api/blob/main/src/routes/authRoutes.js): `src/routes/authRoutes.js`
- [Project routes](https://github.com/somaiyassine/tasks-api/blob/main/src/routes/projectRoutes.js): `src/routes/projectRoutes.js`
- [Task routes](https://github.com/somaiyassine/tasks-api/blob/main/src/routes/taskRoutes.js): `src/routes/taskRoutes.js`
- [Error handling](https://github.com/somaiyassine/tasks-api/blob/main/src/middlewares/errorHandler.js): `src/middlewares/errorHandler.js`
- [Server startup](https://github.com/somaiyassine/tasks-api/blob/main/src/server.js): `src/server.js`

### Identity and Access

- [Account operations](https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/authController.js): `src/controllers/authController.js`
- [JWT authentication](https://github.com/somaiyassine/tasks-api/blob/main/src/middlewares/auth.js): `src/middlewares/auth.js`
- [Role access](https://github.com/somaiyassine/tasks-api/blob/main/src/middlewares/roles.js): `src/middlewares/roles.js`
- [User records](https://github.com/somaiyassine/tasks-api/blob/main/src/models/User.js): `src/models/User.js`

### Project Management

- [Project operations](https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/projectController.js): `src/controllers/projectController.js`
- [Project records](https://github.com/somaiyassine/tasks-api/blob/main/src/models/Project.js): `src/models/Project.js`

### Task Management

- [Task operations](https://github.com/somaiyassine/tasks-api/blob/main/src/controllers/taskController.js): `src/controllers/taskController.js`
- [Task records](https://github.com/somaiyassine/tasks-api/blob/main/src/models/Task.js): `src/models/Task.js`

### Persistence and Query

- [Search and sorting](https://github.com/somaiyassine/tasks-api/blob/main/src/utils/query.js): `src/utils/query.js`
- [MongoDB connection](https://github.com/somaiyassine/tasks-api/blob/main/src/config/db.js): `src/config/db.js`

### Other components

- **API client**

## Connections

- API client → Express application: sends requests (evidence: `src/app.js`)
- Express application → Auth routes: mounts routes (evidence: `src/app.js`)
- Express application → Project routes: mounts routes (evidence: `src/app.js`)
- Express application → Task routes: mounts routes (evidence: `src/app.js`)
- Express application → Error handling: forwards errors (evidence: `src/app.js`)
- Auth routes → Account operations: dispatches requests (evidence: `src/routes/authRoutes.js`)
- Project routes → Project operations: dispatches requests (evidence: `src/routes/projectRoutes.js`)
- Task routes → Task operations: dispatches requests (evidence: `src/routes/taskRoutes.js`)
- Auth routes → JWT authentication: protects profile (evidence: `src/routes/authRoutes.js`)
- Project routes → JWT authentication: protects routes (evidence: `src/routes/projectRoutes.js`)
- Task routes → JWT authentication: protects routes (evidence: `src/routes/taskRoutes.js`)
- Auth routes → Role access: restricts users (evidence: `src/routes/authRoutes.js`)
- Task routes → Role access: restricts assignment (evidence: `src/routes/taskRoutes.js`)
- Account operations → User records: reads and writes (evidence: `src/controllers/authController.js`)
- JWT authentication → User records: loads identity (evidence: `src/middlewares/auth.js`)
- Project operations → Project records: reads and writes (evidence: `src/controllers/projectController.js`)
- Project operations → Task records: deletes project tasks (evidence: `src/controllers/projectController.js`)
- Project operations → Search and sorting: builds list queries (evidence: `src/controllers/projectController.js`)
- Task operations → Task records: reads and writes (evidence: `src/controllers/taskController.js`)
- Task operations → Project records: checks project access (evidence: `src/controllers/taskController.js`)
- Task operations → User records: checks assignees (evidence: `src/controllers/taskController.js`)
- Task operations → Search and sorting: builds list queries (evidence: `src/controllers/taskController.js`)
- Server startup → Express application: starts app (evidence: `src/server.js`)
- Server startup → MongoDB connection: connects database (evidence: `src/server.js`)
