# aggink/study architecture

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

- Interactive diagram: https://gitdiagram.com/aggink/study
- Repository: https://github.com/aggink/study

## Overview

##### Project Type and Purpose
- This is a multi-project .NET solution combining:
- Core utility libraries (CoreLib.Common, CoreLib.Utilities).
- Three lab applications:
– Lab 1 & Lab 2: Console-style apps executing student “IRunService” tasks.
– Lab 3: A web API (ASP.NET Core) implementing CRUD over a database (Clean Architecture + Feature folders + MediatR).

##### File Structure
- Top-level executables:
- Study.Lab1/Program.cs (console runner).
- Study.Lab2/Program.cs (console runner).
- Study.Lab3.Web (ASP.NET Core Web API).
- Library layers per lab:
- `.Logic.Interfaces` – contracts/interfaces.
- `.Logic` – implementations of services.
- `.Logic.UnitTests` – unit-test assemblies.
- Infrastructure for Lab 3:
- Study.Lab3.Storage – EF Core models & DbContext.
- Study.Lab3.Storage.MS_SQL & …PostgreSQL – migrations & context factories.
- Cross-cutting utilities:
- CoreLib.Common (exceptions, shared utilities).
- CoreLib.Utilities (Excel processing, extensions).

##### Architectural Patterns
- Lab 1 & 2: plugin pattern via IRunService in Program.cs → selects student service by group/number.
- Lab 3:
- Clean Architecture layering:
– Presentation (Web) → Application (Logic + Interfaces) → Infrastructure (Storage).
- Using Features (Controllers/Queries/Commands grouped by feature).
- MediatR for command/query dispatch.
- EF Core Code-First migrations for database schema.

##### Main Components & Their Relationships

A. Core Libraries (shared)
– CoreLib.Common
– CoreLib.Utilities.Interfaces
– CoreLib.Utilities
– (UnitTest projects)

B. Lab 1 Application (Console)
– Study.Lab1 (Program)
– Study.Lab1.Logic.Interfaces → Study.Lab1.Logic → Study.Lab1.Logic.UnitTests
↘ Console IRunService lookup → student services
↖ Depends on CoreLib utilities.

C. Lab 2 Application (Console)
– Study.Lab2 (Program)
– Study.Lab2.Logic.Interfaces → Study.Lab2.Logic → Study.Lab2.Logic.UnitTests
↘ HTTP-request services (IRequestService, IResponseProcessor, IServerRequestService)
↖ Depends on CoreLib.

D. Lab 3 Web API
– Study.Lab3.Web (Controllers, Feature folders, Middleware)
– Study.Lab3.Logic.Interfaces → Study.Lab3.Logic (Services, Extensions)
– Study.Lab3.Storage (Models, DbContext, Constants)
– Study.Lab3.Storage.MS_SQL & …PostgreSQL (Migrations, ContextFactory)
– Underlying Databases: Microsoft SQL Server, PostgreSQL
Flow:
Controllers → MediatR → Logic Services → DbContext → Database
Unit tests (none for Web by default).

E. External/Infrastructure
– Databases (SQL Server, PostgreSQL)
– Docker Compose (to bring up DBs, Web API)
– GitHub Actions CI/CD (build-and-test workflows)

##### Architectural Patterns & Principles
- Dependency Inversion: each “Logic” layer depends on interfaces (Logic.Interfaces).
- Single Responsibility: each project has one role (API, Business Logic, Storage).
- Clean Architecture + Feature grouping (Lab 3 Web).
- Plugin/Strategy pattern for IRunService in Labs 1 & 2.

##### Technology Stack Highlights
- .NET 6+ (csproj across projects)
- EF Core (Code-First, Migrations)
- MediatR (CQRS)
- ASP.NET Core Web API
- xUnit/NUnit (unit test projects)
- GitHub Actions (CI)
- Docker Compose (local dev infra)

