# ruis94/deeplearning architecture

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

- Interactive diagram: https://gitdiagram.com/ruis94/deeplearning
- Repository: https://github.com/ruis94/deeplearning

## Overview

#### Purpose and entry point
DeepLearning is a layered .NET backend for translation-exam practice: user registration, exam configuration, AI-generated/imported questions, submissions, grading-derived progress, weak points, and review-library data. The HTTP host starts at `src/DeepLearning.Api/Program.cs`; public API boundaries are controllers under `src/DeepLearning.Api/Controllers` and route constants in `src/DeepLearning.Api/Constants/ApiRoutes.cs`.

#### API and request boundary
Controllers expose resources for users, exam setup, questions, submissions, follow-ups, progress, and weak points, dispatching application commands/queries rather than accessing persistence directly. Cross-cutting API behavior includes correlation IDs and centralized exception translation in `src/DeepLearning.Api/Middleware/CorrelationIdMiddleware.cs` and `src/DeepLearning.Api/Middleware/GlobalExceptionHandler.cs`.

#### Application command/query layer
`DeepLearning.Application` implements feature-oriented CQRS handlers, validators, and result DTOs. Key write flows include question generation/import and user registration, represented by `src/DeepLearning.Application/Features/Questions/Commands/GenerateQuestion/GenerateQuestionCommandHandler.cs`, `src/DeepLearning.Application/Features/Questions/Commands/ImportUserQuestion/ImportUserQuestionCommandHandler.cs`, and `src/DeepLearning.Application/Features/Users/Commands/RegisterUser/RegisterUserCommandHandler.cs`. MediatR-style pipeline behaviors provide validation, logging, and unhandled-exception handling in `src/DeepLearning.Application/Behaviors`.

#### Exam configuration and generation
Exam types define assessment dimensions, error taxonomies, and prompt templates. Those configurable inputs are created and queried through `src/DeepLearning.Application/Features/ExamConfig` and are persisted as domain entities including `src/DeepLearning.Domain/Entities/ExamType.cs` and `src/DeepLearning.Domain/Entities/PromptTemplate.cs`. Generation depends on application abstractions such as `src/DeepLearning.Application/Interfaces/IExamConfigLoader.cs` and `src/DeepLearning.Application/Interfaces/ILlmClient.cs`, isolating use cases from AI implementation.

#### Submission grading feedback loop
The core learning loop centers on `Submission` and `GradingResult`: a submission is graded, then emits `SubmissionGradedEvent`. Event handlers update learner projections: `src/DeepLearning.Domain/Events/SubmissionGradedEvent.cs`, `src/DeepLearning.Application/Features/Progress/EventHandlers/UpdateProgressOnGraded.cs`, `src/DeepLearning.Application/Features/WeakPoints/EventHandlers/UpdateWeakPointsOnGraded.cs`, and `src/DeepLearning.Application/Features/ReviewLibrary/EventHandlers/ExtractKnowledgePointsOnGraded.cs`. This separates grading state transitions from downstream progress, weak-point recurrence, and extracted review material.

#### Domain model and consistency boundary
`DeepLearning.Domain` holds entities, enums, guarded results, domain exceptions, and events without infrastructure dependencies. Aggregate-oriented core records include `src/DeepLearning.Domain/Entities/Question.cs`, `src/DeepLearning.Domain/Entities/Submission.cs`, and `src/DeepLearning.Domain/Entities/WeakPoint.cs`. Application handlers use repository interfaces and `IUnitOfWork` to define persistence/transaction boundaries, e.g. `src/DeepLearning.Application/Interfaces/ISubmissionRepository.cs` and `src/DeepLearning.Application/Interfaces/IUnitOfWork.cs`.

#### Infrastructure and operations
Infrastructure implements application ports. EF Core/Npgsql persistence is rooted at `src/DeepLearning.Infrastructure/Persistence/AppDbContext.cs`, with PostgreSQL schema/migrations in `src/DeepLearning.Infrastructure/Persistence/Migrations` and repositories in `src/DeepLearning.Infrastructure/Persistence/Repositories`. AI integration uses a Claude-oriented client and configurable prompts: `src/DeepLearning.Infrastructure/Ai/LlmClient.cs`, `src/DeepLearning.Infrastructure/Ai/Options/ClaudeApiOptions.cs`, and `src/DeepLearning.Infrastructure/Ai/PromptRenderer.cs`. Background jobs produce snapshots, prompt regression results, and rubric calibration reports under `src/DeepLearning.Infrastructure/BackgroundJobs`. Containerized local deployment is defined by `docker-compose.yml` and `src/DeepLearning.Api/Dockerfile`.

