# dlgkiet/soa_final architecture

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

- Interactive diagram: https://gitdiagram.com/dlgkiet/soa_final
- Repository: https://github.com/dlgkiet/soa_final

## Overview

Based on your provided file tree and README, this project is an online course management system that follows a Layered Architecture design. It uses a .NET Core backend (with ASP.NET Core, Entity Framework Core, and JWT authentication), a React + TypeScript frontend, and a PostgreSQL database. The project is split into distinct layers—Presentation, Service, Data Access, and Core—which are clearly represented in both the file structure and the README.

##### Main Components
- Frontend (Presentation Layer): Represented by the "frontend" folder that contains the React application. It handles UI, routing, and API calls.
- API/Backend (Presentation Layer for API): Contained in the "API" folder with controllers (e.g., AnswerController, AuthController) that receive incoming HTTP requests.
- Service Layer: Located in the "Service" folder and its associated interfaces & implementations. This layer processes business logic and acts as a bridge between the API/controllers and data layers.
- Data Access Layer: Found in the "DataAccess" directory. It encapsulates the database context (using PostgreSQL via Npgsql) and repository implementations (e.g., AnswerRepository, CourseRepository) as per the layered design.
- Core Layer: Contained in the "Core" directory. This holds the fundamental entities and models (like Admin, Answer, Course, etc.) used across the application.

##### Relationships and Interactions
- The Frontend (React) calls the API endpoints exposed by the backend controllers.
- The API layer passes requests to the Service Layer, which contains core business logic.
- The Service Layer interacts with the Data Access Layer, which in turn interacts with the PostgreSQL database using Entity Framework Core.
- The Core Layer is used across layers for shared entities and validation models.
- Incorporate external services like JWT Authentication and potential Docker containerization for deployment.

##### Architectural Patterns & Technologies
- Layered Architecture: Show clearly how each layer (Presentation → Service → Data Access → Core) is separated.
- MVC or RESTful design in API Controllers.
- Use of specific technologies:
- ASP.NET Core for the backend API.
- Entity Framework Core for data management.
- JWT for authentication.
- React, TypeScript, TailwindCSS for the frontend UI.
- PostgreSQL as the main database.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User/Client"]:::external

    %% Frontend Section
    FE["React Frontend\n(React, TypeScript, TailwindCSS)"]:::frontend

    %% Backend Layers Subgraph
    subgraph "Backend Architecture"
        API["API Controllers\n(ASP.NET Core, JWT)"]:::backend
        SV["Service Layer\n(Business Logic)"]:::service
        BUS["Business Layer\n(Services & Validators)"]:::business
        DA["Data Access Layer\n(Entity Framework Core)"]:::data
    end

    %% Core Layer (Shared across backend)
    CORE["Core Layer\n(Entities & Models)"]:::core

    %% Database
    DB["PostgreSQL Database"]:::database

    %% Data Flow
    User -->|"interacts"| FE
    FE -->|"calls"| API
    API -->|"delegates"| SV
    SV -->|"invokes"| BUS
    SV -->|"processes"| DA
    DA -->|"communicates"| DB

    %% Core Layer interactions
    API ---|"uses"| CORE
    SV ---|"uses"| CORE
    DA ---|"uses"| CORE

    %% Click Events
    click FE "https://github.com/dlgkiet/soa_final/tree/main/frontend/"
    click API "https://github.com/dlgkiet/soa_final/tree/main/API/"
    click SV "https://github.com/dlgkiet/soa_final/tree/main/Service/"
    click DA "https://github.com/dlgkiet/soa_final/tree/main/DataAccess/"
    click CORE "https://github.com/dlgkiet/soa_final/tree/main/Core/"
    click BUS "https://github.com/dlgkiet/soa_final/tree/main/Business/"
    click DB "https://github.com/dlgkiet/soa_final/blob/main/DataAccess/Context/ApplicationDbContext.cs"

    %% Class Definitions for Colors
    classDef external fill:#ffdddd,stroke:#880000,stroke-width:2px;
    classDef frontend fill:#ddffdd,stroke:#006600,stroke-width:2px;
    classDef backend fill:#ddddff,stroke:#000088,stroke-width:2px;
    classDef service fill:#ffffdd,stroke:#888800,stroke-width:2px;
    classDef business fill:#ffeedd,stroke:#884400,stroke-width:2px;
    classDef data fill:#ddffff,stroke:#008888,stroke-width:2px;
    classDef database fill:#ffddff,stroke:#880088,stroke-width:2px;
    classDef core fill:#eeeeee,stroke:#666666,stroke-width:2px;
```