##### Essential Elements
- Component names & responsibilities
- Interfaces vs. implementations
- External dependencies (databases, CI/CD, Docker)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Libraries
    subgraph "Core Libraries"
        COMMON["CoreLib.Common"]:::lib
        UTIL_IF["CoreLib.Utilities.Interfaces"]:::lib
        UTIL["CoreLib.Utilities"]:::lib
    end

    %% Lab 1
    subgraph "Lab 1 Console App"
        L1_PROG["Study.Lab1 (Program)"]:::exe
        L1_IF["Study.Lab1.Logic.Interfaces"]:::lib
        L1_LOGIC["Study.Lab1.Logic"]:::lib
        L1_TEST["Study.Lab1.Logic.UnitTests"]:::lib
    end

    %% Lab 2
    subgraph "Lab 2 Console App"
        L2_PROG["Study.Lab2 (Program)"]:::exe
        L2_IF["Study.Lab2.Logic.Interfaces"]:::lib
        L2_LOGIC["Study.Lab2.Logic"]:::lib
        L2_TEST["Study.Lab2.Logic.UnitTests"]:::lib
    end

    %% Lab 3 Web API
    subgraph "Lab 3 Web API"
        L3_WEB["Study.Lab3.Web"]:::exe
        L3_IF["Study.Lab3.Logic.Interfaces"]:::lib
        L3_LOGIC["Study.Lab3.Logic"]:::lib
        subgraph "Storage Layer"
            L3_STORAGE["Study.Lab3.Storage"]:::lib
            L3_SQL["Study.Lab3.Storage.MS_SQL"]:::infra
            L3_PG["Study.Lab3.Storage.PostgreSQL"]:::infra
        end
        SQLDB[(SQL Server)]:::infra
        PGDB[(PostgreSQL)]:::infra
    end

    %% Infrastructure
    DOCKER["Docker Compose"]:::infra
    CI["GitHub Actions CI/CD"]:::infra

    %% Dependencies Core to Labs
    COMMON -->|depends| L1_PROG
    UTIL_IF -->|depends| L1_PROG
    UTIL -->|depends| L1_PROG

    COMMON -->|depends| L2_PROG
    UTIL_IF -->|depends| L2_PROG
    UTIL -->|depends| L2_PROG

    COMMON -->|depends| L3_WEB
    UTIL_IF -->|depends| L3_WEB
    UTIL -->|depends| L3_WEB

    %% Lab 1 Flow
    L1_PROG -->|"uses IRunService"| L1_IF
    L1_IF -->|"implements"| L1_LOGIC
    L1_LOGIC -->|"tested by"| L1_TEST

    %% Lab 2 Flow
    L2_PROG -->|"uses IRunService, IRequestService"| L2_IF
    L2_IF -->|"implements"| L2_LOGIC
    L2_LOGIC -->|"tested by"| L2_TEST

    %% Lab 3 Flow
    L3_WEB -->|"uses APIs"| L3_IF
    L3_IF -->|"implements"| L3_LOGIC
    L3_LOGIC -->|"EF Core context"| L3_STORAGE
    L3_SQL -->|"migrations"| L3_STORAGE
    L3_PG -->|"migrations"| L3_STORAGE
    L3_STORAGE -->|connects| SQLDB
    L3_STORAGE -->|connects| PGDB

    %% Infra connections
    DOCKER -->|orchestrates| SQLDB
    DOCKER -->|orchestrates| PGDB
    DOCKER -->|orchestrates| L3_WEB
    CI -->|builds/tests| L1_PROG
    CI -->|builds/tests| L2_PROG
    CI -->|builds/tests| L3_WEB

    %% Click Events
    click COMMON "https://github.com/aggink/study/blob/master/CoreLib.Common/CoreLib.Common.csproj"
    click COMMON "https://github.com/aggink/study/blob/master/CoreLib.Common/Extensions/BusinessLogicException.cs"
    click UTIL_IF "https://github.com/aggink/study/blob/master/CoreLib.Utilities.Interfaces/CoreLib.Utilities.Interfaces.csproj"
    click UTIL_IF "https://github.com/aggink/study/blob/master/CoreLib.Utilities.Interfaces/DtoModels/Services/WorksheetDto.cs"
    click UTIL_IF "https://github.com/aggink/study/blob/master/CoreLib.Utilities.Interfaces/Services/IExcelDataProcessorService.cs"
    click UTIL_IF "https://github.com/aggink/study/blob/master/CoreLib.Utilities.Interfaces/Services/IWorksheetReaderService.cs"
    click UTIL "https://github.com/aggink/study/blob/master/CoreLib.Utilities/CoreLib.Utilities.csproj"
    click UTIL "https://github.com/aggink/study/blob/master/CoreLib.Utilities/Extensions/StringExtensions.cs"
    click UTIL "https://github.com/aggink/study/blob/master/CoreLib.Utilities/Services/ExcelDataProcessorService.cs"
    click UTIL "https://github.com/aggink/study/blob/master/CoreLib.Utilities/Services/WorksheetReaderService.cs"
    click L1_PROG "https://github.com/aggink/study/blob/master/Study.Lab1/Program.cs"
    click L1_PROG "https://github.com/aggink/study/blob/master/Study.Lab1/Study.Lab1.csproj"
    click L1_IF "https://github.com/aggink/study/blob/master/Study.Lab1.Logic.Interfaces/Study.Lab1.Logic.Interfaces.csproj"
    click L1_IF "https://github.com/aggink/study/blob/master/Study.Lab1.Logic.Interfaces/IRunService.cs"
    click L1_LOGIC "https://github.com/aggink/study/blob/master/Study.Lab1.Logic/Study.Lab1.Logic.csproj"
    click L1_TEST "https://github.com/aggink/study/blob/master/Study.Lab1.Logic.UnitTests/Study.Lab1.Logic.UnitTests.csproj"
    click L2_PROG "https://github.com/aggink/study/blob/master/Study.Lab2/Program.cs"
    click L2_PROG "https://github.com/aggink/study/blob/master/Study.Lab2/Study.Lab2.csproj"
    click L2_IF "https://github.com/aggink/study/blob/master/Study.Lab2.Logic.Interfaces/Study.Lab2.Logic.Interfaces.csproj"
    click L2_IF "https://github.com/aggink/study/blob/master/Study.Lab2.Logic.Interfaces/IRunService.cs"
    click L2_LOGIC "https://github.com/aggink/study/blob/master/Study.Lab2.Logic/Study.Lab2.Logic.csproj"
    click L2_TEST "https://github.com/aggink/study/blob/master/Study.Lab2.Logic.UnitTests/Study.Lab2.Logic.UnitTests.csproj"
    click L3_WEB "https://github.com/aggink/study/blob/master/Study.Lab3.Web/Program.cs"
    click L3_WEB "https://github.com/aggink/study/blob/master/Study.Lab3.Web/Study.Lab3.Web.csproj"
    click L3_IF "https://github.com/aggink/study/blob/master/Study.Lab3.Logic.Interfaces/Study.Lab3.Logic.Interfaces.csproj"
    click L3_LOGIC "https://github.com/aggink/study/blob/master/Study.Lab3.Logic/Study.Lab3.Logic.csproj"
    click L3_STORAGE "https://github.com/aggink/study/blob/master/Study.Lab3.Storage/Study.Lab3.Storage.csproj"
    click L3_STORAGE "https://github.com/aggink/study/blob/master/Study.Lab3.Storage/Database/DataContext.cs"
    click L3_STORAGE "https://github.com/aggink/study/blob/master/Study.Lab3.Storage/Models/University/Announcement.cs"
    click L3_STORAGE "https://github.com/aggink/study/blob/master/Study.Lab3.Storage/Constants/ModelConstants.cs"
    click L3_SQL "https://github.com/aggink/study/blob/master/Study.Lab3.Storage.MS_SQL/Study.Lab3.Storage.MS_SQL.csproj"
    click L3_SQL "https://github.com/aggink/study/blob/master/Study.Lab3.Storage.MS_SQL/MicrosoftSqlContextFactory.cs"
    click L3_PG "https://github.com/aggink/study/blob/master/Study.Lab3.Storage.PostgreSQL/Study.Lab3.Storage.PostgreSQL.csproj"
    click DOCKER "https://github.com/aggink/study/blob/master/docker-compose.yml"
    click CI "https://github.com/aggink/study/blob/master/.github/workflows/build-and-test.yml"
    click CI "https://github.com/aggink/study/blob/master/.github/workflows/branch-name-check.yml"

    %% Styles
    classDef exe fill:#D0E7FF,stroke:#0366D6,stroke-width:2px
    classDef lib fill:#E6FFE6,stroke:#228B22,stroke-width:2px
    classDef infra fill:#FFF4E6,stroke:#FF8C00,stroke-width:2px
```
