How ykh2000/medieval works
1. High-level shape
MediEval is a single ASP.NET Core MVC monolith with a standard server-rendered UI. Requests come in through MVC controllers, which coordinate business logic in Data/Services, persist through EF Core, and render Razor views. The app is centered on an OTC medicine commerce workflow plus admin and real-time communication features.
2. Presentation layer
The main UI is split between standard MVC controllers under Controllers/ and an admin-only MVC Area under Areas/Admin/. Views live in Views/ and Areas/Admin/Views/, with shared layouts and partials. This separation is important for the architecture diagram because admin and customer-facing pages are distinct routes and layouts.
3. Core business domains
The domain models in Models/ cover medicines, pharmacies, pharmacy brands, orders, order items, shopping cart items, chat messages, and users. These are the core entities that flow through the app: catalog browsing, cart management, checkout/order creation, and customer support chat.
4. Data access and persistence
Data/AppDbContext.cs is the EF Core database boundary. Migrations/ shows the schema evolves through EF migrations, and AppDbInitializer.cs likely seeds or prepares the database. Data/Base/ contains a repository abstraction, but the implementation also uses service classes directly, so the persistence boundary is service-oriented rather than purely repository-driven.
5. Application services
The Data/Services/ layer is the main business logic boundary. It includes MedicineService, OrdersService, PharmacyService, PharmacyBrandService, and buffered file upload services. Controllers depend on these services instead of talking to EF Core directly, which keeps the MVC layer thin and makes service classes the key orchestration point for data operations.
6. Authentication and user management
Authentication is handled through ASP.NET Core Identity, reflected by ApplicationUser, account-related view models, and AccountController. Roles are defined in Data/Static/UserRoles.cs, and the UI includes login, registration, password recovery, lockout, and access-denied flows. Authorization is used to separate regular users from admins.
7. Catalog and commerce flow
Users browse medicines and pharmacy-related entities through MedicineController, PharmacyController, and PharmacyBrandController. The shopping flow runs through the cart and order models plus OrdersController. The ShoppingCart helper and ShoppingCartSummary view component indicate the cart is maintained server-side and summarized in the UI.
8. Admin subsystem
The admin area includes controllers for home, medicine, and user management, plus a dedicated admin layout. This is a clear boundary for privileged operations such as managing catalog data and user administration. In the diagram, this should be shown as a separate presentation slice over the same service and database layers.
9. Real-time communication
The app uses SignalR hubs in Hubs/ for chat, notifications, and user presence/counting. Browser-side JavaScript in wwwroot/js/ connects to these hubs to provide live updates for customer–pharmacist chat and alerts. This is an asynchronous push channel separate from normal HTTP request/response traffic.
10. File upload subsystem
There are two upload paths: a buffered file upload controller/service and a dedicated image upload controller/model pair. Uploaded content is stored under UploadedFiles/ and also under wwwroot/Images/ for browser access. This subsystem is likely used for medicine images and other user-submitted files, and it forms a distinct storage boundary outside the database.
11. Email and external integration
Services/MailJetEMailSender.cs and MailJetOptions.cs show outbound email integration via Mailjet. This is part of the account lifecycle, likely supporting registration and password reset workflows. It is an external dependency separate from the core database and UI layers.
12. Frontend assets and client runtime
The client side is mainly Razor-rendered HTML with Bootstrap, jQuery, validation scripts, and SignalR JavaScript libraries under wwwroot/lib/. Custom scripts such as chat.js, notification.js, and usersCount.js bind the real-time features to the UI. The frontend is therefore not a SPA; it is server-rendered with targeted JavaScript enhancements.
13. Configuration and deployment context
appsettings.json, appsettings.Development.json, launchSettings.json, and the serviceDependencies files define runtime configuration and deployment wiring. The presence of SQL Server service metadata indicates the app is designed to run against a relational SQL backend, with environment-specific configuration controlling connection strings and related settings.
14. What the diagram should emphasize
The cleanest architecture view is: browser/UI → MVC controllers or SignalR hubs → service layer → EF Core DbContext → SQL Server, with side paths for file storage and Mailjet email. The admin area, real-time hubs, and upload subsystem should be drawn as separate vertical slices because they cross-cut the core commerce flow without replacing it.
Main entry points: MediEval/Controllers MVC Controllers · Admin/Controllers Admin Controllers · Services Catalog Services · Views Razor Views
Components 16
Presentation
Server-rendered MVC UI and admin area.
- MVC Controllers · Customer-facing request handlers for account, catalog, cart, orders, chat, and uploads.
MediEval/Controllers - Admin Controllers · Privileged admin routes for home, medicine, and user management.
MediEval/Areas/Admin/Controllers - Razor Views · Main customer-facing Razor pages and shared layouts/partials.
MediEval/Views - Admin Views · Admin area pages and dedicated admin layout.
MediEval/Areas/Admin/Views
Application
Services, cart, and business workflows.
- Catalog Services · Medicine, pharmacy, and brand services that drive catalog operations.
MediEval/Data/Services - Orders Service · Orchestrates cart-to-order conversion and order retrieval.
MediEval/Data/Services/OrdersService.cs - Shopping Cart · Server-side cart state and cart summary component.
MediEval/Data/Cart/ShoppingCart.cs - View Models · Login, register, admin, cart, and medicine form models used between controllers and views.
MediEval/Data/ViewModel
Infrastructure
EF Core persistence, identity, and external services.
- App DbContext · Primary EF Core boundary for all domain persistence.
MediEval/Data/AppDbContext.cs - Db Initializer · Database seeding and startup preparation logic.
MediEval/Data/AppDbInitializer.cs - Identity Users · ASP.NET Core Identity user model and role definitions.
MediEval/Models/ApplicationUser.cs - Mailjet Email · Outbound email provider for account lifecycle workflows.
MediEval/Services/MailJetEMailSender.cs
Realtime
SignalR hubs and browser push features.
- SignalR Hubs · Chat, notification, and user-presence hubs.
MediEval/Hubs
Client Assets
Static JS/CSS and uploaded file storage.
- Client Scripts · Custom JavaScript for chat, notifications, users count, and site behavior.
MediEval/wwwroot/js - File Storage · Local uploaded files and web-accessible images.
MediEval/UploadedFiles
Other components
- Domain Models · Core commerce entities: medicines, pharmacies, orders, chats, and carts.
MediEval/Models
Connections 22
- MVC Controllers → Catalog Services: uses · Controllers delegate catalog operations to services.
- MVC Controllers → Orders Service: uses · Order and cart actions flow through order service orchestration.
- MVC Controllers → Shopping Cart: uses · Shopping cart controller logic relies on server-side cart state.
- MVC Controllers → SignalR Hubs: signals · Chat and notifications connect to realtime hubs.
- MVC Controllers → Razor Views: renders · MVC controllers render Razor pages.
- Admin Controllers → Catalog Services: uses · Admin catalog management shares the same service layer.
- Admin Controllers → Razor Views: renders · Admin actions render Razor views through the MVC pipeline.
- Admin Controllers → Admin Views: renders · Admin-specific pages use the area layout and views.
- Razor Views → View Models: binds · Views consume typed models from controllers.
- Admin Views → View Models: binds · Admin pages use dedicated form and listing models.
- Catalog Services → App DbContext: persists via · Catalog services read and write through EF Core.
- Orders Service → App DbContext: persists via · Checkout and order workflows use the database boundary.
- Shopping Cart → Orders Service: submits to · Cart contents are transformed into orders.
- App DbContext → Domain Models: maps · EF Core maps the core domain entities.
- Db Initializer → App DbContext: prepares · Startup seeding and setup operate through DbContext.
- MVC Controllers → Identity Users: authenticates · Account and access flows depend on Identity users and roles.
- Admin Controllers → Identity Users: authorizes · Admin routes are protected by role-based authorization.
- MVC Controllers → Mailjet Email: sends email · Password reset and registration flows trigger outbound mail.
- SignalR Hubs → Client Scripts: pushes to · Browser scripts connect to and consume hub events.
- Client Scripts → Razor Views: enhances · Client scripts enrich server-rendered pages.
- MVC Controllers → File Storage: stores files · Upload controllers write to local upload/image storage.
- Catalog Services → File Storage: reads images · Catalog services may reference uploaded medicine images.