How vanshika6605/ai-hospital-management-app works
1. This is an ASP.NET Core MVC hospital management system built around a layered monolith: UI controllers and Razor views, a service layer, a repository layer, and Entity Framework Core persistence.
2. The application is split into role-based MVC Areas: Admin, Doctor, Patient, Receptionist, and Identity. Each area has its own controllers and views, which is the main presentation boundary in the repo.
3. The shared, non-area entry point is minimal: HomeController and shared views/layouts under Views/Shared. The root layout and login partial indicate a single server-rendered web app with authenticated and unauthenticated entry paths.
4. Identity is handled separately under Areas/Identity/Pages/Account using Razor Pages for login and registration. That boundary suggests ASP.NET Core Identity is the auth subsystem, independent from the role-specific MVC pages.
5. The domain model lives in Models/Domain and centers on hospital entities such as Patient, Doctor, Appointment, Department, Bill, Prescription, MedicalRecord, DoctorSchedule, Notification, and ApplicationUser. AppointmentStatus is the main workflow enum.
6. EF Core persistence is wired through Data/ApplicationDbContext.cs, with migrations tracked in Data/Migrations. SeedData.cs suggests startup data population for initial users, roles, or reference records.
7. The repository layer is thin and currently focused on appointments: a generic repository abstraction plus an appointment-specific repository. This implies most data access is meant to be centralized behind repositories, with room for entity-specific extensions where needed.
8. The service layer contains the business workflows: appointments, billing, departments, doctors, patients, prescriptions, and notifications. These services likely coordinate validation, status changes, cross-entity updates, and persistence through repositories.
9. Controllers in each area depend on those services rather than on the DbContext directly. That keeps UI actions separate from business rules: for example, Admin controllers manage CRUD screens, Doctor controllers handle dashboards/prescriptions, Receptionist handles billing, and Patient/Doctor dashboards surface role-specific data.
10. View models in ViewModels act as the UI contract between controllers and Razor views. They separate presentation shape from domain entities, especially for forms like appointments, bills, departments, doctors, patients, and prescriptions.
11. The notification subsystem has both a domain entity and a SignalR hub (Hubs/NotificationHub.cs) plus a notification service. That indicates a real-time push channel for events such as booking, billing, or status updates, alongside standard request/response MVC flows.
12. Static assets and client libraries are bundled under wwwroot, with Bootstrap, jQuery, validation, and site-specific CSS/JS. This is a server-rendered app with lightweight client-side enhancement rather than a SPA.
13. Program.cs is the composition root where MVC, Identity, EF Core, services, repositories, and SignalR are wired together. The app’s runtime boundary is therefore a conventional ASP.NET Core web host backed by a relational database via EF Core.
14. For an architecture diagram, the key data flow is: browser request → role/area controller or Identity page → service → repository → ApplicationDbContext/database, with notifications optionally flowing through SignalR back to connected clients.
Main entry points: Program.cs Program · ApplicationDbContext.cs Db Context · DashboardController.cs Admin Area · GenericRepository.cs Generic Repo
Components 24
Presentation
Role-based MVC areas plus shared server-rendered pages and assets.
- Home · Shared entry controller for the non-area home pages.
Controllers/HomeController.cs - Shared Views · Root layout, login partial, error page, and shared MVC templates.
Views/Shared/_Layout.cshtml - Admin Area · Administrative controllers and views for appointments, departments, doctors, and patients.
Areas/Admin/Controllers/DashboardController.cs - Doctor Area · Doctor dashboards and prescription workflows.
Areas/Doctor/Controllers/DashboardController.cs - Patient Area · Patient dashboard and role-specific pages.
Areas/Patient/Controllers/DashboardController.cs - Receptionist Area · Billing screens for front-desk workflows.
Areas/Receptionist/Controllers/BillingController.cs
Identity
Authentication and account pages built with Razor Pages.
- Identity Pages · Login and registration pages under the Identity area.
Areas/Identity/Pages/Account/Login.cshtml
Application
Business workflows implemented through services and repositories.
- Appointments · Coordinates booking, status changes, and appointment workflows.
Services/Implementations/AppointmentService.cs - Billing · Handles billing and invoice-related business rules.
Services/Implementations/BillingService.cs - Doctors · Business logic for doctor management and schedules.
Services/Implementations/DoctorService.cs - Patients · Patient management and related workflow logic.
Services/Implementations/PatientService.cs - Departments · Department management and lookup logic.
Services/Implementations/DepartmentService.cs - Prescriptions · Creates and manages prescriptions and medication details.
Services/Implementations/PrescriptionService.cs - Appt Repo · Appointment-specific data access built on the generic repository.
Repositories/Implementations/AppointmentRepository.cs - Generic Repo · Shared repository abstraction for common EF Core operations.
Repositories/Implementations/GenericRepository.cs
Persistence
Entity Framework Core database access, schema, and seed data.
- Db Context · ApplicationDbContext and DbSet mappings for the hospital domain.
Data/ApplicationDbContext.cs - Seed Data · Initial data population for users, roles, and reference records.
Data/SeedData.cs - Migrations · EF Core migrations and model snapshot tracking schema evolution.
Data/Migrations/ApplicationDbContextModelSnapshot.cs
Realtime
SignalR notification channel and related push workflow.
- Notifications · Creates notifications and pushes updates to clients.
Services/Implementations/NotificationService.cs - SignalR Hub · Push channel for live notification delivery to connected clients.
Hubs/NotificationHub.cs
Domain
Hospital entities, enums, and view models used across layers.
- Domain Models · Hospital entities such as Patient, Doctor, Appointment, Bill, Prescription, and Notification.
Models/Domain/Appointment.cs - Status Enum · Appointment lifecycle states used across booking and doctor workflows.
Models/Enums/AppointmentStatus.cs - View Models · Presentation shapes for appointment, billing, department, doctor, patient, and prescription screens.
ViewModels/AppointmentViewModel.cs
Host
Application startup and dependency wiring.
- Program · Composition root wiring MVC, Identity, EF Core, services, repositories, and SignalR.
Program.cs
Connections 42
- Program → Admin Area: maps · Registers the admin MVC area in the web host.
- Program → Doctor Area: maps · Registers the doctor MVC area in the web host.
- Program → Patient Area: maps · Registers the patient MVC area in the web host.
- Program → Receptionist Area: maps · Registers the receptionist MVC area in the web host.
- Program → Identity Pages: enables · Configures Identity Razor Pages for authentication.
- Program → Appointments: injects · Wires the appointment workflow service into DI.
- Program → Billing: injects · Wires the billing workflow service into DI.
- Program → Doctors: injects · Wires the doctor workflow service into DI.
- Program → Patients: injects · Wires the patient workflow service into DI.
- Program → Departments: injects · Wires the department workflow service into DI.
- Program → Prescriptions: injects · Wires the prescription workflow service into DI.
- Program → Notifications: injects · Wires the notification service into DI.
- Program → Db Context: configures · Registers EF Core persistence for the application database.
- Program → SignalR Hub: hosts · Maps the real-time notification hub.
- Home → Shared Views: renders · Uses shared MVC layout and templates.
- Admin Area → View Models: uses · Shapes CRUD and booking screens with view models.
- Doctor Area → View Models: uses · Shapes dashboard and prescription screens with view models.
- Patient Area → View Models: uses · Shapes patient dashboard data for views.
- Receptionist Area → View Models: uses · Shapes billing and invoice views.
- Identity Pages → Shared Views: shares · Uses the common layout and partials where applicable.
- Admin Area → Appointments: calls · Admin appointment screens delegate to the appointment service.
- Admin Area → Doctors: calls · Admin doctor screens delegate to doctor management logic.
- Admin Area → Patients: calls · Admin patient screens delegate to patient management logic.
- Admin Area → Departments: calls · Admin department screens delegate to department management logic.
- Doctor Area → Prescriptions: calls · Doctor prescription screens delegate to prescription logic.
- Patient Area → Appointments: calls · Patient dashboard and booking paths use appointment workflows.
- Receptionist Area → Billing: calls · Billing screens delegate to billing workflow logic.
- Appointments → Appt Repo: uses · Appointment workflow persists through the appointment repository.
- Appointments → Notifications: publishes · Appointment changes can trigger notifications.
- Billing → Generic Repo: uses · Billing workflows persist through shared repository operations.
- Doctors → Generic Repo: uses · Doctor workflows rely on shared repository operations.
- Patients → Generic Repo: uses · Patient workflows rely on shared repository operations.
- Departments → Generic Repo: uses · Department workflows rely on shared repository operations.
- Prescriptions → Generic Repo: uses · Prescription workflows rely on shared repository operations.
- Notifications → SignalR Hub: pushes · Notification service broadcasts real-time updates through the hub.
- Appt Repo → Db Context: queries · Appointment repository talks to EF Core context.
- Generic Repo → Db Context: queries · Shared repository talks to EF Core context.
- Db Context → Domain Models: maps · DbContext maps the hospital entities to the database schema.
- Db Context → Status Enum: uses · Appointment entity state transitions rely on the workflow enum.
- Db Context → Migrations: evolves · Schema changes are tracked through EF Core migrations.
- Seed Data → Db Context: seeds · Initial records are inserted through the application context.
- View Models → Domain Models: adapts · View models translate domain entities into UI-specific shapes.