# malikbasiq/todo-fullstack-nest-react architecture

> Architecture diagram of the GitHub repository malikbasiq/todo-fullstack-nest-react, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/malikbasiq/todo-fullstack-nest-react
- Repository: https://github.com/malikbasiq/todo-fullstack-nest-react

## Overview

##### Project type and purpose
- This is a monorepo full-stack Todo application.
- Frontend: React + Vite SPA, client-side routing, Axios HTTP client.
- Backend: NestJS REST API with JWT authentication, role-based access (NORMAL_USER_ROLE, ADMIN), PostgreSQL persistence.

##### File structure
- Top level:
- react-app-vite/ → React SPA
- todo-backend/   → NestJS API
- Frontend details:
- src/pages/ → page components (Login, SignUp, ActiveTodos, CompletedTodos, UsersPage)
- src/components/ → reusable UI (NavBar, ActiveTodoList, CompletedTodoList)
- src/axios/AxiosSetup.ts → Axios instance + interceptors (attach JWT)
- src/api/ApiConstants.ts → endpoint definitions
- src/utils/LoginInfo.ts → JWT token management
- src/Routing.tsx & ProtectedRoute.tsx → route guards
- Backend details:
- src/app.controller.ts → HTTP endpoints (CRUD todos, users)
- src/app.service.ts    → business logic layer
- src/app.module.ts     → NestJS module definitions (imports, providers, controllers)
- src/main.ts           → bootstrap Nest application
- Configuration: nest-cli.json, tsconfig, .env (PORT, DATABASE_URL, JWT_SECRET)
- Testing: src/app.controller.spec.ts, test/app.e2e-spec.ts

##### Key architecture insights from README
- Monolithic backend with layered MVC (Controllers → Services → Database).
- JWT-based stateless authentication.
- Role-based authorization: NORMAL_USER_ROLE vs ADMIN.
- Frontend-driven UI with async calls to the NestJS API.

##### Elements
- Clear labels: “React SPA”, “Axios HTTP Client”, “NestJS Controller”, “NestJS Service”, “PostgreSQL”
- User → React SPA
- React SPA → Axios→ NestJS Controller
- Controller → Service → Database
- Auth flows: Login request → AuthController → JWT issuance → localStorage
- Blue rectangles for frontend components
- Green rectangles for backend modules

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Users and External
    User["User"]:::external
    Storage["Browser Storage"]:::storage

    %% Frontend Layer
    subgraph "Frontend (React + Vite)"
        direction TB
        Entry["Entry Point\n(main.tsx & index.html)"]:::frontend
        Routing["Client-Side Routing\n(Routing.tsx)"]:::frontend
        Guard["Protected Route Guard\n(ProtectedRoute.tsx)"]:::frontend
        subgraph "Pages"
            direction TB
            Login["Login Page"]:::frontend
            SignUp["SignUp Page"]:::frontend
            ActivePage["Active Todos Page"]:::frontend
            CompletedPage["Completed Todos Page"]:::frontend
            UsersPage["Users Management Page"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            NavBar["Navigation Bar"]:::frontend
            ActiveList["Active Todo List"]:::frontend
            CompletedList["Completed Todo List"]:::frontend
        end
        Axios["Axios HTTP Client\n(AxiosSetup.ts)"]:::frontend
        ApiConst["API Constants\n(ApiConstants.ts)"]:::frontend
        LoginInfo["JWT Token Utility\n(LoginInfo.ts)"]:::frontend
        ConfigFE["Vite & TS Configs"]:::config
    end

    %% Backend Layer
    subgraph "Backend (NestJS API)"
        direction TB
        Bootstrap["Application Bootstrap\n(main.ts)"]:::backend
        ModuleDef["Module Definitions\n(app.module.ts)"]:::backend
        Controller["Controllers\n(app.controller.ts)"]:::backend
        Service["Business Logic\n(app.service.ts)"]:::backend
        ConfigBE["Nest CLI & TS Configs"]:::config
        subgraph "Testing"
            direction TB
            UnitTest["Unit Tests\n(app.controller.spec.ts)"]:::testing
            E2E["E2E Tests\n(app.e2e-spec.ts)"]:::testing
            JestConfig["Jest E2E Config\n(jest-e2e.json)"]:::testing
        end
        Build["Build Output\n(dist/)"]:::backend
    end

    %% Database
    Database["PostgreSQL Database"]:::db

    %% Data Flows
    User -->|"interacts with"| Entry
    Entry --> Routing
    Routing --> Guard
    Guard --> Pages
    Pages --> NavBar
    Pages --> ActiveList
    Pages --> CompletedList
    Pages --> UsersPage
    Pages -->|uses| Axios
    Axios -->|HTTP JSON\nBearer JWT| Controller
    Controller -->|calls| Service
    Service -->|reads/writes| Database
    Controller -->|issues/verifies JWT| LoginInfo
    LoginInfo -.->|stores token| Storage
    ConfigFE -.-> Entry
    ConfigBE -.-> Bootstrap

    %% Click Events
    click Entry "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/main.tsx"
    click Entry "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/index.html"
    click Routing "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/Routing.tsx"
    click Guard "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/ProtectedRoute.tsx"
    click Login "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/pages/Login.tsx"
    click SignUp "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/pages/SignUp.tsx"
    click ActivePage "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/pages/ActiveTodos.tsx"
    click CompletedPage "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/pages/CompletedTodos.tsx"
    click UsersPage "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/pages/UsersPage.tsx"
    click NavBar "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/components/NavBar.tsx"
    click ActiveList "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/components/ActiveTodoList.tsx"
    click CompletedList "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/components/CompletedTodoList.tsx"
    click Axios "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/axios/AxiosSetup.ts"
    click ApiConst "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/api/ApiConstants.ts"
    click LoginInfo "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/src/utils/LoginInfo.ts"
    click ConfigFE "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/vite.config.ts"
    click ConfigFE "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/tsconfig.json"
    click ConfigFE "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/react-app-vite/tsconfig.node.json"
    click Bootstrap "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/src/main.ts"
    click ModuleDef "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/src/app.module.ts"
    click Controller "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/src/app.controller.ts"
    click Service "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/src/app.service.ts"
    click ConfigBE "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/nest-cli.json"
    click ConfigBE "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/tsconfig.json"
    click ConfigBE "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/tsconfig.build.json"
    click UnitTest "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/src/app.controller.spec.ts"
    click E2E "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/test/app.e2e-spec.ts"
    click JestConfig "https://github.com/malikbasiq/todo-fullstack-nest-react/blob/main/todo-backend/test/jest-e2e.json"
    click Build "https://github.com/malikbasiq/todo-fullstack-nest-react/tree/main/todo-backend/dist/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#D6FFD6,stroke:#28a745,color:#28a745;
    classDef db fill:#FFE0B2,stroke:#e36209,color:#e36209,shape:cylinder;
    classDef external fill:#FFFFFF,stroke:#000000,color:#000000,stroke-dasharray: 5 5;
    classDef storage fill:#F0F0F0,stroke:#888888,color:#333333,stroke-dasharray: 2 2;
    classDef config fill:#F0D0FF,stroke:#9b59b6,color:#9b59b6;
    classDef testing fill:#FFEFFF,stroke:#e83e8c,color:#e83e8c;
```
