# lvu237it/wdp301-planning-web-application architecture

> Architecture diagram of the GitHub repository lvu237it/wdp301-planning-web-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lvu237it/wdp301-planning-web-application
- Repository: https://github.com/lvu237it/wdp301-planning-web-application

## Overview

##### Project Type and Purpose
- This is a full‐stack, team‐collaboration web application.
- Front‐end: Single‐Page Application (SPA) built with React (Vite, Tailwind, shadcn-ui).
- Back‐end: Node.js + Express REST API (MVC pattern), real-time socket support, scheduled jobs, file management, OAuth and JWT-based authentication.
- Persistence: Likely MongoDB via Mongoose models.

##### File Structure
- Top‐level: `/front-end` and `/back-end`.
- Back‐end:
- `index.js`/`app.js` – Express app bootstrap
- `routes/` → `controllers/` → `models/` (MVC)
- `middlewares/`, `services/`, `utils/` (cross-cutting concerns)
- `swagger.json` for API docs
- cron jobs under `utils/cronJobs.js`
- OAuth config in `configs/passport-config.js`
- Front‐end:
- `src/` with `components/`, `pages/`, `contexts/`, `utils/`
- UI library under `components/ui/`
- Routing via React Router (`ProtectedRoute.jsx`)
- Real-time client socket in `utils/socketClient.js`
- Constants and styles grouped under `constants/` and `styles/`

##### Key README Insights
- (Not provided, but file tree alone indicates tech stack and architecture.)

##### Main Components & Interactions
a. Components
- Client SPA (React)
- API Server (Express)
- Database (MongoDB)
- Real-time Socket Service (Socket.io)
- External OAuth Service (Google)
- Email Service (SMTP/SendGrid via `sendMail.js`)
- File Storage (local/disk or cloud)
- Cron Scheduler (background jobs)
b. Interactions
- Browser ↔ SPA (user events, page routing)
- SPA ↔ API (HTTP REST over JWT)
- SPA ↔ API (WebSocket for live updates)
- API ↔ Database (CRUD via Mongoose models)
- API ↔ Google OAuth (OAuth2 handshake)
- API ↔ Email service (notification emails)
- Scheduler ↔ Database (periodic tasks)
c. Architectural Patterns
- Backend: MVC + Services + Middlewares
- Frontend: Component‐based SPA with Context for state
- Authentication: Passport.js + JWT + Protected Routes
- Real-time: Socket.io integration
d. Technologies & Frameworks
- Backend: Node.js, Express, Mongoose, Passport, JWT, Socket.io, Swagger
- Frontend: React, Vite, Tailwind CSS, shadcn-ui, React Router

## Diagram (Mermaid)

```mermaid
graph TB
    %% Front-end Layer
    subgraph "Front-end (React SPA)"
        direction TB
        FE_SPA["React SPA"]:::frontend
        FE_Protected["ProtectedRoute"]:::frontend
        FE_SocketClient["SocketClient"]:::frontend
    end

    %% Back-end Layer
    subgraph "Back-end (Express API + Socket)"
        direction TB
        BE_App["Express App (app.js/index.js)"]:::backend

        subgraph "Routing Layer"
            direction TB
            Routes["Routes (back-end/routes)"]:::backend
            AuthRoutes["authenticationRoutes.js"]:::backend
            BoardRoutes["boardRoutes.js"]:::backend
        end

        subgraph "Controller Layer"
            direction TB
            AuthController["AuthenticationController"]:::backend
            BoardController["BoardController"]:::backend
            FileController["FileController"]:::backend
        end

        subgraph "Service Layer"
            direction TB
            NotificationService["NotificationService"]:::service
        end

        subgraph "Data Layer"
            direction TB
            UserModel["UserModel"]:::database
            BoardModel["BoardModel"]:::database
            FileModel["FileModel"]:::database
            MongoDB["MongoDB"]:::database
        end

        subgraph "Utils & Middlewares"
            direction TB
            VerifyToken["verifyToken (JWT)"]:::backend
            PassportConfig["passport-config.js"]:::backend
            SendMail["sendMail.js"]:::service
            FileUtils["fileUtils.js"]:::service
            CronJobs["cronJobs.js"]:::async
            SocketServer["socket.js"]:::service
            AppError["appError.js"]:::backend
            AuthUtils["auth.js"]:::backend
        end

        Swagger["swagger.json"]:::external
    end

    %% External Services
    GoogleOAuth["Google OAuth"]:::external
    EmailService["Email Service (SMTP/SendGrid)"]:::external

    %% Connections
    FE_SPA -->|"REST API (JWT)"| AuthRoutes
    FE_SPA -->|"REST API (JWT)"| BoardRoutes
    FE_SPA -->|"WebSocket"| SocketServer
    FE_Protected -->|uses| FE_SPA
    FE_SocketClient -->|initialized by| FE_SPA

    BE_App -->|uses| Routes
    BE_App -->|bootstrap| Swagger

    Routes -->|calls| AuthController
    Routes -->|calls| BoardController
    Routes -->|calls| FileController
    Routes -->|middleware| VerifyToken

    AuthController -->|uses| PassportConfig
    AuthController -->|calls| NotificationService
    AuthController -->|CRUD| UserModel

    BoardController -->|CRUD| BoardModel
    FileController -->|CRUD| FileModel
    FileController -->|uses| FileUtils

    NotificationService -->|sends via| SendMail
    NotificationService -->|uses| AuthUtils

    CronJobs -->|scheduled CRUD| MongoDB
    SocketServer -->|real-time events| BoardController

    UserModel --->|persists to| MongoDB
    BoardModel --->|persists to| MongoDB
    FileModel --->|persists to| MongoDB

    AuthController -->|OAuth handshake| GoogleOAuth
    NotificationService -.->|async email| EmailService
    BE_App -.->|error handling| AppError

    %% Click Events
    click FE_SPA "https://github.com/lvu237it/wdp301-planning-web-application/tree/main/front-end/src"
    click FE_Protected "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/front-end/src/components/common/ProtectedRoute.jsx"
    click FE_SocketClient "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/front-end/src/utils/socketClient.js"
    click Routes "https://github.com/lvu237it/wdp301-planning-web-application/tree/main/back-end/routes"
    click AuthRoutes "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/routes/authenticationRoutes.js"
    click BoardRoutes "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/routes/boardRoutes.js"
    click AuthController "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/controllers/authenticationController.js"
    click BoardController "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/controllers/boardController.js"
    click FileController "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/controllers/fileController.js"
    click NotificationService "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/services/NotificationService.js"
    click UserModel "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/models/userModel.js"
    click BoardModel "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/models/boardModel.js"
    click FileModel "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/models/fileModel.js"
    click BE_App "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/app.js"
    click VerifyToken "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/middlewares/verifyToken.js"
    click PassportConfig "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/configs/passport-config.js"
    click SendMail "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/utils/sendMail.js"
    click FileUtils "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/utils/fileUtils.js"
    click CronJobs "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/utils/cronJobs.js"
    click SocketServer "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/utils/socket.js"
    click Swagger "https://github.com/lvu237it/wdp301-planning-web-application/blob/main/back-end/swagger.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#E8F0FE,stroke:#1a73e8,color:#1a73e8;
    classDef service fill:#E6F4EA,stroke:#34A853,color:#34A853;
    classDef database fill:#FBE9E7,stroke:#EA4335,color:#EA4335;
    classDef external fill:#F1F3F4,stroke:#5F6368,color:#5F6368;
    classDef async stroke-dasharray: 5 5,fill:none;
```
