How borismirsky/medical-booking works
Purpose and Runtime
Medical-Booking is a role-based doctor discovery, scheduling, booking, and clinical-record system. It runs as a .NET Web API backend with a Next.js/React/TypeScript frontend. Roles are admin, doctor, and patient. Primary entry points are backend/MedicalBookingProject/src/MedicalBookingProject.Web/Program.cs and frontend/medical-booking/app/page.tsx.
Backend Layering
The backend follows a Clean Architecture-style split:
• Domain owns entities, DTOs, and service/repository interfaces: backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Models, backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Abstractions.
• Application implements use-case services: backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/BookingService.cs, backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/AppointmentService.cs, backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/TimeslotService.cs.
• Data access implements persistence and JWT infrastructure: backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/MedicalBookingDbContext.cs, backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Repo, backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Scripts/JwtGenerator.cs.
• Web exposes HTTP contracts and controllers: backend/MedicalBookingProject/src/MedicalBookingProject.Web/Controllers, backend/MedicalBookingProject/src/MedicalBookingProject.Web/Contracts.
Identity and Authorization Boundary
Admin, doctor, and patient are distinct domain user models, with roles represented in the domain. Authentication issues JWTs; the browser stores tokens in localStorage. This is the critical trust boundary between frontend requests and protected backend workflows. Relevant paths: backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Models/Users, backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Scripts/JwtGenerator.cs, frontend/medical-booking/app/Services/service.tsx.
Scheduling and Booking Flow
Admins create doctors and schedules/timeslots. Patients inspect available doctor slots, create or cancel bookings, and see their booking history. Doctors view their schedules; booked slots lead to appointment creation. Core models and services are backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Models/Shedules/Timeslot.cs, backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/TimeslotService.cs, and backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/BookingService.cs.
Appointment and Medical Record Flow
A doctor turns a booked consultation into an appointment and records clinical information. Appointment and medical-record services mediate this transition before repository persistence. API boundaries are represented by request/response contracts and dedicated controllers: backend/MedicalBookingProject/src/MedicalBookingProject.Web/Controllers/AppointmentsController.cs, backend/MedicalBookingProject/src/MedicalBookingProject.Web/Controllers/MedicalrecordsController.cs, backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/MedicalrecordService.cs.
Persistence and Infrastructure
Entity Framework configurations map domain entities through the DbContext and repository implementations. The deployed/local persistence dependency is a checked-in SQLite database rather than an external managed service: backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Database/medical_booking_db.db, backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Configuration, backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Repo.
Frontend Role Workspaces
Next.js App Router pages route users into separate role-oriented entry and profile pages. Components encode the primary user workflows: admin manages doctors/schedules, patient registers and books, and doctor manages appointments and records. Paths: frontend/medical-booking/app/profileadmin/page.tsx, frontend/medical-booking/app/profilepatient/page.tsx, frontend/medical-booking/app/profiledoctor/page.tsx.
Main entry points: Controllers Controllers · Abstractions Domain abstractions · TimeslotService.cs Timeslot service · AppointmentsController.cs Appointment & records API
Components 19
Next.js frontend
- App entry
frontend/medical-booking/app/page.tsx - Role workspaces · Separate admin, patient, and doctor workflows.
frontend/medical-booking/app/profileadmin/page.tsx - API client & token store · Stores JWTs in localStorage and sends API requests.
frontend/medical-booking/app/Services/service.tsx
API boundary
- Web API host
backend/MedicalBookingProject/src/MedicalBookingProject.Web/Program.cs - Controllers
backend/MedicalBookingProject/src/MedicalBookingProject.Web/Controllers - API contracts
backend/MedicalBookingProject/src/MedicalBookingProject.Web/Contracts - Appointment & records API · Exposes appointment and clinical-record endpoints.
backend/MedicalBookingProject/src/MedicalBookingProject.Web/Controllers/AppointmentsController.cs
Application services
- Booking service · Creates, cancels, and lists patient bookings.
backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/BookingService.cs - Timeslot service · Manages doctor schedules and available slots.
backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/TimeslotService.cs - Appointment service · Turns booked consultations into appointments.
backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/AppointmentService.cs - Medical record service · Persists doctor clinical records.
backend/MedicalBookingProject/src/MedicalBookingProject.Application/Services/MedicalrecordService.cs
Domain
- Domain models
backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Models - Users & roles · Admin, doctor, and patient identities define role access.
backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Models/Users - Timeslot · Represents a doctor consultation slot and booking state.
backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Models/Shedules/Timeslot.cs - Domain abstractions
backend/MedicalBookingProject/src/MedicalBookingProject.Domain/Abstractions
Data access
- Repository implementations
backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Repo - EF DbContext
backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/MedicalBookingDbContext.cs - SQLite database
backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Database/medical_booking_db.db - JWT generator · Issues tokens after authentication.
backend/MedicalBookingProject/src/MedicalBookingProject.DataAccess/Scripts/JwtGenerator.cs
Connections 22
- App entry → Role workspaces: routes users
- Role workspaces → API client & token store: invokes
- API client & token store → Web API host: HTTP with JWT
- Web API host → Controllers: hosts
- Controllers → API contracts: binds
- Controllers → Booking service: booking requests
- Controllers → Timeslot service: schedule requests
- Appointment & records API → Appointment service: appointment workflow
- Appointment & records API → Medical record service: record workflow
- Controllers → Appointment & records API: includes
- Booking service → Domain abstractions: uses
- Timeslot service → Timeslot: manages
- Timeslot service → Domain abstractions: uses
- Appointment service → Domain abstractions: uses
- Medical record service → Domain abstractions: uses
- Repository implementations → Domain abstractions: implements
- Repository implementations → EF DbContext: persists through
- EF DbContext → SQLite database: maps to
- Controllers → JWT generator: authenticates via
- JWT generator → Users & roles: creates claims for
- Domain models → Users & roles: contains
- Domain models → Timeslot: contains