How mizuto26/webapp_exercise works
1. This is an ASP.NET Core MVC application organized as a teaching/exercise repo. It combines several small sample controllers/views with one more fully layered feature around item registration.
2. The repository is split into three main architectural areas:
- Applications: domain models, service abstractions, and application services
- Infrastructures: persistence models, EF Core context, repository implementations, and entity adapters
- Presentations: MVC-facing controllers, view models, and DI wiring for the item-registration flow
3. The core business domain lives in Applications/Domains with Item, ItemCategory, and ItemStock. These are the business objects the application tries to protect from persistence and UI details.
4. The application boundary is defined by interfaces in Applications/Adapters, Applications/Repositories, and Applications/Services. IItemRegisterService is the main use-case entry point, while IConverter/IRestorer and repository interfaces abstract data transformation and persistence access.
5. Applications/Services/Impls/ItemRegisterService.cs appears to coordinate the item-registration use case. It likely orchestrates validation, repository calls, and domain object creation, while remaining independent of EF Core and MVC concerns.
6. The persistence layer is in Infrastructures. AppDbContext is the EF Core database context, and Infrastructures/Entities contains database-shaped entities such as ItemEntity, ItemStockEntity, and ItemCatgoryEntity (note the spelling). This layer is where the domain model is flattened into storage-friendly records.
7. The Infrastructures/Adapters classes bridge the domain and persistence models. ItemEntityAdapter, ItemStockEntityAdapter, and ItemCategoryEntityAdapter convert between entities and domain objects, which keeps the domain model isolated from database schema details.
8. Repository implementations live in Infrastructures/Repositories, backed by AppDbContext. This is the concrete data-access boundary used by the application service layer. The file tree suggests separate repositories for items and item categories, with the item repository interface duplicated across layers to keep contracts available where needed.
9. The presentation boundary for the item-registration feature is in Presentations. ItemRegisterController is the MVC controller for that workflow, ItemRegisterViewModel shapes data for the views, and ItemRegisterViewModelAdapter maps between view state and application/domain state. TempDataStore suggests multi-step form handling across redirects.
10. Presentations/Extensions/DependencyExtension.cs is the composition root for this feature set. It likely registers repositories, adapters, services, and other app-specific dependencies into the ASP.NET Core DI container.
11. The UI is mostly Razor views under Views, with a dedicated Views/ItemRegister folder for the registration flow and additional exercise/sample views like Ex09, Op04, TagHelperForm, and RazorSyntaxSample. Views/Shared/_Layout.cshtml provides the common site shell.
12. There is also a set of root-level controllers in Controllers, such as HomeController, Ex03Controller, Op01Controller, and TagHelperFormController. These appear to support discrete exercises and MVC feature demos rather than core business functionality.
13. wwwroot contains static assets and client-side libraries, including Bootstrap, jQuery, and validation scripts. This supports standard Razor MVC rendering and unobtrusive form validation, especially for the sample form-based exercises.
14. Custom exceptions in Exceptions define the app’s error semantics: DomainException, ExistsException, NotFoundException, and InternalException. These provide a clear boundary for business-rule failures versus infrastructure or unexpected failures.
15. The overall runtime flow for the item-registration feature is: browser request -> MVC controller -> view model mapping -> application service -> repository/adapters -> EF Core context/database -> reverse mapping back to domain/view model -> Razor view response. The exercise controllers mostly bypass this deeper layering and serve as lightweight request/view demonstrations.
Main entry points: ItemRegisterService.cs Register service · ItemRegisterController.cs Register controller · DependencyExtension.cs DI wiring · Adapters Core adapters
Components 20
Applications
Domain, contracts, and use-case orchestration
- Item · Core business item entity
Applications/Domains/Item.cs - Category · Business item category
Applications/Domains/ItemCategory.cs - Stock · Business item stock
Applications/Domains/ItemStock.cs - Core adapters · Conversion and restoration contracts
Applications/Adapters - Repo contracts · Persistence abstractions for application layer
Applications/Repositories - Register service · Item registration orchestration
Applications/Services/Impls/ItemRegisterService.cs
Infrastructures
EF Core persistence and model adapters
- Db context · Database access boundary
Infrastructures/Context/AppDbContext.cs - Entities · Storage-shaped records
Infrastructures/Entities - Entity adapters · Domain-to-entity translators
Infrastructures/Adapters - Repos · Concrete repository implementations
Infrastructures/Repositories
Presentations
MVC flow for item registration
- Register controller · Item registration request handler
Presentations/Controllers/ItemRegisterController.cs - Register VM · Form state for item registration
Presentations/ViewModels/ItemRegisterViewModel.cs - VM adapter · Maps view state to app/domain state
Presentations/ViewModels/ItemRegisterViewModelAdapter.cs - Temp store · Cross-request state for the flow
Presentations/Controllers/TempDataStore.cs - DI wiring · Registers feature dependencies
Presentations/Extensions/DependencyExtension.cs
Samples
Exercise controllers, views, and form models
- Exercise controllers · Home and lesson controllers
Controllers - Form models · Simple request models for exercises
Models - Razor views · Exercise pages and shared layout
Views - Static assets · CSS, JS, HTML, and libraries
wwwroot
Other components
- Exceptions · Domain and application error semantics
Exceptions
Connections 28
- Register service → Item: creates · Builds business item objects
- Register service → Repo contracts: uses · Loads and saves through repository contracts
- Register service → Core adapters: depends on · Uses conversion/restoration abstractions
- Register service → Exceptions: throws · Signals business and lookup failures
- Core adapters → Item: maps · Converts domain objects
- Core adapters → Category: maps · Converts category objects
- Core adapters → Stock: maps · Converts stock objects
- Entity adapters → Item: maps · Bridges storage and domain item models
- Entity adapters → Category: maps · Bridges storage and domain category models
- Entity adapters → Stock: maps · Bridges storage and domain stock models
- Entities → Db context: persisted by · EF Core tracks entity records
- Repos → Db context: queries · Uses DbContext for persistence
- Repos → Entities: stores · Works with entity shapes
- Repos → Repo contracts: implements · Concrete repository boundary
- Register controller → Register VM: binds · Receives and returns registration form data
- Register controller → VM adapter: maps · Converts between controller and app forms
- Register controller → Register service: invokes · Triggers registration use case
- Register controller → Temp store: stores state · Carries data across redirects
- VM adapter → Item: maps · Transforms view data into domain input
- VM adapter → Register VM: maps · Transforms between view model shapes
- DI wiring → Register controller: registers · Wires MVC feature dependencies
- DI wiring → Register service: registers · Adds application service to DI
- DI wiring → Repos: registers · Adds persistence implementations to DI
- DI wiring → Entity adapters: registers · Adds mapping components to DI
- Exercise controllers → Razor views: renders · Exercise controllers return Razor pages
- Exercise controllers → Form models: binds · Simple form handling for lessons
- Razor views → Static assets: uses · Shared CSS/JS and validation assets
- Razor views → Exceptions: shows · Error page reflects application failures