# tuankietcoderr/drd-fe architecture

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

- Interactive diagram: https://gitdiagram.com/tuankietcoderr/drd-fe
- Repository: https://github.com/tuankietcoderr/drd-fe

## Overview

##### Project type and purpose
- This is a Next.js (v13+) full-stack (primarily front-end + BFF) web application generated with create-next-app.
- It targets three user roles—candidates (user), recruiters (nha-tuyen-dung), and administrators (quan-tri)—each with its own auth flows, dashboards, and pages.
- It uses React (app-directory routing), Redux Toolkit (RTK Query for remote data), Contexts/hooks, Tailwind CSS, Docker, and external backend services (authentication, job data, file uploads, chatbot AI, etc.).

##### File structure
- Top level: configuration files (.eslintrc, prettier, Dockerfile, docker-compose.yml, deploy.sh), README, package.json.
- “src/app”: Next.js app router with nested folders for each role and auth vs. root layouts/pages.
- “src/components”: shared UI primitives (ui/…), views organized by domain (user, recruiter, admin).
- “src/redux”: Redux store config, RTK Query feature slices for auth, candidate, recruiter, job, cv-review, chatbot, etc.
- “src/hooks” & “src/context”: custom React hooks and contexts for audio recorder, chat widget, mobile detection, etc.
- “src/lib”, “src/utils”, “src/validator”: helper functions and validation logic.
- “next.config.mjs”, PostCSS/Tailwind config, jsconfig.json for path aliases.

##### README for additional insights
- Standard Next.js dev/start scripts, font optimization with next/font, Vercel deployment recommended. No mention of an internal API layer—instead the app relies on external REST endpoints surfaced via RTK Query.

##### Final advice
- Be exhaustive: break the app into logical layers (presentation, state, data-fetching, external services).
- Call out key cross-cutting concerns (authentication, file uploads, chatbot).
- Related components (e.g., Redux feature slices) to reduce clutter but still show their interactions.

## Diagram (Mermaid)