Main entry points: [`src/DeepLearning.Application/Features`](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Features) (CQRS handlers), [`src/DeepLearning.Application/Interfaces/IUnitOfWork.cs`](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Interfaces/IUnitOfWork.cs) (Application ports), [`src/DeepLearning.Domain/Entities/Submission.cs`](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Domain/Entities/Submission.cs) (Learning aggregates), [`src/DeepLearning.Api/Controllers`](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Api/Controllers) (Resource controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_host["API host<br/>.NET entry point<br/>[Program.cs]"]
  node_controllers["Resource controllers<br/>HTTP boundary<br/>[Controllers]"]
  node_routes["Route constants<br/>API contract<br/>[ApiRoutes.cs]"]
  node_api_middleware["API middleware<br/>cross-cutting"]
end

subgraph group_application["Application"]
  node_cqrs["CQRS handlers<br/>use cases<br/>[Features]"]
  node_pipeline["MediatR behaviors<br/>request pipeline<br/>[Behaviors]"]
  node_generation["Question generation<br/>write flow"]
  node_exam_config["Exam configuration<br/>use cases<br/>[ExamConfig]"]
  node_grading_projections["Grading projections<br/>event handlers"]
  node_ports{{"Application ports<br/>interfaces<br/>[IUnitOfWork.cs]"}}
end

subgraph group_domain["Domain"]
  node_aggregates["Learning aggregates<br/>domain entities<br/>[Submission.cs]"]
  node_graded_event(("Submission graded event<br/>domain event"))
end

subgraph group_infrastructure["Infrastructure"]
  node_persistence["EF Core persistence<br/>DbContext and repositories<br/>[AppDbContext.cs]"]
  node_postgres[("PostgreSQL<br/>database<br/>[Migrations]")]
  node_llm["Claude LLM client<br/>AI adapter<br/>[LlmClient.cs]"]
  node_jobs["Background jobs<br/>operations pipeline<br/>[BackgroundJobs]"]
end

node_containers["Container deployment<br/>local runtime<br/>[docker-compose.yml]"]

node_host -->|"configures"| node_api_middleware
node_api_middleware -->|"wraps"| node_controllers
node_routes -->|"defines routes"| node_controllers
node_controllers -->|"dispatches commands and queries"| node_cqrs
node_cqrs -->|"runs through"| node_pipeline
node_pipeline -->|"applies to"| node_generation
node_cqrs -->|"includes"| node_exam_config
node_cqrs -->|"depends on"| node_ports
node_generation -->|"loads config and generates via"| node_ports
node_exam_config -->|"manages"| node_aggregates
node_cqrs -->|"changes"| node_aggregates
node_aggregates -->|"emits after grading"| node_graded_event
node_graded_event -->|"triggers"| node_grading_projections
node_grading_projections -->|"updates learner projections"| node_aggregates
node_ports -->|"implemented by"| node_persistence
node_ports -->|"implemented by"| node_llm
node_persistence -->|"persists to"| node_postgres
node_jobs -->|"reads and writes"| node_persistence
node_jobs -->|"runs prompt and rubric work"| node_llm
node_containers -->|"runs"| node_host
node_containers -->|"provisions"| node_postgres

click node_host "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Api/Program.cs"
click node_controllers "https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Api/Controllers"
click node_routes "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Api/Constants/ApiRoutes.cs"
click node_api_middleware "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Api/Middleware/CorrelationIdMiddleware.cs"
click node_cqrs "https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Features"
click node_pipeline "https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Behaviors"
click node_generation "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Features/Questions/Commands/GenerateQuestion/GenerateQuestionCommandHandler.cs"
click node_exam_config "https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Features/ExamConfig"
click node_grading_projections "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Features/Progress/EventHandlers/UpdateProgressOnGraded.cs"
click node_ports "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Interfaces/IUnitOfWork.cs"
click node_aggregates "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Domain/Entities/Submission.cs"
click node_graded_event "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Domain/Events/SubmissionGradedEvent.cs"
click node_persistence "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Infrastructure/Persistence/AppDbContext.cs"
click node_postgres "https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Infrastructure/Persistence/Migrations"
click node_llm "https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Infrastructure/Ai/LlmClient.cs"
click node_jobs "https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Infrastructure/BackgroundJobs"
click node_containers "https://github.com/ruis94/deeplearning/blob/master/docker-compose.yml"

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_host,node_controllers,node_routes,node_api_middleware toneBlue
class node_cqrs,node_pipeline,node_generation,node_exam_config,node_grading_projections,node_ports toneAmber
class node_aggregates,node_graded_event toneMint
class node_persistence,node_postgres,node_llm,node_jobs toneRose
class node_containers toneNeutral
```

## Components

### HTTP API

- [API host](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Api/Program.cs): .NET entry point · `src/DeepLearning.Api/Program.cs`
- [Resource controllers](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Api/Controllers): HTTP boundary · Users, exam setup, questions, submissions, follow-ups, progress, and weak points. · `src/DeepLearning.Api/Controllers`
- [Route constants](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Api/Constants/ApiRoutes.cs): API contract · `src/DeepLearning.Api/Constants/ApiRoutes.cs`
- [API middleware](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Api/Middleware/CorrelationIdMiddleware.cs): cross-cutting · Correlation IDs and centralized exception translation. · `src/DeepLearning.Api/Middleware/CorrelationIdMiddleware.cs`

### Application

- [CQRS handlers](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Features): use cases · Feature commands, queries, validators, and result DTOs. · `src/DeepLearning.Application/Features`
- [MediatR behaviors](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Behaviors): request pipeline · Validation, logging, and unhandled-exception handling. · `src/DeepLearning.Application/Behaviors`
- [Question generation](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Features/Questions/Commands/GenerateQuestion/GenerateQuestionCommandHandler.cs): write flow · Generates or imports user questions. · `src/DeepLearning.Application/Features/Questions/Commands/GenerateQuestion/GenerateQuestionCommandHandler.cs`
- [Exam configuration](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Application/Features/ExamConfig): use cases · Manages assessment dimensions, taxonomies, and prompt templates. · `src/DeepLearning.Application/Features/ExamConfig`
- [Grading projections](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Features/Progress/EventHandlers/UpdateProgressOnGraded.cs): event handlers · Updates progress, weak points, and review material after grading. · `src/DeepLearning.Application/Features/Progress/EventHandlers/UpdateProgressOnGraded.cs`
- [Application ports](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Application/Interfaces/IUnitOfWork.cs): interfaces · Repositories, unit of work, exam-config loader, and LLM client abstractions. · `src/DeepLearning.Application/Interfaces/IUnitOfWork.cs`

### Domain

- [Learning aggregates](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Domain/Entities/Submission.cs): domain entities · Questions, submissions, weak points, exam types, and prompt templates. · `src/DeepLearning.Domain/Entities/Submission.cs`
- [Submission graded event](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Domain/Events/SubmissionGradedEvent.cs): domain event · `src/DeepLearning.Domain/Events/SubmissionGradedEvent.cs`

### Infrastructure

- [EF Core persistence](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Infrastructure/Persistence/AppDbContext.cs): DbContext and repositories · `src/DeepLearning.Infrastructure/Persistence/AppDbContext.cs`
- [PostgreSQL](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Infrastructure/Persistence/Migrations): database · Schema and migrations are managed by EF Core. · `src/DeepLearning.Infrastructure/Persistence/Migrations`
- [Claude LLM client](https://github.com/ruis94/deeplearning/blob/master/src/DeepLearning.Infrastructure/Ai/LlmClient.cs): AI adapter · Renders configurable prompts and calls the LLM. · `src/DeepLearning.Infrastructure/Ai/LlmClient.cs`
- [Background jobs](https://github.com/ruis94/deeplearning/tree/master/src/DeepLearning.Infrastructure/BackgroundJobs): operations pipeline · Produces snapshots, prompt regression results, and rubric calibration reports. · `src/DeepLearning.Infrastructure/BackgroundJobs`

### Other components

- [Container deployment](https://github.com/ruis94/deeplearning/blob/master/docker-compose.yml): local runtime · `docker-compose.yml`

## Connections

- API host → API middleware: configures
- API middleware → Resource controllers: wraps
- Route constants → Resource controllers: defines routes
- Resource controllers → CQRS handlers: dispatches commands and queries
- CQRS handlers → MediatR behaviors: runs through
- MediatR behaviors → Question generation: applies to
- CQRS handlers → Exam configuration: includes
- CQRS handlers → Application ports: depends on
- Question generation → Application ports: loads config and generates via
- Exam configuration → Learning aggregates: manages
- CQRS handlers → Learning aggregates: changes
- Learning aggregates → Submission graded event: emits after grading
- Submission graded event → Grading projections: triggers
- Grading projections → Learning aggregates: updates learner projections
- Application ports → EF Core persistence: implemented by
- Application ports → Claude LLM client: implemented by
- EF Core persistence → PostgreSQL: persists to
- Background jobs → EF Core persistence: reads and writes
- Background jobs → Claude LLM client: runs prompt and rubric work
- Container deployment → API host: runs
- Container deployment → PostgreSQL: provisions
