# vm-phung1134/thesis-course-registration-system architecture

> Architecture diagram of the GitHub repository vm-phung1134/thesis-course-registration-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vm-phung1134/thesis-course-registration-system
- Repository: https://github.com/vm-phung1134/thesis-course-registration-system

## Overview

##### Project type and purpose
- This is a full-stack, multi-page web application built on Next.js (React) with a Node.js/Express API and Firebase for authentication.
- It serves as a “Thesis Course Registration (TCR) System” for students, lecturers, and admins to register research topics, submit progress reports, schedule defenses (using genetic algorithms), assign instructors, and evaluate theses.

##### Core architecture & layers
a. Presentation Layer (Next.js Frontend)
- Next.js runtime (server-side rendering + client CSR).
- Pages folder (URL→Page components).
- Component library (Atomic Design):
− Atoms → Molecules → Organisms → Templates.
- Global styles (Tailwind config, globals.css).
b. State Management Layer
- React Contexts (AuthContext, currentUserContext, languageContext, subscribeState, socketContext, searchContext).
- Redux store (store.ts) with reducers handling REST API slices (auth, classroom, comment, etc.).
- React Query (if used) for caching server state.
c. Service / API Layer
- HTTP clients & hooks (useMutationAPI, usePagination, useTableSearch, useToastify, custom hooks).
- Utils (classroomService.ts, calculatorPoint.ts, date converters).
- Firebase SDK (firebase-config.ts) for Auth.
d. Data & External Services Layer
- Express.js API Server (external repo) exposing REST endpoints under e.g. /api/auth, /api/classroom, etc.
- Database (e.g., PostgreSQL or MongoDB) behind Express.
- Firebase Auth service.
- (Optional) WebSocket server if real-time features are used.
- Genetic-Algorithm scheduling microservice (batch/back-end job).

##### Component interactions & data flow
- User (browser) → Next.js page → UI Components
- UI Components dispatch actions either via React Context or Redux → Middleware/hooks → API client (Axios/fetch)
- API client → Express.js REST API → Database → returns JSON
- Results → Redux store / React Query cache → re-render UI
- Auth flow: UI calls Firebase Auth SDK → Firebase → token → stored in Context/Redux → included in API headers
- WebSocket (if any): socketContext connects to socket server for live updates
- Background Scheduler: Express triggers genetic-algorithm job or calls microservice to compute schedules

##### Architectural patterns & principles
- Atomic Design for UI decomposition.
- Layered architecture: Presentation → Application (hooks/services) → Domain (contexts/redux) → Infrastructure (API, Auth, DB).
- Single source of truth via Redux and Context.
- Separation of concerns: each directory (components, hooks, utils, contexts, redux) fulfills a distinct role.

