# prateekjaiswal16/taskflow architecture

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

- Interactive diagram: https://gitdiagram.com/prateekjaiswal16/taskflow
- Repository: https://github.com/prateekjaiswal16/taskflow

## Overview

##### Project Type and Purpose
- This is a full-stack task management application.
- Frontend: React (Vite) single-page app that handles UI for tasks and users.
- Backend: Node.js + Express REST API providing auth, task and user endpoints.
- Database: MongoDB for persisting Users and Tasks.
- File storage: Supabase (user note: MongoDB is used for primary data; files are stored in Supabase).
- CI/CD: GitHub Actions + Docker Compose for orchestration.

##### Key Architectural Components
a. Frontend (React/SP A)
- Components: Pages (Dashboard, Login, Register, TaskDetail), Layouts, UI primitives, Task & User components
- State management: Zustand stores (useAuthStore, useTaskStore, useUserStore)
- Services: authService, taskService, userService call backend REST endpoints via axios
b. Backend (Express API)
- Entry point: server.js
- Routes (authRoutes, taskRoutes, userRoutes) → Controllers → Models (Mongoose schemas)
- Middleware:
– authMiddleware: JWT verification
– errorMiddleware: centralized error handling
– uploadSupabase: handles file uploads to Supabase
- Utils: generateToken (JWT), supabaseClient (SDK)
- Config: db.js initializes MongoDB connection
c. Database
- MongoDB collections: users, tasks
d. External Services
- Supabase: object storage for file uploads
e. DevOps / Deployment
- Dockerfiles for frontend & backend
- compose.yml brings up API, Web, MongoDB, Supabase emulator (if any)
- GitHub Actions (cicd.yml) for build/test/deploy pipelines

##### Interactions and Data Flow
1. User interacts with React UI → triggers actions (e.g., login, fetch tasks)
2. Frontend Service calls REST API over HTTP(S) → Express routes
3. Express Controller validates/authenticates via JWT → interacts with Mongoose Models
4. Models read/write to MongoDB
5. For uploads, Express middleware streams file → Supabase storage via supabaseClient
6. Response sent back to frontend → UI updates via state store

