# saurabh21y/hyscaler architecture

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

- Interactive diagram: https://gitdiagram.com/saurabh21y/hyscaler
- Repository: https://github.com/saurabh21y/hyscaler

## Overview

#### Purpose and Entry Points
TaskFlow is a React/FastAPI project-management system for multi-user projects, task boards, comments, activity history, JWT authentication, and project-scoped real-time updates. Backend startup is `backend/app/main.py`; the SPA starts at `frontend/src/main.jsx` and composes routes/UI in `frontend/src/App.jsx`.

#### Frontend Application Shell
The Vite React client provides authenticated project, board, task, dashboard, assigned-task, team, and settings views. Shared authentication state keeps the short-lived access token in memory; UI components are presentation and interaction layers over server-owned data.
- `frontend/src/context/AuthContext.jsx`
- `frontend/src/pages/ProjectPage.jsx`
- `frontend/src/pages/Dashboard.jsx`

#### HTTP Client and Server-State Boundary
Axios centralizes REST communication and handles 401 refresh/retry behavior, while TanStack Query manages fetched server state and cache invalidation. The backend remains authoritative: filters, search, sorting, and pagination are performed by API endpoints rather than by loading all task records into the browser.
- `frontend/src/api/axios.js`
- `backend/app/routers/tasks.py`
- `backend/app/routers/dashboard.py`

#### FastAPI API and Domain Boundaries
FastAPI routers divide the API by domain: auth, projects/membership, tasks, comments, activity, cross-project assignment, dashboard, and WebSockets. Pydantic schemas define request/response contracts; service modules centralize project and activity operations where appropriate.
- `backend/app/main.py`
- `backend/app/routers/projects.py`
- `backend/app/routers/tasks.py`
- `backend/app/services/project_service.py`
- `backend/app/services/activity_service.py`

#### Identity, Authentication, and Authorization
The backend issues short-lived JWT access tokens and uses an httpOnly refresh cookie. Dependency/security layers validate identity and enforce protected access. Project membership and owner roles gate project actions; task status transitions add the specific “only assignee or owner may mark done” rule.
- `backend/app/routers/auth.py`
- `backend/app/core/security.py`
- `backend/app/core/dependencies.py`
- `backend/app/routers/tasks.py`

#### Persistence and Transactional Domain Effects
MongoDB is the persistence runtime, accessed through PyMongo initialization/session modules. Project, membership, task, comment, and activity records are stored and queried by routers/services. Mutations that generate audit events are intended to persist activity with the triggering operation; task changes also maintain completion timestamps and membership-dependent assignment validity.
- `backend/app/db/mongo.py`
- `backend/app/db/session.py`
- `backend/app/services/activity_service.py`
- `backend/app/routers/comments.py`

#### Real-Time Collaboration
A WebSocket endpoint authenticates a JWT passed in the connection URL, verifies project membership, and registers sockets in an in-memory project room manager. Mutating REST operations publish small project-scoped events; the client socket hook invalidates relevant query caches and refetches canonical REST data. The manager is single-process only; multi-worker deployment needs a shared backplane such as Redis pub/sub.
- `backend/app/routers/ws.py`
- `backend/app/websockets/connection_manager.py`
- `frontend/src/ws/useProjectSocket.js`

#### Runtime and Infrastructure
Backend runtime is Python 3.11+ with Uvicorn/FastAPI; frontend runtime is Node 18+ with Vite. Required external infrastructure is MongoDB 6+ or Atlas. Environment configuration supplies Mongo connection details, JWT/cookie policy, CORS origin, and frontend API/WS base URLs.
- `backend/app/core/config.py`
- `backend/.env.example`
- `frontend/.env.example`
- `frontend/vite.config.js`

