# khoa-cntt/xdwdttdt2164 architecture

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

- Interactive diagram: https://gitdiagram.com/khoa-cntt/xdwdttdt2164
- Repository: https://github.com/khoa-cntt/xdwdttdt2164

## Overview

##### Project Type and Purpose
- This is a full-stack web application that supports job posting, candidate applications, and an automated CV screening mechanism. Its purpose is to connect candidates with employers while providing functionalities like registration/login (with OTP verification), job search/application, posting and management of job adverts, and handling payment through a wallet system.
- The README also highlights that the project is built with Node.js/Express (backend) and Vue.js (frontend), using Docker for containerization along with services such as Redis and a SQL database.

##### Analyzing the File Structure to Identify Components
- Backend:
- Located in the /backend directory.
- Follows an MVC-like structure with separate folders for controllers, services, routes, models, migrations, validations, and middlewares. This separation indicates a well-defined layer separation for handling business logic, data models, routing, and error handling.
- Contains configuration files for third-party services like Cloudinary, Redis, and email settings.
- Utilizes Sequelize for ORM tasks and includes migration scripts to manage database schema changes.
- Frontend:
- Located in the /frontend directory.
- Uses Vue (with Vue Router and Vuex) to structure the UI components and views, split into role-based segments (admin, candidate, employer, common) which reflects the multi-role functionality.
- Contains static assets, configuration files, and a clear separation between reusable components and view layers.
- Root and Containerization:
- The top-level directory contains the docker-compose.yml file that orchestrates running of both frontend and backend services as well as database and Redis containers.
- The presence of Dockerfiles in both frontend and backend further confirms the containerized deployment setup.

##### Key Components
- Frontend Client:
- Represented by the Vue.js application.
- Includes sub-modules like components (admin, candidate, employer, common), views, router, and global state management (Vuex).
- Backend API:
- Represented by the Node.js/Express server.
- Break this into sub-components:
▪ Controllers – handling HTTP request logic.
▪ Services – encapsulating business logic.
▪ Routes – defining API endpoints.
▪ Middlewares – for authentication (JWT, OTP verification), validation, and error handling.
▪ Models and Migrations – defining the database schema and data operations via Sequelize.
- Utility libraries (sending emails, generating OTPs, password hashing, etc.) supporting various operations.
- Database:
- A SQL database (MySQL/PostgreSQL) that is managed via Sequelize.
- External & Supporting Services:
- Redis: For temporary data storage such as OTPs and token management.
- Cloudinary: For handling file uploads (images, PDFs) when applicable.
- Email Service (ex: Gmail): For sending OTP emails and password reset links.
- Docker & Infrastructure:
- Docker containers for each service.
- Docker Compose as the orchestrator to connect backend, frontend, database, and Redis.

##### Details on Relationships and Interactions
- How the Frontend communicates with the Backend via API calls (using Axios).
- How Backend controllers invoke services and interact with the database using models.
- Middleware processes that occur before and after API calls (authentication, validation, error handling).

##### Emphasizing Architectural Patterns and Technologies
- MVC pattern used within the backend (Controllers, Models, Services).
- Layered architecture with separate concerns (routing, business logic, data access).
- Differences in responsibilities in client vs. server sides.
- Use of containerization and orchestration using Docker and Docker Compose.
- Technologies (Node.js, Express, Sequelize, Vue.js, Vue Router, Vuex/Pinia, Docker, Redis, MySQL/PostgreSQL, Cloudinary, JWT, and nodemailer).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Docker & Orchestration
    DC("Docker Compose Setup"):::container

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE_Client("Frontend (Vue.js)"):::frontend
        FE_Components("Components"):::frontendComp
        FE_Views("Views"):::frontendComp
        FE_Router("Router"):::frontendComp
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE_API("Backend API"):::backendApi
        BE_Controllers("Controllers"):::backendComp
        BE_Services("Services"):::backendComp
        BE_Routes("Routes"):::backendComp
        BE_Middlewares("Middlewares"):::backendComp
        BE_Models("Models/Migrations"):::backendComp
        BE_Libs("Utility Libraries"):::backendComp
    end

    %% External Services
    subgraph "External Services"
        DB("Database (SQL)"):::external
        Redis("Redis"):::external
        Cloud("Cloudinary"):::external
        PDF("Upload PDF"):::external
        Email("Email Service"):::external
    end

    %% Containerization Files
    subgraph "Containerization"
        BE_Docker("Backend Dockerfile"):::container
        FE_Docker("Frontend Dockerfile"):::container
    end

    %% Connections between Docker Compose and Components
    DC --> FE_Client
    DC --> BE_API
    DC --> DB
    DC --> Redis

    %% Frontend to Backend Communication
    FE_Client -->|"APIcalls"| BE_API

    %% Backend Internal Flow
    BE_API -->|"calls"| BE_Controllers
    BE_Controllers -->|"invokes"| BE_Services
    BE_Services -->|"operatesOn"| BE_Models
    BE_API --> BE_Routes
    BE_API --> BE_Middlewares
    BE_API --> BE_Libs

    %% Backend Services interacting with External Services
    BE_Services -->|"DB"| DB
    BE_Services -->|"Cache"| Redis
    BE_Services -->|"Uploads"| Cloud
    BE_Services -->|"Emails"| Email

    %% Linking Docker files to corresponding components
    BE_API --> BE_Docker
    FE_Client --> FE_Docker

    %% Click Events for Frontend Components
    click FE_Client "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/frontend/"
    click FE_Components "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/frontend/src/components/"
    click FE_Views "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/frontend/src/views/"
    click FE_Router "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/frontend/src/router/index.js"

    %% Click Events for Backend Components
    click BE_API "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/"
    click BE_Controllers "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/controllers/"
    click BE_Services "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/services/"
    click BE_Routes "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/routes/"
    click BE_Middlewares "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/middlewares/"
    click BE_Models "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/models/"
    click BE_Libs "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/src/libs/"

    %% Click Events for External Service Configurations
    click Cloud "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/backend/src/config/cloudinary.config.js"
    click DB "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/backend/src/config/db.config.js"
    click Redis "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/backend/src/config/redis.config.js"
    click PDF "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/backend/src/config/uploadpdf.config.js"
    click Email "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/backend/src/libs/sendMail.js"

    %% Click Events for Containerization Files
    click BE_Docker "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/backend/Dockerfile"
    click DC "https://github.com/khoa-cntt/xdwdttdt2164/blob/main/backend/docker-compose.yml"
    click FE_Docker "https://github.com/khoa-cntt/xdwdttdt2164/tree/main/frontend/Dockerfile"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef frontendComp fill:#B0E0E6,stroke:#00008B,stroke-width:2px;
    classDef backendApi fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef backendComp fill:#98FB98,stroke:#006400,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef container fill:#DA70D6,stroke:#9400D3,stroke-width:2px;
```