```mermaid
graph TB
  %% Layers
  subgraph "Client (Browser)" 
    direction TB
    ReactApp["React App (Hydration)"]:::client
    ReduxStore["Redux Store"]:::state
    Contexts["React Contexts"]:::state
    Hooks["Custom Hooks"]:::state
    UILib["UI Component Library"]:::ui
    Views["Domain Views"]:::ui
    ReactApp -->|"uses"| ReduxStore
    ReactApp -->|"uses"| Contexts
    ReactApp -->|"uses"| Hooks
    ReactApp -->|"renders"| UILib
    ReactApp -->|"renders"| Views
  end

  subgraph "Server (Next.js)" 
    direction TB
    SSR["SSR Engine"]:::server
    Router["App Router"]:::server
    Providers["Global Providers"]:::server
    Layout["Main Layout"]:::server
    SSR -->|renders| Router
    Router -->|applies| Providers
    Providers -->|wraps| Layout
    Layout -->|renders pages| Router
  end

  subgraph "External Services" 
    direction TB
    AuthService["Authentication Service"]:::external
    CandidateAPI["Candidate API"]:::external
    RecruiterAPI["Recruiter API"]:::external
    AdminAPI["Admin API"]:::external
    ChatbotAI["Chatbot/AI Service"]:::external
    FileStorage["File Storage Service"]:::external
    AuthService -->|DB| AuthDB[(Auth DB)]:::db
    CandidateAPI -->|DB| CandidateDB[(Candidate DB)]:::db
    RecruiterAPI -->|DB| RecruiterDB[(Recruiter DB)]:::db
    AdminAPI -->|DB| AdminDB[(Admin DB)]:::db
    FileStorage -->|Blob Store| Storage[(Blob Storage)]:::db
  end

  subgraph "Infrastructure"
    direction TB
    CDN["CDN / Static Hosting"]:::infra
    DockerInfra["Docker & CI/CD"]:::infra
  end

  %% Interactions
  ReactApp -->|"HTTP(S) SSR"| SSR
  SSR -->|"fetch data via RTK Query"| AuthService
  SSR -->|"fetch data via RTK Query"| CandidateAPI
  SSR -->|"fetch data via RTK Query"| RecruiterAPI
  SSR -->|"fetch data via RTK Query"| AdminAPI
  SSR -->|"fetch data via RTK Query"| ChatbotAI
  SSR -->|"upload via RTK Query"| FileStorage
  ReactApp -->|"fetch data via RTK Query"| AuthService
  ReactApp -->|"fetch data via RTK Query"| CandidateAPI
  ReactApp -->|"fetch data via RTK Query"| RecruiterAPI
  ReactApp -->|"fetch data via RTK Query"| AdminAPI
  ReactApp -->|"invoke"| ChatbotAI
  ReactApp -->|"upload"| FileStorage
  CDN -->|serves static assets| ReactApp
  DockerInfra -->|deploys| SSR

  %% Role-based Routing
  subgraph "Routing (src/app)" 
    direction TB
    UserAuth["User Auth Pages"]:::route
    UserRoot["User Root Pages & Layout"]:::route
    RecAuth["Recruiter Auth Pages"]:::route
    RecRoot["Recruiter Root Pages & Layout"]:::route
    AdminAuth["Admin Auth Pages"]:::route
    AdminRoot["Admin Root Pages & Layout"]:::route
    Router --> UserAuth
    Router --> UserRoot
    Router --> RecAuth
    Router --> RecRoot
    Router --> AdminAuth
    Router --> AdminRoot
  end

  %% Redux Feature Slices
  subgraph "Redux (src/redux)" 
    direction TB
    StoreConfig["Store Config"]:::state
    BaseQuery["RTK Base Query"]:::state
    HooksFile["Redux Typed Hooks"]:::state
    AuthSlice["Auth Feature Slice"]:::state
    CandidateSlice["Candidate Feature Slice"]:::state
    RecruiterSlice["Recruiter Feature Slice"]:::state
    JobSlice["Job Description Feature Slice"]:::state
    CVSlice["CV Review Feature Slice"]:::state
    ChatbotSlice["Chatbot Feature Slice"]:::state
    LocationSlice["Location Feature Slice"]:::state
    OccupationSlice["Occupation Feature Slice"]:::state
    PostSlice["Post/Job Feature Slice"]:::state
    UploadSlice["File Upload Feature Slice"]:::state
    StoreConfig --> BaseQuery
    StoreConfig --> HooksFile
    StoreConfig --> AuthSlice
    StoreConfig --> CandidateSlice
    StoreConfig --> RecruiterSlice
    StoreConfig --> JobSlice
    StoreConfig --> CVSlice
    StoreConfig --> ChatbotSlice
    StoreConfig --> LocationSlice
    StoreConfig --> OccupationSlice
    StoreConfig --> PostSlice
    StoreConfig --> UploadSlice
  end

  %% Utilities
  subgraph "Utilities"
    direction TB
    Utils["Utility Functions"]:::util
    ValSchemas["Validation Schemas"]:::util
    Types["Type Definitions"]:::util
  end

  %% Public & Config
  subgraph "Project Config & Assets"
    direction TB
    Public["Public Static Assets"]:::infra
    TailwindConfig["Tailwind & PostCSS Config"]:::infra
    NextConfig["Next.js & Path Config"]:::infra
    DockerConfig["Docker & CI/CD Scripts"]:::infra
    ESLintPrettier["ESLint & Prettier Config"]:::infra
  end

  %% Click Events
  click Router "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app"
  click UserAuth "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app/(user)/(auth)"
  click UserRoot "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app/(user)/(root)"
  click RecAuth "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app/nha-tuyen-dung/(auth)"
  click RecRoot "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app/nha-tuyen-dung/(root)"
  click AdminAuth "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app/quan-tri/(auth)"
  click AdminRoot "https://github.com/tuankietcoderr/drd-fe/tree/main/src/app/quan-tri/(root)"
  click Providers "https://github.com/tuankietcoderr/drd-fe/blob/main/src/app/providers.jsx"
  click SSR "https://github.com/tuankietcoderr/drd-fe/blob/main/src/app/store-provider.jsx"
  click Layout "https://github.com/tuankietcoderr/drd-fe/blob/main/src/layout/MainLayout.jsx"
  click UILib "https://github.com/tuankietcoderr/drd-fe/tree/main/src/components/ui"
  click Views "https://github.com/tuankietcoderr/drd-fe/tree/main/src/components/views"
  click Hooks "https://github.com/tuankietcoderr/drd-fe/tree/main/src/hooks"
  click Contexts "https://github.com/tuankietcoderr/drd-fe/tree/main/src/context"
  click StoreConfig "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/store.js"
  click BaseQuery "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/baseQuery.js"
  click HooksFile "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/hooks.js"
  click AuthSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/auth/authSlice.js"
  click AuthSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/auth/authQuery.js"
  click CandidateSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/candidate/candidateSlice.js"
  click CandidateSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/candidate/candidateQuery.js"
  click RecruiterSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/recruiter/recruiterQuery.js"
  click JobSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/job-description/jobDescriptionSlice.js"
  click JobSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/job-description/jobDescriptionQuery.js"
  click CVSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/cv-review/cvReviewSlice.js"
  click CVSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/cv-review/cvReviewQuery.js"
  click ChatbotSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/chatbot/chatbotSlice.js"
  click ChatbotSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/chatbot/chatbotQuery.js"
  click LocationSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/location/locationSlice.js"
  click LocationSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/location/locationQuery.js"
  click OccupationSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/occupation/occupationSlice.js"
  click OccupationSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/occupation/occupationQuery.js"
  click PostSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/post/postQuery.js"
  click UploadSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/upload/uploadSlice.js"
  click UploadSlice "https://github.com/tuankietcoderr/drd-fe/blob/main/src/redux/features/upload/uploadQuery.js"

  %% Styles
  classDef client fill:#E0F7FA,stroke:#00796B,stroke-width:1px
  classDef server fill:#BBDEFB,stroke:#1E88E5,stroke-width:1px
  classDef external fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px
  classDef infra fill:#EEEEEE,stroke:#9E9E9E,stroke-width:1px
  classDef state fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
  classDef ui fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px
  classDef route fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
  classDef util fill:#F0F4C3,stroke:#AFB42B,stroke-width:1px
```
