# yassiinneee/protask-manager architecture

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

- Interactive diagram: https://gitdiagram.com/yassiinneee/protask-manager
- Repository: https://github.com/yassiinneee/protask-manager

## Overview

#### Purpose and Entry Points
ProTask Manager is a full-stack task-management platform with authenticated task CRUD, administration, email verification, caching, and Gemini-assisted task drafting. The application server is rooted at `server.js`; React boots from `client/src/main.jsx` into `client/src/App.jsx`. REST endpoints are grouped below `/api`.

#### Client Application
The React/Vite client owns session-facing workflows: login/registration/verification, dashboard task interactions, settings, and admin UI. `App.jsx` coordinates major screen state; components render feature areas, while service modules isolate HTTP/auth/AI calls.
- `client/src/App.jsx`
- `client/src/components/TaskList.jsx`
- `client/src/services/api.js`

#### API Composition and Request Boundary
Express in `server.js` is the integration boundary for browser requests, API route mounting, health reporting, and development/production frontend serving. Routes dispatch to feature controllers, keeping HTTP definitions separate from business operations.
- `server.js`
- `server/routes/taskRoutes.js`
- `server/controllers/taskController.js`

#### Identity, Verification, and Administration
User operations include JWT-based login/logout, profile/password changes, OTP/email verification, and role-protected administrative user management. Authentication and authorization occur before protected controller operations; email delivery is delegated to a utility/provider boundary.
- `server/routes/userRoutes.js`
- `server/middleware/authMiddleware.js`
- `server/utils/sendEmail.js`

#### Task Domain and Persistence
Tasks and users are MongoDB/Mongoose document models. Task endpoints support owned/assigned task lifecycle operations plus filtering, pagination, and statistics; controllers enforce the application-facing ownership/authorization rules before persistence.
- `server/models/Task.js`
- `server/models/User.js`
- `server/config/db.js`

#### AI Assistance and Resilience
The AI assistant accepts task-generation/refinement requests from the client and routes them through a dedicated controller. It uses Google Gemini when configured, with local structured-template fallback when the external AI service/key is unavailable, preserving task-authoring functionality.
- `client/src/components/AiTaskAssistant.jsx`
- `server/routes/aiRoutes.js`
- `server/controllers/aiController.js`

#### Security and Cache Layers
Cross-cutting middleware supplies JWT protection, request validation, XSS sanitization, error handling, and the server-level security/rate-limit stack. Caching uses Redis when reachable and an in-memory fallback otherwise; cache operational endpoints expose stats/flush/test capabilities.
- `server/middleware/validators.js`
- `server/middleware/xssMiddleware.js`
- `server/config/redis.js`

#### Runtime and Deployment
Node.js 20+ runs Express; React 19/Vite builds the client. MongoDB is the primary store, Redis is optional cache infrastructure, Gemini and SMTP are external integrations. Development can serve Vite through Express; production builds a server bundle. Container deployment places Nginx ahead of the Node app, with Compose coordinating app, MongoDB, and Redis.
- `docker-compose.yml`
- `nginx.conf`
- `vite.config.js`

