How parth-yangandul-df/calendar-booking works
1. System shape
- This is a two-tier scheduling platform: a React/Vite frontend in client/ and an ASP.NET Core 8 Web API backend in src/backend/.
- The backend follows a Clean Architecture split into Domain, Application, Infrastructure, and Api, with SQL Server as the primary persistence layer.
2. Frontend boundary
- The client is a single-page app built with React 19, Vite, Tailwind, and shadcn/ui.
- It is organized by feature areas: auth, availability, booking, and admin.
- The frontend owns routing, screens, local UI composition, and request orchestration through feature-specific API modules and hooks.
3. Frontend authentication and access control
- Authentication state is managed in features/auth/AuthContext.tsx and consumed via useAuth.
- Route protection is enforced through components such as ProtectedRoute and AdminGuard.
- The auth flow is cookie-based from the client’s perspective: the backend issues JWTs in httpOnly cookies, so the client mostly relies on session state and API responses rather than storing tokens directly.
4. Backend API boundary
- The Api project exposes controllers for Auth, Availability, Booking, Admin, and Users.
- Controllers are thin entry points: they validate the request, call application-layer services/use cases, and return DTOs.
- Global exception handling is centralized in ExceptionHandlingMiddleware, so error policy is cross-cutting rather than duplicated per controller.
5. Application layer responsibilities
- The Application project is the use-case layer and contains DTOs, validators, and interfaces for repositories and services.
- Feature namespaces mirror the product areas: Auth, Availability, Booking, and Admin.
- Validation is handled with request validators, indicating that business input rules are enforced before reaching infrastructure.
6. Domain model
- Core business entities live in Domain: ApplicationUser, WeeklyTemplate, AvailabilityOverride, Booking, and RefreshToken.
- Important enums include BookingStatus and UserRole, which shape access control and booking lifecycle behavior.
- This layer represents the actual scheduling model: users define availability templates and overrides, and bookings reserve time against that model.
7. Persistence and data access
- Infrastructure/Data/ApplicationDbContext.cs is the EF Core persistence boundary.
- Repositories in Infrastructure/Repositories implement the application interfaces for availability, bookings, and refresh tokens.
- EF Core migrations show the system’s schema evolution, including availability management, booking engine, and Google event ID support.
8. Availability subsystem
- Availability is modeled around monthly calendar views on the frontend and weekly templates plus date-specific overrides on the backend.
- The client includes calendar grid, day-side panel, time-range editor, and user search features.
- Backend DTOs support calendar-day views, templates, and overrides, suggesting availability is read and written through structured calendar-shaped data rather than simple CRUD.
9. Booking subsystem
- Booking is its own feature slice end-to-end: frontend booking pages and tabs map to backend booking controllers, DTOs, and validators.
- The booking flow likely checks user availability, creates a booking record, and tracks status changes through BookingStatus.
- The presence of BookingTimeline, confirmation dialogs, and incoming/my-bookings tabs suggests a split between requester and recipient views.
10. Admin subsystem
- Admin functionality is isolated into its own feature on both sides.
- Backend admin DTOs include booking, user, and stats shapes, which implies reporting and moderation views rather than core scheduling operations.
- Frontend admin components such as stat cards and pagination controls indicate table/list-oriented management screens.
11. External services and operational integrations
- SQL Server is the backing database for EF Core and also the store for Hangfire jobs.
- MailKit SMTP is used for booking-related email notifications.
- Google Calendar integration is present via GoogleCalendarService, and the README says bookings generate Google Meet links, so calendar event creation is part of the booking workflow.
- BookingEmailJobService and SendBookingEmailJob indicate asynchronous background processing for email delivery.
12. Security and session management
- ASP.NET Core Identity is combined with a custom JWT implementation and refresh tokens.
- Refresh tokens are persisted via repository and entity support, implying server-managed session renewal.
- Role-based behavior is important because admin access is separated from regular authenticated users.
13. Suggested diagram boundaries
- Draw three major boxes: Client SPA, Backend API, and Infrastructure services.
- Inside the backend, show the layered flow: Controllers → Application → Domain → Infrastructure → SQL Server / external services.
- The key external dependencies to show are SQL Server, SMTP, Google Calendar/Meet, and Hangfire job processing.
Main entry points: Application Use Cases · App.tsx App Shell · Program.cs API Host · AuthController.cs Auth Controller
Components 25
Client SPA
React/Vite single-page app with feature-organized screens and local orchestration.
- App Shell · Top-level SPA composition, routing, and page wiring.
client/src/App.tsx - Auth Flow · Login, register, session state, and route protection.
client/src/features/auth - Availability · Calendar views, template editing, and user availability browsing.
client/src/features/availability - Booking · Booking pages, tabs, confirmations, and booking timeline UI.
client/src/features/booking - Admin · Administrative stats, lists, and management screens.
client/src/features/admin - Route Guards · ProtectedRoute and AdminGuard gate access by session and role.
client/src/components/layout/ProtectedRoute.tsx
Backend API
ASP.NET Core controllers and middleware entry point.
- API Host · Program bootstrap and cross-cutting middleware pipeline.
src/backend/Api/Program.cs - Error Middleware · Centralized exception handling and API error policy.
src/backend/Api/Middleware/ExceptionHandlingMiddleware.cs - Auth Controller · Authentication endpoints for login, register, refresh, and session setup.
src/backend/Api/Controllers/AuthController.cs - Availability Controller · Endpoints for templates, overrides, and calendar-day views.
src/backend/Api/Controllers/AvailabilityController.cs - Booking Controller · Booking creation, updates, and status changes.
src/backend/Api/Controllers/BookingController.cs - Admin Controller · Administrative booking, user, and stats endpoints.
src/backend/Api/Controllers/AdminController.cs
Application & Domain
Use cases, DTOs, validators, and core scheduling model.
- Use Cases · Feature application services, DTOs, and request orchestration.
src/backend/Application - Validators · Request validation for auth, availability, and booking commands.
src/backend/Application - Domain Model · Users, availability templates and overrides, bookings, tokens, and roles.
src/backend/Domain
Infrastructure
EF Core persistence, repositories, jobs, email, and external integrations.
- EF Core DbContext · ApplicationDbContext and schema configurations for the scheduling model.
src/backend/Infrastructure/Data/ApplicationDbContext.cs - Repositories · Persistence adapters for availability, bookings, and refresh tokens.
src/backend/Infrastructure/Repositories - Background Jobs · Booking email job service and queued email execution.
src/backend/Infrastructure/Jobs - Email Service · MailKit-based booking notification delivery and templates.
src/backend/Infrastructure/Email/EmailService.cs - Calendar Service · Google Calendar event creation and Meet link support.
src/backend/Infrastructure/Services/GoogleCalendarService.cs - Token Service · JWT issuance and refresh-token support for session renewal.
src/backend/Infrastructure/Services/TokenService.cs
External Services
Database and third-party operational dependencies.
- SQL Server · Primary relational store for app data, identities, and Hangfire state.
- SMTP · Outbound mail transport for booking notifications.
- Google Calendar · Calendar and Meet integration target for bookings.
- Hangfire · Background job processing backed by the SQL Server store.
Connections 32
- App Shell → Auth Flow: routes to · SPA routes into auth-related screens and session state.
- App Shell → Availability: routes to · SPA exposes availability calendars and editors.
- App Shell → Booking: routes to · SPA exposes booking pages and booking tabs.
- App Shell → Admin: routes to · SPA exposes admin management screens.
- App Shell → Route Guards: protects · Top-level routing is gated by auth and role checks.
- Auth Flow → Auth Controller: calls · Client auth module talks to auth endpoints using cookie-based sessions.
- Availability → Availability Controller: calls · Availability UI reads and writes calendar-shaped DTOs.
- Booking → Booking Controller: calls · Booking UI orchestrates booking requests and updates.
- Admin → Admin Controller: calls · Admin UI loads reports and management data.
- API Host → Error Middleware: uses · Host config wires centralized exception handling.
- API Host → Auth Controller: hosts · API host exposes auth controller endpoints.
- API Host → Availability Controller: hosts · API host exposes availability controller endpoints.
- API Host → Booking Controller: hosts · API host exposes booking controller endpoints.
- API Host → Admin Controller: hosts · API host exposes admin controller endpoints.
- Auth Controller → Use Cases: delegates to · Controller hands auth work to application use cases.
- Availability Controller → Use Cases: delegates to · Controller hands availability work to application use cases.
- Booking Controller → Use Cases: delegates to · Controller hands booking work to application use cases.
- Admin Controller → Use Cases: delegates to · Controller hands admin work to application use cases.
- Use Cases → Validators: validates with · Commands and requests are checked before persistence.
- Use Cases → Domain Model: models · Use cases operate on core scheduling entities and enums.
- Use Cases → Repositories: depends on · Application layer relies on repository interfaces/adapters.
- Repositories → EF Core DbContext: uses · Repositories persist through EF Core DbContext.
- EF Core DbContext → SQL Server: stores in · EF Core schema and data live in SQL Server.
- Background Jobs → Hangfire: queues on · Email jobs are executed through Hangfire.
- Background Jobs → Email Service: dispatches · Background jobs invoke email delivery.
- Email Service → SMTP: sends via · MailKit sends notification email over SMTP.
- Calendar Service → Google Calendar: syncs with · Bookings create or update Google Calendar events.
- Token Service → Auth Controller: supports · Token issuance and refresh power authentication responses.
- Auth Controller → Token Service: uses · Auth controller relies on token issuance and renewal.
- Use Cases → Calendar Service: uses · Booking flow can create external calendar events.
- Use Cases → Background Jobs: enqueues · Booking flow triggers deferred email work.
- Use Cases → Repositories: persists · Availability, booking, and refresh-token data are stored through repositories.