# ngocdai101004/intro2se-project-job-search architecture

> Architecture diagram of the GitHub repository ngocdai101004/intro2se-project-job-search, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ngocdai101004/intro2se-project-job-search
- Repository: https://github.com/ngocdai101004/intro2se-project-job-search

## Overview

##### Main Components
a. Frontend:
b. Backend:
- Inside, highlight components such as:
- Controllers (applicant, auth, chat, company, job, search, user) that handle business logic.
- Routes that expose API endpoints.
- Middlewares (verifyAdmin, verifyEmployee, verifyUser) that manage authentication/authorization.
- Models and Data Interfaces (e.g., applicationModel, chatModel, companyModel, jobModel etc.) indicating an MVC-ish design.
- Utility functions (token generation/decoding, email sending, and request slowdown).
- Configuration for database connection (MongoDB) and other settings.
c. Database:
- “MongoDB” as a separate component where all the persistent data (users, companies, job postings, chats) reside.
d. External Services:
- An “Email Service” (for confirmation emails, etc.), an “S3 Storage” (for assets like images uploaded in resumes or profiles), and a “Generative AI Service” (given by the Gemini API key variable).

##### Relationships and Interactions
- Optionally, detail internal data flows within the backend (e.g., from Routes → Controllers → Models) to capture the MVC flow and indicate the use of middleware for authentication and request validation.

##### Architectural Patterns and Design Principles
- That the backend follows an MVC pattern, separating concerns clearly across models, controllers, and routes.
- That the project’s overall design emphasizes a decoupled full-stack architecture (frontend and backend are separate modules) which improves scalability and maintenance.
- Secure transmission of data (JWT for authentication, middleware to verify user roles) and modular integration of external services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FEClient["Frontend Client\n(React/Vite)"]:::frontend
        FE_Pages["Pages\n(Auth, Company, Chat, Job Listings, Profile)"]:::frontend
        FE_Components["Components\n(ProtectedRoute, axios instance, etc.)"]:::frontend
        FEClient --> FE_Pages
        FEClient --> FE_Components
    end

    subgraph "Backend Layer"
        BE["Backend Server\n(Node.js/Express)"]:::backend
        BE_Routes["Routes\n(API Endpoints)"]:::backend
        BE_Middle["Middlewares\n(verifyAdmin, verifyEmployee, verifyUser)"]:::backend
        BE_Controllers["Controllers\n(Business Logic)"]:::backend
        BE_Models["Models\n(Data Interfaces)"]:::backend
        BE_Utils["Utility Functions\n(token, email, slowdown, etc.)"]:::backend
        BE_Config["Configuration\n(Database & settings)"]:::backend

        BE --> BE_Routes
        BE_Routes --> BE_Middle
        BE_Routes --> BE_Controllers
        BE_Controllers --> BE_Models
        BE --> BE_Utils
        BE --> BE_Config
    end

    FEClient -->|"HTTP_API_Requests"| BE
    BE -->|"Database_Operations"| Mongo["MongoDB"]:::database

    BE -->|"Send_Email"| ES["Email Service"]:::external
    BE -->|"Store_Files"| S3["S3 Storage"]:::external
    BE -->|"AI_Interactions"| AI["Generative AI Service"]:::external

    %% Click Events
    click FEClient "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/frontend/"
    click FE_Pages "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/frontend/src/pages/"
    click FE_Components "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/frontend/src/components/"
    click BE "https://github.com/ngocdai101004/intro2se-project-job-search/blob/main/backend/src/app.ts"
    click BE_Controllers "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/backend/src/controllers/"
    click BE_Routes "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/backend/src/routes/"
    click BE_Middle "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/backend/src/middlewares/"
    click BE_Models "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/backend/src/models/"
    click BE_Utils "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/backend/src/utils/"
    click BE_Config "https://github.com/ngocdai101004/intro2se-project-job-search/tree/main/backend/src/configs/"
    click ES "https://github.com/ngocdai101004/intro2se-project-job-search/blob/main/backend/src/utils/sendEmail.ts"
    click S3 "https://github.com/ngocdai101004/intro2se-project-job-search/blob/main/frontend/src/utils/s3.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