##### Architectural Patterns and Principles
- MVC in backend (Routes → Controllers → Models)
- JWT stateless authentication
- Separation of concerns: UI components vs. business logic vs. data access
- Containerization (Docker) + Infrastructure as code (compose.yml)
- Single-page app with client routing (ProtectedRoute, AdminRoute)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (UI Layer)" 
        style Frontend fill:#cce5ff,stroke:#004085,stroke-width:2px
        Frontend["React SPA"]:::frontend
        subgraph "Pages"
            style Pages fill:#e2edf5,stroke:#004085
            DashboardPage["DashboardPage.jsx"]:::frontend
            LoginPage["LoginPage.jsx"]:::frontend
            RegisterPage["RegisterPage.jsx"]:::frontend
            TaskDetailPage["TaskDetailPage.jsx"]:::frontend
        end
        subgraph "Layouts & UI"
            style Layouts fill:#e2edf5,stroke:#004085
            MainLayout["MainLayout.jsx"]:::frontend
            Navbar["Navbar.jsx"]:::frontend
            Sidebar["Sidebar.jsx"]:::frontend
            UIPimitives["UI Primitives"]:::frontend
            TaskComponents["Task Components"]:::frontend
            UserComponents["UserForm.jsx"]:::frontend
        end
        subgraph "Routing & State & Services"
            style Services fill:#e2edf5,stroke:#004085
            ProtectedRoute["ProtectedRoute.jsx"]:::frontend
            AdminRoute["AdminRoute.jsx"]:::frontend
            StoreAuth["useAuthStore.js"]:::frontend
            StoreTask["useTaskStore.js"]:::frontend
            StoreUser["useUserStore.js"]:::frontend
            AuthService["authService.js"]:::frontend
            TaskService["taskService.js"]:::frontend
            UserService["userService.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (API Layer)"
        style Backend fill:#d4edda,stroke:#155724,stroke-width:2px
        APIServer["Express API"]:::backend
        Server["server.js"]:::backend
        subgraph "Routes → Controllers → Models"
            style MVC fill:#e9f7ef,stroke:#155724
            AuthRoutes["authRoutes.js"]:::backend
            TaskRoutes["taskRoutes.js"]:::backend
            UserRoutes["userRoutes.js"]:::backend
            AuthController["authController.js"]:::backend
            TaskController["taskController.js"]:::backend
            UserController["userController.js"]:::backend
            UserModel["userModel.js"]:::backend
            TaskModel["taskModel.js"]:::backend
        end
        subgraph "Middleware & Utils"
            style Middleware fill:#e9f7ef,stroke:#155724
            AuthMiddleware["authMiddleware.js"]:::backend
            ErrorMiddleware["errorMiddleware.js"]:::backend
            UploadSupabase["uploadSupabase.js"]:::backend
            GenerateToken["generateToken.js"]:::backend
            SupabaseClient["supabaseClient.js"]:::backend
        end
        DBConfig["db.js"]:::backend
    end

    %% Data Layer
    subgraph "Database (Data Layer)"
        style Database fill:#fff3cd,stroke:#856404,stroke-width:2px
        MongoDB["MongoDB (users, tasks)"]:::data
    end

    %% External Services
    subgraph "External Services"
        style External fill:#f5e2ff,stroke:#4a148c,stroke-width:2px
        Supabase["Supabase Storage"]:::external
    end

    %% DevOps Layer
    subgraph "DevOps / CI-CD"
        style DevOps fill:#e2e3e5,stroke:#383d41,stroke-width:2px
        GitHubActions["GitHub Actions"]:::devops
        DockerCompose["Docker Compose"]:::devops
    end

    %% Connections
    Frontend -->|"/login, /tasks, /users"| APIServer
    APIServer -->|"JWT Auth"| AuthMiddleware
    APIServer -->|Queries| MongoDB
    APIServer -->|"File Stream"| Supabase
    AuthMiddleware -->|token| GenerateToken
    AuthRoutes -->|calls| AuthController
    TaskRoutes -->|calls| TaskController
    UserRoutes -->|calls| UserController
    AuthController -->|CRUD| UserModel
    TaskController -->|CRUD| TaskModel
    GitHubActions -->|build/test/deploy| DockerCompose
    DockerCompose -->|orchestrate| APIServer
    DockerCompose -->|orchestrate| Frontend
    DockerCompose -->|orchestrate| MongoDB
    DockerCompose -->|emulate| Supabase

    %% Click Events - Frontend
    click Frontend "https://github.com/prateekjaiswal16/taskflow/tree/main/frontend/src"
    click DashboardPage "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/pages/DashboardPage.jsx"
    click LoginPage "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/pages/LoginPage.jsx"
    click RegisterPage "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/pages/RegisterPage.jsx"
    click TaskDetailPage "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/pages/TaskDetailPage.jsx"
    click MainLayout "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/components/layout/MainLayout.jsx"
    click Navbar "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/components/layout/Navbar.jsx"
    click Sidebar "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/components/layout/Sidebar.jsx"
    click UIP primitives "frontend/src/components/ui"
    click TaskComponents "https://github.com/prateekjaiswal16/taskflow/tree/main/frontend/src/components/tasks"
    click UserComponents "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/components/users/UserForm.jsx"
    click ProtectedRoute "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/routes/ProtectedRoute.jsx"
    click AdminRoute "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/routes/AdminRoute.jsx"
    click StoreAuth "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/store/useAuthStore.js"
    click StoreTask "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/store/useTaskStore.js"
    click StoreUser "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/store/useUserStore.js"
    click AuthService "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/service/authService.js"
    click TaskService "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/service/taskService.js"
    click UserService "https://github.com/prateekjaiswal16/taskflow/blob/main/frontend/src/service/userService.js"
    click Server "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/server.js"
    click DBConfig "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/config/db.js"
    click AuthRoutes "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/routes/authRoutes.js"
    click TaskRoutes "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/routes/taskRoutes.js"
    click UserRoutes "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/routes/userRoutes.js"
    click AuthController "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/controllers/authController.js"
    click TaskController "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/controllers/taskController.js"
    click UserController "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/controllers/userController.js"
    click UserModel "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/models/userModel.js"
    click TaskModel "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/models/taskModel.js"
    click AuthMiddleware "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/middleware/authMiddleware.js"
    click ErrorMiddleware "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/middleware/errorMiddleware.js"
    click UploadSupabase "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/middleware/uploadSupabase.js"
    click GenerateToken "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/utils/generateToken.js"
    click SupabaseClient "https://github.com/prateekjaiswal16/taskflow/blob/main/backend/utils/supabaseClient.js"
    click GitHubActions "https://github.com/prateekjaiswal16/taskflow/blob/main/.github/workflows/cicd.yml"
    click DockerCompose "https://github.com/prateekjaiswal16/taskflow/blob/main/compose.yml"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085
    classDef backend fill:#d4edda,stroke:#155724
    classDef data fill:#fff3cd,stroke:#856404
    classDef external fill:#f5e2ff,stroke:#4a148c
    classDef devops fill:#e2e3e5,stroke:#383d41
```
