# abuki43/blogwebsitebackend architecture

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

- Interactive diagram: https://gitdiagram.com/abuki43/blogwebsitebackend
- Repository: https://github.com/abuki43/blogwebsitebackend

## Overview

##### Main Components
- API Endpoints: Group the different endpoints into logical categories (Articles, Authentication, Comments, Profiles) as they are implemented in the Endpoints folder.
- Data Access Layer: Reflect the Models and Dtos used to represent domain objects and data transfers. Also, include the use of Entity Framework Core and the SQLite database.
- Services: Show the JwtService and any other business logic that interacts with the endpoints.
- Configuration: Include appsettings.json files and the Program.cs bootstrap which links all components.
- External Interfaces: Incorporate the REST testing interface (using the request.http file) and the API documentation (api-documentation.md) as external artifacts that assist in development and troubleshooting.

##### Relationships and Interactions
- The JWT Authentication flow should be highlighted to illustrate how the AuthEndpoints utilize JwtService.
- Flow from endpoints to the database via Entity Framework Core – annotate with migration processes when showing schema evolution.
- Make clear the separation of concerns: routes handling HTTP requests vs. services performing token validation and business logic vs. data models handling persistence.

##### Architectural Patterns & Design Principles
- That the project follows a layered architecture pattern (API layer, Service/Business layer, Data layer).
- Separation between controllers (Endpoints) and service logic.
- If applicable, add notes on the MVC style present in ASP.NET Core and how models and DTOs differ: Models represent the database entities, and DTOs facilitate communication via the API.
- Mention dependency injection – typically seen in ASP.NET Core for services like JwtService.

##### Technologies, Frameworks, and Libraries
- ASP.NET Core 8.0, which powers the entire application.
- Entity Framework Core as the ORM managing interactions with SQLite.
- SQLite as the chosen database.
- JWT for authentication.
- REST Client integration (via the request.http file) as a testing tool.
- Use of configuration files (appsettings.Development.json and appsettings.json) which influence how the system is started.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Interfaces
    Client["HTTP Client"]:::external
    subgraph "External Interfaces"
        REST_Testing["REST Testing (request.http)"]:::external
        API_Docs["API Documentation (api-documentation.md)"]:::external
    end

    %% Configuration Layer
    subgraph "Configuration Layer"
        Program["Program.cs & Settings"]:::config
    end

    %% API Endpoints
    subgraph "API Endpoints"
        AuthEndpoints["Authentication Endpoints"]:::endpoint
        ArticlesEndpoints["Article Management Endpoints"]:::endpoint
        CommentsEndpoints["Comment Endpoints"]:::endpoint
        ProfilesEndpoints["Profile Endpoints"]:::endpoint
    end

    %% Service Layer
    subgraph "Service Layer"
        JwtService["JwtService"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        EFCore["Entity Framework Core Integration"]:::dataAccess
        Migrations["Migrations"]:::dataAccess
    end

    %% Data Layer
    subgraph "Data Layer"
        Models["Domain Models"]:::data
        DTOs["Data Transfer Objects"]:::data
    end

    %% Database
    Database["SQLite Database (medium.db)"]:::database

    %% Relationships
    Client -->|"sends HTTP request"| AuthEndpoints
    Client -->|"sends HTTP request"| ArticlesEndpoints
    Client -->|"sends HTTP request"| CommentsEndpoints
    Client -->|"sends HTTP request"| ProfilesEndpoints

    REST_Testing -->|"tests APIs"| Program
    API_Docs -->|"documents APIs"| Program

    Program -->|"initializes"| AuthEndpoints
    Program -->|"initializes"| ArticlesEndpoints
    Program -->|"initializes"| CommentsEndpoints
    Program -->|"initializes"| ProfilesEndpoints
    Program -->|"configures"| JwtService
    Program -->|"configures"| EFCore

    AuthEndpoints -->|"calls"| JwtService
    AuthEndpoints -->|"accesses"| EFCore
    ArticlesEndpoints -->|"accesses"| EFCore
    CommentsEndpoints -->|"accesses"| EFCore
    ProfilesEndpoints -->|"accesses"| EFCore

    EFCore -->|"manages"| Models
    EFCore -->|"manages"| DTOs
    EFCore -->|"reads/writes"| Database
    EFCore -->|"applies schema"| Migrations

    JwtService -->|"verifies tokens"| Models

    %% Class Styles
    classDef endpoint fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef service fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef dataAccess fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef data fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef config fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef database fill:#c3e6cb,stroke:#155724,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click ArticlesEndpoints "https://github.com/abuki43/blogwebsitebackend/blob/main/Endpoints/ArticleEndpoints.cs"
    click AuthEndpoints "https://github.com/abuki43/blogwebsitebackend/blob/main/Endpoints/AuthEndpoints.cs"
    click CommentsEndpoints "https://github.com/abuki43/blogwebsitebackend/blob/main/Endpoints/CommentEndpoints.cs"
    click ProfilesEndpoints "https://github.com/abuki43/blogwebsitebackend/blob/main/Endpoints/ProfileEndpoints.cs"
    click EFCore "https://github.com/abuki43/blogwebsitebackend/blob/main/Data/MediumContext.cs"
    click Migrations "https://github.com/abuki43/blogwebsitebackend/tree/main/Migrations/"
    click Models "https://github.com/abuki43/blogwebsitebackend/tree/main/Models/"
    click DTOs "https://github.com/abuki43/blogwebsitebackend/tree/main/Dtos/"
    click JwtService "https://github.com/abuki43/blogwebsitebackend/blob/main/Services/JwtService.cs"
    click Database "https://github.com/abuki43/blogwebsitebackend/blob/main/medium.db"
    click Program "https://github.com/abuki43/blogwebsitebackend/blob/main/Program.cs"
    click REST_Testing "https://github.com/abuki43/blogwebsitebackend/blob/main/request.http"
    click API_Docs "https://github.com/abuki43/blogwebsitebackend/blob/main/api-documentation.md"
```
