How ruis94/deeplearning works
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: Features CQRS handlers · IUnitOfWork.cs Application ports · Submission.cs Learning aggregates · Controllers Resource controllers
Components 17
HTTP API
- API host
src/DeepLearning.Api/Program.cs - Resource controllers · Users, exam setup, questions, submissions, follow-ups, progress, and weak points.
src/DeepLearning.Api/Controllers - Route constants
src/DeepLearning.Api/Constants/ApiRoutes.cs - API middleware · Correlation IDs and centralized exception translation.
src/DeepLearning.Api/Middleware/CorrelationIdMiddleware.cs
Application
- CQRS handlers · Feature commands, queries, validators, and result DTOs.
src/DeepLearning.Application/Features - MediatR behaviors · Validation, logging, and unhandled-exception handling.
src/DeepLearning.Application/Behaviors - Question generation · Generates or imports user questions.
src/DeepLearning.Application/Features/Questions/Commands/GenerateQuestion/GenerateQuestionCommandHandler.cs - Exam configuration · Manages assessment dimensions, taxonomies, and prompt templates.
src/DeepLearning.Application/Features/ExamConfig - Grading projections · Updates progress, weak points, and review material after grading.
src/DeepLearning.Application/Features/Progress/EventHandlers/UpdateProgressOnGraded.cs - Application ports · Repositories, unit of work, exam-config loader, and LLM client abstractions.
src/DeepLearning.Application/Interfaces/IUnitOfWork.cs
Domain
- Learning aggregates · Questions, submissions, weak points, exam types, and prompt templates.
src/DeepLearning.Domain/Entities/Submission.cs - Submission graded event
src/DeepLearning.Domain/Events/SubmissionGradedEvent.cs
Infrastructure
- EF Core persistence
src/DeepLearning.Infrastructure/Persistence/AppDbContext.cs - PostgreSQL · Schema and migrations are managed by EF Core.
src/DeepLearning.Infrastructure/Persistence/Migrations - Claude LLM client · Renders configurable prompts and calls the LLM.
src/DeepLearning.Infrastructure/Ai/LlmClient.cs - Background jobs · Produces snapshots, prompt regression results, and rubric calibration reports.
src/DeepLearning.Infrastructure/BackgroundJobs
Other components
- Container deployment
docker-compose.yml
Connections 21
- 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