# quentinious/csharp-labs architecture

> Architecture diagram of the GitHub repository quentinious/csharp-labs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/quentinious/csharp-labs
- Repository: https://github.com/quentinious/csharp-labs

## Overview

This is a C# console simulator for a 100-day, six-subject semester: it models attendance choices, teacher questioning, expulsion, and pleasure scores. The current runtime also creates semesters, resumes them by UUID, and lists saved semesters; persistent runs save progress in PostgreSQL. The main path is console command → simulation worker/session → day engine → stored or printed result. The graph preserves the strategy, teacher-rule, random-source, and semester-persistence layers. Some worker and command wiring is supported only by the source index; unsampled details are not inferred.

Main entry points: [`Csharp/DaySimulationEngine.cs`](https://github.com/quentinious/csharp-labs/blob/master/Csharp/DaySimulationEngine.cs) (Day engine), [`Csharp/Program.cs`](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Program.cs) (Command entry), [`Csharp/SemesterSession.cs`](https://github.com/quentinious/csharp-labs/blob/master/Csharp/SemesterSession.cs) (Semester session), [`Csharp/Persistence/SemesterRepository.cs`](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/SemesterRepository.cs) (Semester repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Console entry"]
  node_program["Command entry<br/>[Program.cs]"]
  node_console_runner["Console runner"]
  node_simulation_worker["Simulation worker"]
  node_persistent_worker["Persistent worker"]
  node_keyboard["Stop handling"]
end

subgraph group_simulation["Semester simulation"]
  node_session["Semester session<br/>[SemesterSession.cs]"]
  node_engine["Day engine"]
  node_sim_service["Simulation service"]
  node_persistent_service["Persistent service"]
  node_simulator["Semester simulator"]
  node_day_result["Day results<br/>[DayResult.cs]"]
  node_lesson_result["Lesson results<br/>[LessonResult.cs]"]
end

subgraph group_domain["Rules and strategy"]
  node_teacher_factory["Teacher factory<br/>[TeacherFactory.cs]"]
  node_teacher["Questioning rules<br/>[Teacher.cs]"]
  node_strategy["Attendance strategy<br/>[StudentStrategy.cs]"]
  node_history["Student history<br/>[StudentHistory.cs]"]
  node_contracts["Strategy contracts"]
  node_random["Stateful randomness"]
end

subgraph group_persistence["Persistence"]
  node_state["Semester state<br/>[SemesterState.cs]"]
  node_repository["Semester repository"]
  node_repo_contract["Repository contract"]
end

node_user(("Operator"))
node_postgres[("PostgreSQL")]

node_user -->|"runs commands"| node_program
node_program -->|"dispatches"| node_console_runner
node_program -->|"dispatches"| node_simulation_worker
node_program -->|"dispatches"| node_persistent_worker
node_program -->|"configures"| node_repository
node_program -->|"uses"| node_keyboard
node_console_runner -->|"runs"| node_simulator
node_simulation_worker -->|"uses"| node_sim_service
node_persistent_worker -->|"uses"| node_persistent_service
node_persistent_service -->|"simulates day"| node_session
node_persistent_service -->|"saves day"| node_repository
node_session -->|"runs days"| node_engine
node_session -->|"creates strategy"| node_strategy
node_session -->|"creates teachers"| node_teacher_factory
node_session -->|"restores state"| node_random
node_sim_service -->|"simulates"| node_engine
node_engine -->|"requests attendance"| node_strategy
node_engine -->|"checks questioning"| node_teacher
node_engine -->|"supplies randomness"| node_random
node_engine -->|"records days"| node_history
node_engine -->|"builds results"| node_day_result
node_day_result -->|"stores lessons"| node_lesson_result
node_teacher_factory -->|"constructs"| node_teacher
node_teacher_factory -->|"draws assignments"| node_random
node_teacher -->|"reads prior asks"| node_history
node_teacher -->|"draws outcomes"| node_random
node_strategy -->|"implements"| node_contracts
node_strategy -->|"analyzes history"| node_history
node_repository -->|"implements"| node_repo_contract
node_repository -->|"loads and saves"| node_state
node_repository -->|"queries and updates"| node_postgres
node_session -->|"captures state"| node_state
node_simulator -->|"runs days"| node_engine

click node_program "https://github.com/quentinious/csharp-labs/blob/master/Csharp/Program.cs"
click node_console_runner "https://github.com/quentinious/csharp-labs/blob/master/Csharp/ConsoleSemesterRunner.cs"
click node_simulation_worker "https://github.com/quentinious/csharp-labs/blob/master/Csharp/SimulationWorker.cs"
click node_persistent_worker "https://github.com/quentinious/csharp-labs/blob/master/Csharp/PersistentSimulationWorker.cs"
click node_keyboard "https://github.com/quentinious/csharp-labs/blob/master/Csharp/KeyboardStopService.cs"
click node_session "https://github.com/quentinious/csharp-labs/blob/master/Csharp/SemesterSession.cs"
click node_engine "https://github.com/quentinious/csharp-labs/blob/master/Csharp/DaySimulationEngine.cs"
click node_sim_service "https://github.com/quentinious/csharp-labs/blob/master/Csharp/SimulationService.cs"
click node_persistent_service "https://github.com/quentinious/csharp-labs/blob/master/Csharp/PersistentSimulationService.cs"
click node_simulator "https://github.com/quentinious/csharp-labs/blob/master/Csharp/SemesterSimulator.cs"
click node_teacher_factory "https://github.com/quentinious/csharp-labs/blob/master/Csharp/TeacherFactory.cs"
click node_teacher "https://github.com/quentinious/csharp-labs/blob/master/Csharp/Teacher.cs"
click node_strategy "https://github.com/quentinious/csharp-labs/blob/master/Csharp/StudentStrategy.cs"
click node_history "https://github.com/quentinious/csharp-labs/blob/master/Csharp/StudentHistory.cs"
click node_contracts "https://github.com/quentinious/csharp-labs/blob/master/Csharp/StrategyContracts.cs"
click node_random "https://github.com/quentinious/csharp-labs/blob/master/Csharp/StatefulRandomSource.cs"
click node_day_result "https://github.com/quentinious/csharp-labs/blob/master/Csharp/DayResult.cs"
click node_lesson_result "https://github.com/quentinious/csharp-labs/blob/master/Csharp/LessonResult.cs"
click node_state "https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/SemesterState.cs"
click node_repository "https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/SemesterRepository.cs"
click node_repo_contract "https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/ISemesterRepository.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_program,node_console_runner,node_simulation_worker,node_persistent_worker,node_keyboard toneBlue
class node_session,node_engine,node_sim_service,node_persistent_service,node_simulator,node_day_result,node_lesson_result,node_postgres toneAmber
class node_teacher_factory,node_teacher,node_strategy,node_history,node_contracts,node_random toneMint
class node_state,node_repository,node_repo_contract toneRose
class node_user toneIndigo
```

## Components

### Console entry

- [Command entry](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Program.cs): `Csharp/Program.cs`
- [Console runner](https://github.com/quentinious/csharp-labs/blob/master/Csharp/ConsoleSemesterRunner.cs): `Csharp/ConsoleSemesterRunner.cs`
- [Simulation worker](https://github.com/quentinious/csharp-labs/blob/master/Csharp/SimulationWorker.cs): `Csharp/SimulationWorker.cs`
- [Persistent worker](https://github.com/quentinious/csharp-labs/blob/master/Csharp/PersistentSimulationWorker.cs): `Csharp/PersistentSimulationWorker.cs`
- [Stop handling](https://github.com/quentinious/csharp-labs/blob/master/Csharp/KeyboardStopService.cs): `Csharp/KeyboardStopService.cs`

### Semester simulation

- [Semester session](https://github.com/quentinious/csharp-labs/blob/master/Csharp/SemesterSession.cs): `Csharp/SemesterSession.cs`
- [Day engine](https://github.com/quentinious/csharp-labs/blob/master/Csharp/DaySimulationEngine.cs): `Csharp/DaySimulationEngine.cs`
- [Simulation service](https://github.com/quentinious/csharp-labs/blob/master/Csharp/SimulationService.cs): `Csharp/SimulationService.cs`
- [Persistent service](https://github.com/quentinious/csharp-labs/blob/master/Csharp/PersistentSimulationService.cs): `Csharp/PersistentSimulationService.cs`
- [Semester simulator](https://github.com/quentinious/csharp-labs/blob/master/Csharp/SemesterSimulator.cs): `Csharp/SemesterSimulator.cs`
- [Day results](https://github.com/quentinious/csharp-labs/blob/master/Csharp/DayResult.cs): `Csharp/DayResult.cs`
- [Lesson results](https://github.com/quentinious/csharp-labs/blob/master/Csharp/LessonResult.cs): `Csharp/LessonResult.cs`

### Rules and strategy

- [Teacher factory](https://github.com/quentinious/csharp-labs/blob/master/Csharp/TeacherFactory.cs): `Csharp/TeacherFactory.cs`
- [Questioning rules](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Teacher.cs): `Csharp/Teacher.cs`
- [Attendance strategy](https://github.com/quentinious/csharp-labs/blob/master/Csharp/StudentStrategy.cs): `Csharp/StudentStrategy.cs`
- [Student history](https://github.com/quentinious/csharp-labs/blob/master/Csharp/StudentHistory.cs): `Csharp/StudentHistory.cs`
- [Strategy contracts](https://github.com/quentinious/csharp-labs/blob/master/Csharp/StrategyContracts.cs): `Csharp/StrategyContracts.cs`
- [Stateful randomness](https://github.com/quentinious/csharp-labs/blob/master/Csharp/StatefulRandomSource.cs): `Csharp/StatefulRandomSource.cs`

### Persistence

- [Semester state](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/SemesterState.cs): `Csharp/Persistence/SemesterState.cs`
- [Semester repository](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/SemesterRepository.cs): `Csharp/Persistence/SemesterRepository.cs`
- [Repository contract](https://github.com/quentinious/csharp-labs/blob/master/Csharp/Persistence/ISemesterRepository.cs): `Csharp/Persistence/ISemesterRepository.cs`

### Other components

- **Operator**
- **PostgreSQL**

## Connections

- Operator → Command entry: runs commands (evidence: `README.md`)
- Command entry → Console runner: dispatches (evidence: `Csharp/Program.cs`)
- Command entry → Simulation worker: dispatches (evidence: `Csharp/Program.cs`)
- Command entry → Persistent worker: dispatches (evidence: `Csharp/Program.cs`)
- Command entry → Semester repository: configures (evidence: `Csharp/Program.cs`)
- Command entry → Stop handling: uses (evidence: `Csharp/Program.cs`)
- Console runner → Semester simulator: runs (evidence: `Csharp/ConsoleSemesterRunner.cs`)
- Simulation worker → Simulation service: uses (evidence: `Csharp/SimulationWorker.cs`)
- Persistent worker → Persistent service: uses (evidence: `Csharp/PersistentSimulationWorker.cs`)
- Persistent service → Semester session: simulates day (evidence: `Csharp/PersistentSimulationService.cs`)
- Persistent service → Semester repository: saves day (evidence: `Csharp/PersistentSimulationService.cs`)
- Semester session → Day engine: runs days (evidence: `Csharp/SemesterSession.cs`)
- Semester session → Attendance strategy: creates strategy (evidence: `Csharp/SemesterSession.cs`)
- Semester session → Teacher factory: creates teachers (evidence: `Csharp/SemesterSession.cs`)
- Semester session → Stateful randomness: restores state (evidence: `Csharp/SemesterSession.cs`)
- Simulation service → Day engine: simulates (evidence: `Csharp/SimulationService.cs`)
- Day engine → Attendance strategy: requests attendance (evidence: `Csharp/DaySimulationEngine.cs`)
- Day engine → Questioning rules: checks questioning (evidence: `Csharp/DaySimulationEngine.cs`)
- Day engine → Stateful randomness: supplies randomness (evidence: `Csharp/DaySimulationEngine.cs`)
- Day engine → Student history: records days (evidence: `Csharp/DaySimulationEngine.cs`)
- Day engine → Day results: builds results (evidence: `Csharp/DaySimulationEngine.cs`)
- Day results → Lesson results: stores lessons (evidence: `Csharp/DayResult.cs`)
- Teacher factory → Questioning rules: constructs (evidence: `Csharp/TeacherFactory.cs`)
- Teacher factory → Stateful randomness: draws assignments (evidence: `Csharp/TeacherFactory.cs`)
- Questioning rules → Student history: reads prior asks (evidence: `Csharp/Teacher.cs`)
- Questioning rules → Stateful randomness: draws outcomes (evidence: `Csharp/Teacher.cs`)
- Attendance strategy → Strategy contracts: implements (evidence: `Csharp/StudentStrategy.cs`)
- Attendance strategy → Student history: analyzes history (evidence: `Csharp/StudentStrategy.cs`)
- Semester repository → Repository contract: implements (evidence: `Csharp/Persistence/SemesterRepository.cs`)
- Semester repository → Semester state: loads and saves (evidence: `Csharp/Persistence/SemesterRepository.cs`)
- Semester repository → PostgreSQL: queries and updates (evidence: `Csharp/Persistence/SemesterRepository.cs`)
- Semester session → Semester state: captures state (evidence: `Csharp/SemesterSession.cs`)
- Semester simulator → Day engine: runs days (evidence: `Csharp/SemesterSimulator.cs`)