##### Detailed components
- Presentation: pages/, components/{Atoms, Molecules, Organisms, Templates}
- State: contexts/, redux/store.ts + reducers/*
- Hooks/services: hooks/, utils/, data/
- External: Firebase (Auth), REST API Server (Node.js/Express), Database, Scheduler service

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Next.js)" 
        direction TB
        subgraph "Presentation Layer"
            direction TB
            Pages["pages/"]:::frontend
            Atoms["components/Atoms/"]:::frontend
            Molecules["components/Molecules/"]:::frontend
            Organisms["components/Organisms/"]:::frontend
            Templates["components/Templates/"]:::frontend
            GlobalStyles["styles/globals.css"]:::frontend
            TailwindConfig["tailwind.config.ts"]:::frontend
        end
        subgraph "State Management Layer"
            direction TB
            AuthContext["authContext.tsx"]:::frontend
            CurrentUserContext["currentUserContext.tsx"]:::frontend
            LanguageContext["languageContext.tsx"]:::frontend
            SubscribeStateContext["subscribeState.tsx"]:::frontend
            SocketContext["useSocketContext.tsx"]:::frontend
            SearchContext["useSearchContext.tsx"]:::frontend
            ReduxStore["redux/store.ts"]:::frontend
            ReduxReducers["redux/reducer/"]:::frontend
        end
        subgraph "Service/API Layer"
            direction TB
            MutationAPI["hooks/useMutationAPI.tsx"]:::frontend
            Pagination["hooks/usePagination.tsx"]:::frontend
            TableSearch["hooks/useTableSearch.tsx"]:::frontend
            Toastify["hooks/useToastify.tsx"]:::frontend
            CheckedBox["hooks/useCheckedBox.tsx"]:::frontend
            Cookies["hooks/useCookies.tsx"]:::frontend
            GetCurrentUser["hooks/useGetCurrentUser.tsx"]:::frontend
            SelectStage["hooks/useSelectStage.tsx"]:::frontend
            ClassroomService["utils/classroomService.ts"]:::frontend
            CalculatorPoint["utils/calculatorPoint.ts"]:::frontend
            ConvertString["utils/convertString.ts"]:::frontend
            ConvertDate["utils/covertDate.ts"]:::frontend
            GetDeadline["utils/getDeadline.ts"]:::frontend
            FirebaseConfig["config/firebase-config.ts"]:::frontend
        end
    end

    %% Backend and External Services
    subgraph "Backend Services"
        direction TB
        APIServer["Express.js REST API"]:::backend
        DB["Database (PostgreSQL/MongoDB)"]:::backend
        Scheduler["Genetic-Algorithm Scheduler"]:::external
    end
    FirebaseAuth["Firebase Auth"]:::external

    %% Connections
    Templates -->|"dispatch actions / useContext"| AuthContext
    Templates -->|"dispatch actions / useContext"| ReduxStore
    AuthContext -->|"uses hooks/services"| MutationAPI
    ReduxStore -->|"uses hooks/services"| MutationAPI
    MutationAPI -->|"HTTP REST"| APIServer
    APIServer -->|"reads/writes"| DB
    APIServer -->|"trigger scheduling job"| Scheduler
    Templates -->|"Firebase Auth SDK"| FirebaseAuth
    FirebaseAuth -->|"JWT token"| AuthContext

    %% Click Events
    click Pages "https://github.com/vm-phung1134/thesis-course-registration-system/tree/master/pages/"
    click Atoms "https://github.com/vm-phung1134/thesis-course-registration-system/tree/master/components/Atoms/"
    click Molecules "https://github.com/vm-phung1134/thesis-course-registration-system/tree/master/components/Molecules/"
    click Organisms "https://github.com/vm-phung1134/thesis-course-registration-system/tree/master/components/Organisms/"
    click Templates "https://github.com/vm-phung1134/thesis-course-registration-system/tree/master/components/Templates/"
    click GlobalStyles "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/styles/globals.css"
    click TailwindConfig "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/tailwind.config.ts"
    click AuthContext "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/contexts/authContext.tsx"
    click CurrentUserContext "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/contexts/currentUserContext.tsx"
    click LanguageContext "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/contexts/languageContext.tsx"
    click SubscribeStateContext "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/contexts/subscribeState.tsx"
    click SocketContext "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/contexts/useSocketContext.tsx"
    click SearchContext "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/contexts/useSearchContext.tsx"
    click ReduxStore "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/redux/store.ts"
    click ReduxReducers "https://github.com/vm-phung1134/thesis-course-registration-system/tree/master/redux/reducer/"
    click MutationAPI "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useMutationAPI.tsx"
    click Pagination "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/usePagination.tsx"
    click TableSearch "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useTableSearch.tsx"
    click Toastify "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useToastify.tsx"
    click CheckedBox "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useCheckedBox.tsx"
    click Cookies "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useCookies.tsx"
    click GetCurrentUser "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useGetCurrentUser.tsx"
    click SelectStage "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/hooks/useSelectStage.tsx"
    click ClassroomService "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/utils/classroomService.ts"
    click CalculatorPoint "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/utils/calculatorPoint.ts"
    click ConvertString "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/utils/convertString.ts"
    click ConvertDate "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/utils/covertDate.ts"
    click GetDeadline "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/utils/getDeadline.ts"
    click FirebaseConfig "https://github.com/vm-phung1134/thesis-course-registration-system/blob/master/config/firebase-config.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0033A0,color:#000
    classDef backend fill:#D0FFD0,stroke:#006600,color:#000
    classDef external fill:#FFE5B4,stroke:#CC7A00,color:#000
```