Main entry points: [`server.js`](https://github.com/yassiinneee/protask-manager/blob/main/server.js) (Express server), [`client/src/App.jsx`](https://github.com/yassiinneee/protask-manager/blob/main/client/src/App.jsx) (App shell), [`server/routes/taskRoutes.js`](https://github.com/yassiinneee/protask-manager/blob/main/server/routes/taskRoutes.js) (Task routes), [`server/routes/userRoutes.js`](https://github.com/yassiinneee/protask-manager/blob/main/server/routes/userRoutes.js) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_vite["Vite entry<br/>client bootstrap<br/>[main.jsx]"]
  node_app["App shell<br/>React state coordinator<br/>[App.jsx]"]
  node_task_list["Task UI<br/>React component<br/>[TaskList.jsx]"]
  node_ai_ui["AI task assistant<br/>React component"]
  node_client_api["Client API service<br/>HTTP/auth client<br/>[api.js]"]
end

subgraph group_api["Node API"]
  node_server["Express server<br/>HTTP integration boundary<br/>[server.js]"]
  node_task_routes["Task routes<br/>Express routes<br/>[taskRoutes.js]"]
  node_user_routes["User routes<br/>Express routes<br/>[userRoutes.js]"]
  node_ai_routes["AI routes<br/>Express routes<br/>[aiRoutes.js]"]
  node_auth["Auth middleware<br/>JWT and role guard<br/>[authMiddleware.js]"]
  node_validation_security["Validation &amp; XSS<br/>request middleware<br/>[validators.js]"]
  node_task_controller["Task controller<br/>task domain operations<br/>[taskController.js]"]
  node_ai_controller["AI controller<br/>task drafting service<br/>[aiController.js]"]
  node_email["Email delivery<br/>SMTP utility boundary<br/>[sendEmail.js]"]
end

subgraph group_data["Data &amp; Integrations"]
  node_task_model["Task model<br/>Mongoose model<br/>[Task.js]"]
  node_user_model["User model<br/>Mongoose model<br/>[User.js]"]
  node_mongodb[("MongoDB<br/>primary datastore<br/>[db.js]")]
  node_cache[("Redis cache<br/>optional cache layer<br/>[redis.js]")]
  node_gemini{{"Google Gemini<br/>external AI service"}}
end

subgraph group_deploy["Deployment"]
  node_nginx["Nginx<br/>reverse proxy<br/>[nginx.conf]"]
  node_compose["Compose deployment<br/>container orchestration<br/>[docker-compose.yml]"]
  node_vite_config["Vite build config<br/>client build configuration<br/>[vite.config.js]"]
end

node_vite -->|"boots"| node_app
node_app -->|"renders"| node_task_list
node_app -->|"renders"| node_ai_ui
node_task_list -->|"task requests"| node_client_api
node_ai_ui -->|"draft requests"| node_client_api
node_client_api -->|"REST /api"| node_server
node_server -->|"applies"| node_validation_security
node_server -->|"mounts"| node_task_routes
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_ai_routes
node_task_routes -->|"protects"| node_auth
node_user_routes -->|"protects admin/profile"| node_auth
node_task_routes -->|"dispatches"| node_task_controller
node_ai_routes -->|"dispatches"| node_ai_controller
node_user_routes -->|"verification mail"| node_email
node_task_controller -->|"reads/writes"| node_task_model
node_auth -->|"resolves users"| node_user_model
node_task_model -->|"persists in"| node_mongodb
node_user_model -->|"persists in"| node_mongodb
node_server -->|"uses"| node_cache
node_ai_controller -->|"generates when configured"| node_gemini
node_nginx -->|"proxies to"| node_server
node_compose -->|"deploys"| node_nginx
node_vite_config -->|"configures build"| node_vite

click node_vite "https://github.com/yassiinneee/protask-manager/blob/main/client/src/main.jsx"
click node_app "https://github.com/yassiinneee/protask-manager/blob/main/client/src/App.jsx"
click node_task_list "https://github.com/yassiinneee/protask-manager/blob/main/client/src/components/TaskList.jsx"
click node_ai_ui "https://github.com/yassiinneee/protask-manager/blob/main/client/src/components/AiTaskAssistant.jsx"
click node_client_api "https://github.com/yassiinneee/protask-manager/blob/main/client/src/services/api.js"
click node_server "https://github.com/yassiinneee/protask-manager/blob/main/server.js"
click node_task_routes "https://github.com/yassiinneee/protask-manager/blob/main/server/routes/taskRoutes.js"
click node_user_routes "https://github.com/yassiinneee/protask-manager/blob/main/server/routes/userRoutes.js"
click node_ai_routes "https://github.com/yassiinneee/protask-manager/blob/main/server/routes/aiRoutes.js"
click node_auth "https://github.com/yassiinneee/protask-manager/blob/main/server/middleware/authMiddleware.js"
click node_validation_security "https://github.com/yassiinneee/protask-manager/blob/main/server/middleware/validators.js"
click node_task_controller "https://github.com/yassiinneee/protask-manager/blob/main/server/controllers/taskController.js"
click node_ai_controller "https://github.com/yassiinneee/protask-manager/blob/main/server/controllers/aiController.js"
click node_email "https://github.com/yassiinneee/protask-manager/blob/main/server/utils/sendEmail.js"
click node_task_model "https://github.com/yassiinneee/protask-manager/blob/main/server/models/Task.js"
click node_user_model "https://github.com/yassiinneee/protask-manager/blob/main/server/models/User.js"
click node_mongodb "https://github.com/yassiinneee/protask-manager/blob/main/server/config/db.js"
click node_cache "https://github.com/yassiinneee/protask-manager/blob/main/server/config/redis.js"
click node_nginx "https://github.com/yassiinneee/protask-manager/blob/main/nginx.conf"
click node_compose "https://github.com/yassiinneee/protask-manager/blob/main/docker-compose.yml"
click node_vite_config "https://github.com/yassiinneee/protask-manager/blob/main/vite.config.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_vite,node_app,node_task_list,node_ai_ui,node_client_api toneBlue
class node_server,node_task_routes,node_user_routes,node_ai_routes,node_auth,node_validation_security,node_task_controller,node_ai_controller,node_email toneAmber
class node_task_model,node_user_model,node_mongodb,node_cache,node_gemini toneMint
class node_nginx,node_compose,node_vite_config toneRose
```

## Components

### React Client

- [Vite entry](https://github.com/yassiinneee/protask-manager/blob/main/client/src/main.jsx): client bootstrap · `client/src/main.jsx`
- [App shell](https://github.com/yassiinneee/protask-manager/blob/main/client/src/App.jsx): React state coordinator · `client/src/App.jsx`
- [Task UI](https://github.com/yassiinneee/protask-manager/blob/main/client/src/components/TaskList.jsx): React component · `client/src/components/TaskList.jsx`
- [AI task assistant](https://github.com/yassiinneee/protask-manager/blob/main/client/src/components/AiTaskAssistant.jsx): React component · `client/src/components/AiTaskAssistant.jsx`
- [Client API service](https://github.com/yassiinneee/protask-manager/blob/main/client/src/services/api.js): HTTP/auth client · `client/src/services/api.js`

### Node API

- [Express server](https://github.com/yassiinneee/protask-manager/blob/main/server.js): HTTP integration boundary · Mounts APIs, health checks, and frontend serving. · `server.js`
- [Task routes](https://github.com/yassiinneee/protask-manager/blob/main/server/routes/taskRoutes.js): Express routes · `server/routes/taskRoutes.js`
- [User routes](https://github.com/yassiinneee/protask-manager/blob/main/server/routes/userRoutes.js): Express routes · `server/routes/userRoutes.js`
- [AI routes](https://github.com/yassiinneee/protask-manager/blob/main/server/routes/aiRoutes.js): Express routes · `server/routes/aiRoutes.js`
- [Auth middleware](https://github.com/yassiinneee/protask-manager/blob/main/server/middleware/authMiddleware.js): JWT and role guard · `server/middleware/authMiddleware.js`
- [Validation & XSS](https://github.com/yassiinneee/protask-manager/blob/main/server/middleware/validators.js): request middleware · `server/middleware/validators.js`
- [Task controller](https://github.com/yassiinneee/protask-manager/blob/main/server/controllers/taskController.js): task domain operations · Enforces ownership and task lifecycle rules. · `server/controllers/taskController.js`
- [AI controller](https://github.com/yassiinneee/protask-manager/blob/main/server/controllers/aiController.js): task drafting service · Uses structured local fallback when Gemini is unavailable. · `server/controllers/aiController.js`
- [Email delivery](https://github.com/yassiinneee/protask-manager/blob/main/server/utils/sendEmail.js): SMTP utility boundary · `server/utils/sendEmail.js`

### Data & Integrations

- [Task model](https://github.com/yassiinneee/protask-manager/blob/main/server/models/Task.js): Mongoose model · `server/models/Task.js`
- [User model](https://github.com/yassiinneee/protask-manager/blob/main/server/models/User.js): Mongoose model · `server/models/User.js`
- [MongoDB](https://github.com/yassiinneee/protask-manager/blob/main/server/config/db.js): primary datastore · `server/config/db.js`
- [Redis cache](https://github.com/yassiinneee/protask-manager/blob/main/server/config/redis.js): optional cache layer · Falls back to in-memory cache when Redis is unreachable. · `server/config/redis.js`
- **Google Gemini**: external AI service

### Deployment

- [Nginx](https://github.com/yassiinneee/protask-manager/blob/main/nginx.conf): reverse proxy · `nginx.conf`
- [Compose deployment](https://github.com/yassiinneee/protask-manager/blob/main/docker-compose.yml): container orchestration · Coordinates app, MongoDB, and Redis containers. · `docker-compose.yml`
- [Vite build config](https://github.com/yassiinneee/protask-manager/blob/main/vite.config.js): client build configuration · `vite.config.js`

## Connections

- Vite entry → App shell: boots
- App shell → Task UI: renders
- App shell → AI task assistant: renders
- Task UI → Client API service: task requests
- AI task assistant → Client API service: draft requests
- Client API service → Express server: REST /api
- Express server → Validation & XSS: applies
- Express server → Task routes: mounts
- Express server → User routes: mounts
- Express server → AI routes: mounts
- Task routes → Auth middleware: protects
- User routes → Auth middleware: protects admin/profile
- Task routes → Task controller: dispatches
- AI routes → AI controller: dispatches
- User routes → Email delivery: verification mail
- Task controller → Task model: reads/writes
- Auth middleware → User model: resolves users
- Task model → MongoDB: persists in
- User model → MongoDB: persists in
- Express server → Redis cache: uses
- AI controller → Google Gemini: generates when configured
- Nginx → Express server: proxies to
- Compose deployment → Nginx: deploys
- Vite build config → Vite entry: configures build
