How mznzgt/quizwiz works
Main Components
• Domain Layer: Represents the core business logic. Include entities like User and models such as LoginResponseModel, QuizResponse, etc. This layer (Directory: Domain/QuizWiz.Domain) is central and independent.
• Application Layer: Contains modules such as QuizWix.Application.Auth and QuizWiz.Application.QuizGenerator. This layer holds use-case implementations, commands (e.g., AddRolesCommand, AddArticleCommand) and queries (e.g., GetArticleQuery). It’s responsible for orchestrating business operations.
• Infrastructure Layer: Contains components for data access and external integrations:
• Data: QuizWix.Infrastructure.Data (with the DbContext, migrations, etc.) for interacting with SQL databases.
• OpenAI Integration: QuizWiz.Infrastructure.OpenAI (providing an abstraction and implementation for integration with OpenAI Chat API).
• Persistence Layer: Offers specialized persistence services such as:
• Cosmos: QuizWiz.Persistence.Cosmos, which handles Azure Cosmos DB interactions.
• Blob Storage: QuizWiz.Persistence.BlobStorage, which handles blob-based storage.
• Presentation Layer: Contains several projects:
• QuizWiz.ApiService: Exposes REST API endpoints with controllers (e.g., BlobController, OpenAIController, etc.) that expose services like user management and roles.
• QuizWiz.AppHost: Likely serves as the hosting orchestrator.
• QuizWiz.Web: Implements the Blazor Server-Side application providing the user interface for students and teachers.
• ServiceDefaults: Provides common extensions or utilities used across services.
Relationships and Interactions
• The Presentation layer (API and web projects) acts as the entry point. Users (teachers and students) interact with the web client or REST endpoints.
• API controllers in QuizWiz.ApiService route requests to the Application layer through dependency injection – observe the various “DependencyInjection” classes that set up the service registrations.
• The Application layer commands and queries then coordinate with the Domain layer (for business rules) and invoke infrastructure services.
• Infrastructure components (e.g., the DbContext, migration files, and OpenAI service) facilitate data storage and external calls.
• Persistence provides specialized storage mechanisms: one part handles Cosmos DB for quiz data (partitioned by teacher’s email), and another handles Blob Storage for storing related artifacts.
• The external OpenAI Chat API is integrated via the OpenAI service in the Infrastructure layer.
• Data flows from front-end (Blazor) to API endpoints, then through application services, and further to persistence and external services.
Architectural Patterns and Design Principles
• Onion/Clean Architecture: The separation into Domain, Application, Infrastructure, and Presentation layers clearly represents the decoupling of core business logic from external concerns.
• Command-Query Responsibility Segregation (CQRS): Notice the presence of “Commands” (e.g., AddRolesCommand) and “Queries” (e.g., GetArticleQuery) which indicate that operations are split by intent.
• Dependency Injection: Various “DependencyInjection” classes hint at the use of DI for wiring together system components.
• Cloud-Native Design: Emphasis on Azure Cosmos DB, SQL databases, and Docker support reflects a cloud-oriented approach.
Relevant Technologies
• .NET 8 (with Aspire’s default template) is the backbone.
• Blazor Server-Side is used for the UI.
• Azure Cosmos DB and Azure SQL Database are part of data storage.
• The OpenAI Chat API is integrated as a service.
• Entity Framework Core is used for data management.
• Docker and container configurations (see .devcontainer and GitHub Actions) support deployment and CI/CD.