# h-s-rathi/task-management-application architecture

> Architecture diagram of the GitHub repository h-s-rathi/task-management-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/h-s-rathi/task-management-application
- Repository: https://github.com/h-s-rathi/task-management-application

## Overview

##### Project Type and Purpose
- Full-stack web application for task management.
- Frontend: Next.js (React) with UI components, styling, and client-side routing.
- Backend: Node.js/Express REST API with MongoDB, JWT auth, and custom middleware.
- Core use cases: user registration/login, task CRUD, filtering, priority/status management.

##### File Structure
- Top-level “client” directory: a Next.js App Router project with `/app` pages, shared UI (`components/ui`), hooks, and utilities.
- Top-level “server” directory: Express server (`server.js`), route handlers (`routes/`), data models (`models/`), and middleware (`middleware/`).
- Configuration/build files: `next.config.mjs`, `tailwind.config.js`, `.env` (for secrets), `package.json` in each tier.
- Clear separation: frontend for UI, backend for API and data persistence.

##### README for Additional Insights
- Technologies listed: React/Next.js, Material-UI (or Tailwind CSS), Node.js, Express, MongoDB, JWT.
- Setup instructions confirm separate dev workflows for client and server.

##### Main Components and Their Relationships
a. Components:
- Client (Next.js React app)
- Backend API (Express/Node.js)
- Database (MongoDB Atlas or local)
- Authentication (JWT service built into API)
- Browser (user agent)
b. Interactions:
- Browser ↔ Client: HTTP(S) requests for page navigation, form submissions.
- Client ↔ API: REST calls (fetch/Axios) with JWT in headers.
- API ↔ Database: MongoDB queries via Mongoose.
- Middleware:
– Authentication middleware validates JWT → protects `/tasks` routes.
– ErrorHandler middleware catches server errors.
c. Architectural Patterns:
- Separation of concerns: UI vs API vs Data.
- MVC-like pattern on server: Models (User, Task), Controllers (routes), Middleware.
- Component-based design on frontend: reusable UI primitives in `components/ui`.
- Client hooks manage data fetching and authentication state.
d. Key Technologies:
- Next.js App Router, React hooks, Tailwind CSS / MUI.
- Express.js, Mongoose, JSON Web Token.
- Node.js ecosystem (npm scripts, environment variables).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser
    Browser["Browser"]:::browser

    %% Client Side
    subgraph "Client Application" 
        direction TB
        subgraph "Pages"
            direction TB
            HomePage["Home Page"]:::frontend
            DashboardPage["Dashboard Page"]:::frontend
            LoginPage["Login Page"]:::frontend
            RegisterPage["Register Page"]:::frontend
            LayoutStyles["Layout & Global Styles"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            UIPrimitives["Reusable UI Primitives"]:::frontend
            TaskForm["Task Form"]:::frontend
            TaskList["Task List"]:::frontend
            ThemeProvider["Theme Provider"]:::frontend
        end
        subgraph "Hooks & Libs"
            direction TB
            subgraph "Hooks"
                direction TB
                UseAuth["use-auth Hook"]:::frontend
                UseTasks["use-tasks Hook"]:::frontend
                UseToast["use-toast Hook"]:::frontend
                UseMobile["use-mobile Hook"]:::frontend
            end
            subgraph "Utilities"
                direction TB
                AuthLib["Auth Helpers"]:::frontend
                TasksLib["Task API Helpers"]:::frontend
                TypesLib["Shared Types"]:::frontend
                UtilsLib["Misc Utilities"]:::frontend
            end
        end
        subgraph "Client Config"
            direction TB
            NextConfig["next.config.mjs"]:::frontend
            TailwindConfig["tailwind.config.js"]:::frontend
            PostCSSConfig["postcss.config.mjs"]:::frontend
        end
    end

    %% Server Side
    subgraph "Server Application" 
        direction TB
        ServerEntry["server.js"]:::backend
        subgraph "API Routes"
            direction TB
            AuthRoute["Auth Routes"]:::backend
            TaskRoute["Task Routes"]:::backend
        end
        subgraph "Middleware"
            direction TB
            AuthMiddleware["JWT Auth Middleware"]:::middleware
            ErrorMiddleware["Error Handler Middleware"]:::middleware
        end
        subgraph "Data Models"
            direction TB
            UserModel["User Model"]:::backend
            TaskModel["Task Model"]:::backend
        end
        subgraph "Server Config"
            direction TB
            ServerPkg["package.json & lockfile"]:::backend
        end
    end

    %% Database
    MongoDB["MongoDB"]:::database

    %% Relationships
    Browser -->|"navigates"| HomePage
    Browser -->|"navigates"| DashboardPage
    Browser -->|"navigates"| LoginPage
    Browser -->|"navigates"| RegisterPage

    HomePage -->|"renders via React"| UIPrimitives
    DashboardPage -->|"renders"| TaskList
    LoginPage -->|"renders"| UIPrimitives
    RegisterPage -->|"renders"| UIPrimitives

    UIPrimitives -->|"used by"| TaskForm
    UIPrimitives -->|"used by"| TaskList
    UseAuth -->|"provides auth state"| LoginPage
    UseAuth -->|"provides auth state"| RegisterPage
    UseTasks -->|"fetches tasks"| DashboardPage
    UseToast -->|"shows notifications"| TaskForm
    UseMobile -->|"adapts layout"| LayoutStyles

    AuthLib -->|"helper for"| UseAuth
    TasksLib -->|"helper for"| UseTasks
    TypesLib -->|"shared types for"| UIPrimitives
    UtilsLib -->|"utilities for"| TaskForm

    HomePage -->|"API calls"| AuthRoute
    LoginPage -->|"POST /auth/login"| AuthRoute
    RegisterPage -->|"POST /auth/register"| AuthRoute
    DashboardPage -->|"GET /tasks"| TaskRoute
    TaskForm -->|"POST /tasks"| TaskRoute
    TaskList -->|"GET /tasks"| TaskRoute

    AuthRoute -->|"uses"| AuthMiddleware
    TaskRoute -->|"uses"| AuthMiddleware
    AuthRoute -->|"handles errors"| ErrorMiddleware
    TaskRoute -->|"handles errors"| ErrorMiddleware

    AuthRoute -->|"queries"| UserModel
    TaskRoute -->|"queries"| TaskModel

    ServerEntry -->|"loads routes & middleware"| AuthRoute
    ServerEntry -->|"loads routes & middleware"| TaskRoute

    UserModel -->|"persists to"| MongoDB
    TaskModel -->|"persists to"| MongoDB

    %% Click Events - Client
    click HomePage "https://github.com/h-s-rathi/task-management-application/blob/main/client/app/page.tsx"
    click DashboardPage "https://github.com/h-s-rathi/task-management-application/blob/main/client/app/dashboard/page.tsx"
    click LoginPage "https://github.com/h-s-rathi/task-management-application/blob/main/client/app/login/page.tsx"
    click RegisterPage "https://github.com/h-s-rathi/task-management-application/blob/main/client/app/register/page.tsx"
    click LayoutStyles "https://github.com/h-s-rathi/task-management-application/blob/main/client/app/layout.tsx"
    click LayoutStyles "https://github.com/h-s-rathi/task-management-application/blob/main/client/app/globals.css"
    click UIPrimitives "https://github.com/h-s-rathi/task-management-application/tree/main/client/components/ui/"
    click TaskForm "https://github.com/h-s-rathi/task-management-application/blob/main/client/components/task-form.tsx"
    click TaskList "https://github.com/h-s-rathi/task-management-application/blob/main/client/components/task-list.tsx"
    click ThemeProvider "https://github.com/h-s-rathi/task-management-application/blob/main/client/components/theme-provider.tsx"
    click UseAuth "https://github.com/h-s-rathi/task-management-application/blob/main/client/hooks/use-auth.tsx"
    click UseTasks "https://github.com/h-s-rathi/task-management-application/blob/main/client/hooks/use-tasks.tsx"
    click UseToast "https://github.com/h-s-rathi/task-management-application/blob/main/client/hooks/use-toast.ts"
    click UseMobile "https://github.com/h-s-rathi/task-management-application/blob/main/client/hooks/use-mobile.tsx"
    click AuthLib "https://github.com/h-s-rathi/task-management-application/blob/main/client/lib/auth.ts"
    click TasksLib "https://github.com/h-s-rathi/task-management-application/blob/main/client/lib/tasks.ts"
    click TypesLib "https://github.com/h-s-rathi/task-management-application/blob/main/client/lib/types.ts"
    click UtilsLib "https://github.com/h-s-rathi/task-management-application/blob/main/client/lib/utils.ts"
    click NextConfig "https://github.com/h-s-rathi/task-management-application/blob/main/client/next.config.mjs"
    click TailwindConfig "https://github.com/h-s-rathi/task-management-application/blob/main/client/tailwind.config.js"
    click PostCSSConfig "https://github.com/h-s-rathi/task-management-application/blob/main/client/postcss.config.mjs"
    click Client "https://github.com/h-s-rathi/task-management-application/tree/main/client/"

    %% Click Events - Server
    click ServerEntry "https://github.com/h-s-rathi/task-management-application/blob/main/server/server.js"
    click AuthRoute "https://github.com/h-s-rathi/task-management-application/blob/main/server/routes/auth.js"
    click TaskRoute "https://github.com/h-s-rathi/task-management-application/blob/main/server/routes/tasks.js"
    click AuthMiddleware "https://github.com/h-s-rathi/task-management-application/blob/main/server/middleware/auth.js"
    click ErrorMiddleware "https://github.com/h-s-rathi/task-management-application/blob/main/server/middleware/errorHandler.js"
    click UserModel "https://github.com/h-s-rathi/task-management-application/blob/main/server/models/User.js"
    click TaskModel "https://github.com/h-s-rathi/task-management-application/blob/main/server/models/Task.js"
    click ServerPkg "https://github.com/h-s-rathi/task-management-application/blob/main/server/package.json"
    click ServerPkg "https://github.com/h-s-rathi/task-management-application/blob/main/server/package-lock.json"
    click ServerEntry "https://github.com/h-s-rathi/task-management-application/tree/main/server/"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:1px,rx:5,ry:5
    classDef backend fill:#c8e6c9,stroke:#388e3c,stroke-width:1px,rx:3,ry:3
    classDef middleware fill:#e1bee7,stroke:#8e24aa,stroke-width:1px,rx:5,ry:0
    classDef database fill:#ffe0b2,stroke:#fb8c00,stroke-width:1px
    classDef browser fill:#fff9c4,stroke:#fbc02d,stroke-width:1px
```
