# pandugaluh/mini-project architecture

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

- Interactive diagram: https://gitdiagram.com/pandugaluh/mini-project
- Repository: https://github.com/pandugaluh/mini-project

## Overview

##### Main Components
- API Layer: For each service (Project.Service.Course.Api and Project.Service.User.Api), show components such as Controllers and the Program entry point. Label these clearly, as they expose endpoints for handling HTTP requests.
- Domain Layer: Represent the core domain entities and common elements (BaseEntity, Entities like EntityUser, EntityCourse, etc.). This layer encapsulates the domain logic and definitions.
- Infrastructure and Persistence Layers: Include the components managing external concerns—data storage (SQL Server), Kafka consumers and producers, EF Core migrations in the Course Project, and Dapper based database operations in the User Project. Separate these into Infrastructure (for event messaging or other integrations) and Persistence (for data context, repositories, and migrations).

##### Interactions and Relationships
- That Application components interact with Domain entities (to apply business rules) and with Persistence interfaces to handle database operations.
- Connections to SQL Server for both projects, noting that the Course project uses Entity Framework migrations and the User project uses Dapper with a database-first approach.

##### Architectural Patterns and Design Principles
- Microservices: Since there are two distinct services (User and Course), represent them as two separate modules/microservices that communicate indirectly via Kafka. This separation helps in understanding service boundaries and responsibilities.

##### Relevant Technologies and Frameworks
- API layer with .NET 6 and mention that Swagger documentation is auto-generated.
- In the Application layer, note the use of MediatR for the CQRS pattern in the User service.
- Point out the use of either Entity Framework (Course service for migrations) or Dapper (User service for Database-First operations) in the Persistence layer.
- Kafka components: a Producer (in the User project) and a Consumer (in the Course project) that handle event-driven integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services
    Kafka["Kafka"]:::external
    SQLServer["SQL Server"]:::external

    %% Course Management Service
    subgraph "Course Management Service"
        cAPI["Course API Layer (.NET6, Swagger)"]:::api
        cAPICont["Course API Controllers"]:::api
        cApp["Course Application Layer"]:::app
        cDomain["Course Domain Layer"]:::domain
        cInfra["Course Infrastructure Layer (Kafka Consumer)"]:::infra
        cPers["Course Persistence Layer (EF Core)"]:::pers
        cTest["Course Testing (Xunit)"]:::test
    end

    %% User Management Service
    subgraph "User Management Service"
        uAPI["User API Layer (.NET6, Swagger)"]:::api
        uAPICont["User API Controllers"]:::api
        uApp["User Application Layer (CQRS, MediatR)"]:::app
        uDomain["User Domain Layer"]:::domain
        uInfra["User Infrastructure Layer (Kafka Producer)"]:::infra
        uPers["User Persistence Layer (Dapper)"]:::pers
        uDB["User Database (Database-First)"]:::pers
        uTest["User Testing (Xunit)"]:::test
    end

    %% Course Service Flow
    cAPI -->|"calls"| cAPICont
    cAPICont -->|"invokes"| cApp
    cApp -->|"uses"| cDomain
    cApp -->|"calls"| cPers
    cPers -->|"EF-migrations"| SQLServer
    Kafka -->|"delivers event"| cInfra
    cTest ---|"tests"| cAPICont

    %% User Service Flow
    uAPI -->|"calls"| uAPICont
    uAPICont -->|"invokes"| uApp
    uApp -->|"uses"| uDomain
    uApp -->|"calls"| uPers
    uPers -->|"Dapper"| uDB
    uApp -->|"triggers"| uInfra
    uInfra -->|"publishes event"| Kafka
    uTest ---|"tests"| uAPICont

    %% Click Events for Course Service
    click cAPI "https://github.com/pandugaluh/mini-project/blob/main/service-course/src/Project.Service.Course.Api"
    click cAPICont "https://github.com/pandugaluh/mini-project/tree/main/service-course/src/Project.Service.Course.Api/Controllers"
    click cApp "https://github.com/pandugaluh/mini-project/blob/main/service-course/src/Project.Service.Course.Application"
    click cDomain "https://github.com/pandugaluh/mini-project/blob/main/service-course/src/Project.Service.Course.Domain"
    click cInfra "https://github.com/pandugaluh/mini-project/blob/main/service-course/src/Project.Service.Course.Infrastructure"
    click cPers "https://github.com/pandugaluh/mini-project/blob/main/service-course/src/Project.Service.Course.Persistance"
    click cTest "https://github.com/pandugaluh/mini-project/blob/main/service-course/test/Project.Service.Course.Test"

    %% Click Events for User Service
    click uAPI "https://github.com/pandugaluh/mini-project/blob/main/service-user/src/Project.Service.User.Api"
    click uAPICont "https://github.com/pandugaluh/mini-project/tree/main/service-user/src/Project.Service.User.Api/Controllers"
    click uApp "https://github.com/pandugaluh/mini-project/blob/main/service-user/src/Project.Service.User.Application"
    click uDomain "https://github.com/pandugaluh/mini-project/blob/main/service-user/src/Project.Service.User.Domain"
    click uInfra "https://github.com/pandugaluh/mini-project/blob/main/service-user/src/Project.Service.User.Infrastructure"
    click uPers "https://github.com/pandugaluh/mini-project/blob/main/service-user/src/Project.Service.User.Persistance"
    click uDB "https://github.com/pandugaluh/mini-project/blob/main/service-user/src/Project.Service.User.Database"
    click uTest "https://github.com/pandugaluh/mini-project/blob/main/service-user/test/Project.Service.User.Test"

    %% Styles
    classDef api fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef app fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef domain fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef infra fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef pers fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef test fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#fefefe,stroke:#343a40,stroke-width:2px,stroke-dasharray: 5 5,fontStyle:italic;
```
