# phantrang2002/worknest architecture

> Architecture diagram of the GitHub repository phantrang2002/worknest, 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/phantrang2002/worknest
- Repository: https://github.com/phantrang2002/worknest

## Overview

##### Main Components
- Frontend: Built using Next.js (React) with TailwindCSS. This includes pages, layouts, components, and API service clients that the user interacts with.
- Backend API: Developed in ASP.NET Core Web API. This layer contains Controllers (for handling HTTP requests), Data (using ApplicationDBContext, migrations for database schema), Dtos (data transfer objects for request/response), Models (domain entities), and Services (business logic such as token generation).
- Database: A MSSQL database that is set up using the provided WorkNest-db-script.sql. This holds all user accounts, job postings, applications, policies, and more.
- Static Assets: Under the API’s wwwroot folder, which includes images and sample CV templates (PDFs and DOCs) that are served as static files.

##### Relationships and Data Flow
- API Server to Database: Illustrate the connection where the ASP.NET Core backend accesses data using Entity Framework (ApplicationDBContext) and applies migrations.
- API Server Static Assets: Demonstrate that the API also serves static files (sample CV templates/images) through its wwwroot folder.
- Internal Services: Within the API, represent how Controllers use Services (e.g., TokenService) and work with Dtos and Models for business logic and data transformation.

##### Architectural Patterns and Principles
- Separation of Concerns: Frontend and backend are clearly separated. Within the backend, the code is modularized into Controllers, Dtos, Models, and Services.
- RESTful API Design: Highlight how the controllers (e.g., AccountController, JobPostingController) expose endpoints corresponding to the features detailed in the README (user registration, job posting, feedback submission, etc.).
- Layered Architecture: Indicate how the system layers (Presentation → Business Logic → Data Access) are implemented through separate directories/files.

##### Technologies and Frameworks
- Frontend: Next.js (React), TailwindCSS.
- Backend: ASP.NET Core Web API (version 8), Entity Framework Core (for database operations), MSSQL Server.
- Additional: The API also uses token-based authentication via the TokenService and likely employs DTOs for data sanitization and communication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        FE["Frontend (Next.js Client)"]:::frontend
    end

    subgraph "Backend API Layer"
        CTLS["API Controllers (ASP.NET Core Web API)"]:::backend
        BSVC["Business Services (Token Service)"]:::backend
        DTO["DTOs"]:::backend
        MODELS["Domain Models"]:::backend
        DAL["Data Access (ApplicationDBContext)"]:::backend
        STATIC["Static Assets (wwwroot)"]:::static
    end

    subgraph "Database Layer"
        DB["MSSQL Database"]:::database
    end

    FE -->|"RESTfulCalls"| CTLS
    CTLS -->|"calls"| BSVC
    BSVC -->|"transformsData"| DTO
    BSVC -->|"handles"| MODELS
    BSVC -->|"usesEFCore"| DAL
    DAL -->|"queriesInserts"| DB
    CTLS -->|"serves"| STATIC

    click FE "https://github.com/phantrang2002/worknest/tree/main/frontend"
    click CTLS "https://github.com/phantrang2002/worknest/tree/main/api/Controllers"
    click BSVC "https://github.com/phantrang2002/worknest/blob/main/api/Services/TokenService.cs"
    click DTO "https://github.com/phantrang2002/worknest/tree/main/api/Dtos"
    click MODELS "https://github.com/phantrang2002/worknest/tree/main/api/Models"
    click DAL "https://github.com/phantrang2002/worknest/blob/main/api/Data/ApplicationDBContext.cs"
    click DB "https://github.com/phantrang2002/worknest/blob/main/WorkNest-db-script.sql"
    click STATIC "https://github.com/phantrang2002/worknest/tree/main/api/wwwroot"

    classDef frontend fill:#bbf,stroke:#003366,stroke-width:2px;
    classDef backend fill:#b3e6b3,stroke:#006600,stroke-width:2px;
    classDef database fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef static fill:#fff2cc,stroke:#cc9900,stroke-width:2px;
```