Main entry points: [`backend/app/main.py`](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/main.py) (API application), [`backend/app/routers/tasks.py`](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/tasks.py) (Tasks and board queries), [`backend/app/db/mongo.py`](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/db/mongo.py) (Mongo persistence), [`frontend/src/ws/useProjectSocket.js`](https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/ws/useProjectSocket.js) (Project socket hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_spa_entry["SPA entry and routes<br/>React/Vite<br/>[main.jsx]"]
  node_auth_context["Auth state<br/>React context<br/>[AuthContext.jsx]"]
  node_http_client["HTTP client<br/>Axios<br/>[axios.js]"]
  node_query_cache["Server-state cache<br/>TanStack Query"]
  node_project_views["Project and dashboard views<br/>React pages<br/>[ProjectPage.jsx]"]
  node_socket_hook["Project socket hook<br/>React hook"]
end

subgraph group_backend["FastAPI backend"]
  node_api_app["API application<br/>FastAPI<br/>[main.py]"]
  node_auth_api["Authentication API<br/>FastAPI router<br/>[auth.py]"]
  node_access_control["Identity and access control<br/>security dependencies<br/>[dependencies.py]"]
  node_project_domain["Projects and membership<br/>router + service<br/>[projects.py]"]
  node_task_domain["Tasks and board queries<br/>FastAPI router<br/>[tasks.py]"]
  node_dashboard_api["Dashboard and assignments<br/>FastAPI router<br/>[dashboard.py]"]
  node_comments_api["Comments<br/>FastAPI router<br/>[comments.py]"]
  node_activity_service["Activity audit service<br/>domain service"]
  node_mongo_access[("Mongo persistence<br/>PyMongo<br/>[mongo.py]")]
  node_environment["Runtime configuration<br/>environment config<br/>[config.py]"]
end

subgraph group_realtime["Real-time updates"]
  node_ws_endpoint["WebSocket endpoint<br/>FastAPI router<br/>[ws.py]"]
  node_room_manager["Project room manager<br/>in-memory connection manager"]
end

node_spa_entry -->|"uses"| node_auth_context
node_spa_entry -->|"renders"| node_project_views
node_project_views -->|"reads server state"| node_query_cache
node_query_cache -->|"fetches via"| node_http_client
node_auth_context -->|"supplies access token"| node_http_client
node_http_client -->|"REST"| node_api_app
node_api_app -->|"routes"| node_auth_api
node_api_app -->|"routes"| node_project_domain
node_api_app -->|"routes"| node_task_domain
node_api_app -->|"routes"| node_dashboard_api
node_api_app -->|"routes"| node_comments_api
node_auth_api -->|"issues/validates tokens"| node_access_control
node_project_domain -->|"enforces membership"| node_access_control
node_task_domain -->|"enforces task permissions"| node_access_control
node_project_domain -->|"persists"| node_mongo_access
node_task_domain -->|"queries and mutates"| node_mongo_access
node_comments_api -->|"persists"| node_mongo_access
node_task_domain -->|"records mutations"| node_activity_service
node_comments_api -->|"records activity"| node_activity_service
node_activity_service -->|"writes audit events"| node_mongo_access
node_socket_hook -->|"project WebSocket"| node_ws_endpoint
node_ws_endpoint -->|"registers connection"| node_room_manager
node_task_domain -->|"publishes project events"| node_room_manager
node_room_manager -->|"event notification"| node_socket_hook
node_socket_hook -->|"invalidates and refetches"| node_query_cache
node_environment -.->|"configures"| node_api_app

click node_spa_entry "https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/main.jsx"
click node_auth_context "https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/context/AuthContext.jsx"
click node_http_client "https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/api/axios.js"
click node_project_views "https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/pages/ProjectPage.jsx"
click node_socket_hook "https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/ws/useProjectSocket.js"
click node_api_app "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/auth.py"
click node_access_control "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/core/dependencies.py"
click node_project_domain "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/projects.py"
click node_task_domain "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/tasks.py"
click node_dashboard_api "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/dashboard.py"
click node_comments_api "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/comments.py"
click node_activity_service "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/services/activity_service.py"
click node_mongo_access "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/db/mongo.py"
click node_ws_endpoint "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/ws.py"
click node_room_manager "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/websockets/connection_manager.py"
click node_environment "https://github.com/saurabh21y/hyscaler/blob/main/backend/app/core/config.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_spa_entry,node_auth_context,node_http_client,node_query_cache,node_project_views,node_socket_hook toneBlue
class node_api_app,node_auth_api,node_access_control,node_project_domain,node_task_domain,node_dashboard_api,node_comments_api,node_activity_service,node_mongo_access,node_environment toneAmber
class node_ws_endpoint,node_room_manager toneMint
```

## Components

### React SPA

- [SPA entry and routes](https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/main.jsx): React/Vite · Composes authenticated project and workspace views. · `frontend/src/main.jsx`
- [Auth state](https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/context/AuthContext.jsx): React context · Keeps short-lived access token in memory. · `frontend/src/context/AuthContext.jsx`
- [HTTP client](https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/api/axios.js): Axios · Refreshes and retries requests after 401 responses. · `frontend/src/api/axios.js`
- **Server-state cache**: TanStack Query · Caches API data and refetches invalidated resources.
- [Project and dashboard views](https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/pages/ProjectPage.jsx): React pages · `frontend/src/pages/ProjectPage.jsx`
- [Project socket hook](https://github.com/saurabh21y/hyscaler/blob/main/frontend/src/ws/useProjectSocket.js): React hook · Invalidates query caches when project events arrive. · `frontend/src/ws/useProjectSocket.js`

### FastAPI backend

- [API application](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/main.py): FastAPI · Startup point and router host. · `backend/app/main.py`
- [Authentication API](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/auth.py): FastAPI router · Issues JWT access tokens and refresh cookies. · `backend/app/routers/auth.py`
- [Identity and access control](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/core/dependencies.py): security dependencies · Validates JWT identity, membership, and owner permissions. · `backend/app/core/dependencies.py`
- [Projects and membership](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/projects.py): router + service · Manages projects, members, and owner-scoped actions. · `backend/app/routers/projects.py`
- [Tasks and board queries](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/tasks.py): FastAPI router · Applies server-side filtering, sorting, pagination, and status rules. · `backend/app/routers/tasks.py`
- [Dashboard and assignments](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/dashboard.py): FastAPI router · Serves cross-project assignment and dashboard data. · `backend/app/routers/dashboard.py`
- [Comments](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/comments.py): FastAPI router · `backend/app/routers/comments.py`
- [Activity audit service](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/services/activity_service.py): domain service · Persists activity generated by domain mutations. · `backend/app/services/activity_service.py`
- [Mongo persistence](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/db/mongo.py): PyMongo · Stores project, membership, task, comment, and activity records. · `backend/app/db/mongo.py`
- [Runtime configuration](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/core/config.py): environment config · Supplies Mongo, JWT/cookie, CORS, and API/WS settings. · `backend/app/core/config.py`

### Real-time updates

- [WebSocket endpoint](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/routers/ws.py): FastAPI router · Authenticates connection JWTs and verifies project membership. · `backend/app/routers/ws.py`
- [Project room manager](https://github.com/saurabh21y/hyscaler/blob/main/backend/app/websockets/connection_manager.py): in-memory connection manager · Single-process project-scoped socket registry and publisher. · `backend/app/websockets/connection_manager.py`

## Connections

- SPA entry and routes → Auth state: uses
- SPA entry and routes → Project and dashboard views: renders
- Project and dashboard views → Server-state cache: reads server state
- Server-state cache → HTTP client: fetches via
- Auth state → HTTP client: supplies access token
- HTTP client → API application: REST
- API application → Authentication API: routes
- API application → Projects and membership: routes
- API application → Tasks and board queries: routes
- API application → Dashboard and assignments: routes
- API application → Comments: routes
- Authentication API → Identity and access control: issues/validates tokens
- Projects and membership → Identity and access control: enforces membership
- Tasks and board queries → Identity and access control: enforces task permissions
- Projects and membership → Mongo persistence: persists
- Tasks and board queries → Mongo persistence: queries and mutates
- Comments → Mongo persistence: persists
- Tasks and board queries → Activity audit service: records mutations
- Comments → Activity audit service: records activity
- Activity audit service → Mongo persistence: writes audit events
- Project socket hook → WebSocket endpoint: project WebSocket
- WebSocket endpoint → Project room manager: registers connection
- Tasks and board queries → Project room manager: publishes project events
- Project room manager → Project socket hook: event notification
- Project socket hook → Server-state cache: invalidates and refetches
- Runtime configuration → API application: configures
