# parth-yangandul-df/calendar-booking architecture

> Architecture diagram of the GitHub repository parth-yangandul-df/calendar-booking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parth-yangandul-df/calendar-booking
- Repository: https://github.com/parth-yangandul-df/calendar-booking

## Overview

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: [`src/backend/Application`](https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Application) (Use Cases), [`client/src/App.tsx`](https://github.com/parth-yangandul-df/calendar-booking/blob/main/client/src/App.tsx) (App Shell), [`src/backend/Api/Program.cs`](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Program.cs) (API Host), [`src/backend/Api/Controllers/AuthController.cs`](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AuthController.cs) (Auth Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client SPA"]
  node_client_app["App Shell<br/>React/Vite shell<br/>[App.tsx]"]
  node_client_auth["Auth Flow<br/>feature area"]
  node_client_availability["Availability<br/>feature area"]
  node_client_booking["Booking<br/>feature area"]
  node_client_admin["Admin<br/>feature area"]
  node_client_routeguard["Route Guards<br/>auth/ui guard<br/>[ProtectedRoute.tsx]"]
end

subgraph group_backend_api["Backend API"]
  node_api_entry["API Host<br/>ASP.NET Core host<br/>[Program.cs]"]
  node_api_middleware["Error Middleware<br/>cross-cutting middleware"]
  node_api_auth["Auth Controller<br/>[AuthController.cs]"]
  node_api_availability["Availability Controller"]
  node_api_booking["Booking Controller"]
  node_api_admin["Admin Controller<br/>[AdminController.cs]"]
end

subgraph group_backend_app["Application & Domain"]
  node_app_usecases["Use Cases<br/>application layer"]
  node_app_validators["Validators<br/>input rules"]
  node_domain_model["Domain Model<br/>core model"]
end

subgraph group_backend_infra["Infrastructure"]
  node_infra_db[("EF Core DbContext<br/>persistence boundary")]
  node_infra_repos["Repositories<br/>data access"]
  node_infra_jobs["Background Jobs<br/>async processing"]
  node_infra_email["Email Service<br/>smtp integration<br/>[EmailService.cs]"]
  node_infra_calendar["Calendar Service<br/>google integration"]
  node_infra_token["Token Service<br/>security service<br/>[TokenService.cs]"]
end

subgraph group_external["External Services"]
  node_sql_server[("SQL Server<br/>database")]
  node_smtp["SMTP<br/>external service"]
  node_google_calendar["Google Calendar<br/>external service"]
  node_hangfire["Hangfire<br/>job runner"]
end

node_client_app -->|"routes to"| node_client_auth
node_client_app -->|"routes to"| node_client_availability
node_client_app -->|"routes to"| node_client_booking
node_client_app -->|"routes to"| node_client_admin
node_client_app -->|"protects"| node_client_routeguard
node_client_auth -->|"calls"| node_api_auth
node_client_availability -->|"calls"| node_api_availability
node_client_booking -->|"calls"| node_api_booking
node_client_admin -->|"calls"| node_api_admin
node_api_entry -->|"uses"| node_api_middleware
node_api_entry -->|"hosts"| node_api_auth
node_api_entry -->|"hosts"| node_api_availability
node_api_entry -->|"hosts"| node_api_booking
node_api_entry -->|"hosts"| node_api_admin
node_api_auth -->|"delegates to"| node_app_usecases
node_api_availability -->|"delegates to"| node_app_usecases
node_api_booking -->|"delegates to"| node_app_usecases
node_api_admin -->|"delegates to"| node_app_usecases
node_app_usecases -->|"validates with"| node_app_validators
node_app_usecases -->|"models"| node_domain_model
node_app_usecases -->|"depends on"| node_infra_repos
node_infra_repos -->|"uses"| node_infra_db
node_infra_db -->|"stores in"| node_sql_server
node_infra_jobs -->|"queues on"| node_hangfire
node_infra_jobs -->|"dispatches"| node_infra_email
node_infra_email -->|"sends via"| node_smtp
node_infra_calendar -->|"syncs with"| node_google_calendar
node_infra_token -->|"supports"| node_api_auth
node_api_auth -->|"uses"| node_infra_token
node_app_usecases -->|"uses"| node_infra_calendar
node_app_usecases -->|"enqueues"| node_infra_jobs
node_app_usecases -->|"persists"| node_infra_repos

click node_client_app "https://github.com/parth-yangandul-df/calendar-booking/blob/main/client/src/App.tsx"
click node_client_auth "https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/auth"
click node_client_availability "https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/availability"
click node_client_booking "https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/booking"
click node_client_admin "https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/admin"
click node_client_routeguard "https://github.com/parth-yangandul-df/calendar-booking/blob/main/client/src/components/layout/ProtectedRoute.tsx"
click node_api_entry "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Program.cs"
click node_api_middleware "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Middleware/ExceptionHandlingMiddleware.cs"
click node_api_auth "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AuthController.cs"
click node_api_availability "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AvailabilityController.cs"
click node_api_booking "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/BookingController.cs"
click node_api_admin "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AdminController.cs"
click node_app_usecases "https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Application"
click node_app_validators "https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Application"
click node_domain_model "https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Domain"
click node_infra_db "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Data/ApplicationDbContext.cs"
click node_infra_repos "https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Infrastructure/Repositories"
click node_infra_jobs "https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Infrastructure/Jobs"
click node_infra_email "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Email/EmailService.cs"
click node_infra_calendar "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Services/GoogleCalendarService.cs"
click node_infra_token "https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Services/TokenService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_app,node_client_auth,node_client_availability,node_client_booking,node_client_admin,node_client_routeguard toneBlue
class node_api_entry,node_api_middleware,node_api_auth,node_api_availability,node_api_booking,node_api_admin toneAmber
class node_app_usecases,node_app_validators,node_domain_model toneMint
class node_infra_db,node_infra_repos,node_infra_jobs,node_infra_email,node_infra_calendar,node_infra_token toneRose
class node_sql_server,node_smtp,node_google_calendar,node_hangfire toneIndigo
```

## Components

### Client SPA

React/Vite single-page app with feature-organized screens and local orchestration.

- [App Shell](https://github.com/parth-yangandul-df/calendar-booking/blob/main/client/src/App.tsx): React/Vite shell · Top-level SPA composition, routing, and page wiring. · `client/src/App.tsx`
- [Auth Flow](https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/auth): feature area · Login, register, session state, and route protection. · `client/src/features/auth`
- [Availability](https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/availability): feature area · Calendar views, template editing, and user availability browsing. · `client/src/features/availability`
- [Booking](https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/booking): feature area · Booking pages, tabs, confirmations, and booking timeline UI. · `client/src/features/booking`
- [Admin](https://github.com/parth-yangandul-df/calendar-booking/tree/main/client/src/features/admin): feature area · Administrative stats, lists, and management screens. · `client/src/features/admin`
- [Route Guards](https://github.com/parth-yangandul-df/calendar-booking/blob/main/client/src/components/layout/ProtectedRoute.tsx): auth/ui guard · 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](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Program.cs): ASP.NET Core host · Program bootstrap and cross-cutting middleware pipeline. · `src/backend/Api/Program.cs`
- [Error Middleware](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Middleware/ExceptionHandlingMiddleware.cs): cross-cutting middleware · Centralized exception handling and API error policy. · `src/backend/Api/Middleware/ExceptionHandlingMiddleware.cs`
- [Auth Controller](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AuthController.cs): controller · Authentication endpoints for login, register, refresh, and session setup. · `src/backend/Api/Controllers/AuthController.cs`
- [Availability Controller](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AvailabilityController.cs): controller · Endpoints for templates, overrides, and calendar-day views. · `src/backend/Api/Controllers/AvailabilityController.cs`
- [Booking Controller](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/BookingController.cs): controller · Booking creation, updates, and status changes. · `src/backend/Api/Controllers/BookingController.cs`
- [Admin Controller](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Api/Controllers/AdminController.cs): 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](https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Application): application layer · Feature application services, DTOs, and request orchestration. · `src/backend/Application`
- [Validators](https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Application): input rules · Request validation for auth, availability, and booking commands. · `src/backend/Application`
- [Domain Model](https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Domain): core 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](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Data/ApplicationDbContext.cs): persistence boundary · ApplicationDbContext and schema configurations for the scheduling model. · `src/backend/Infrastructure/Data/ApplicationDbContext.cs`
- [Repositories](https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Infrastructure/Repositories): data access · Persistence adapters for availability, bookings, and refresh tokens. · `src/backend/Infrastructure/Repositories`
- [Background Jobs](https://github.com/parth-yangandul-df/calendar-booking/tree/main/src/backend/Infrastructure/Jobs): async processing · Booking email job service and queued email execution. · `src/backend/Infrastructure/Jobs`
- [Email Service](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Email/EmailService.cs): smtp integration · MailKit-based booking notification delivery and templates. · `src/backend/Infrastructure/Email/EmailService.cs`
- [Calendar Service](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Services/GoogleCalendarService.cs): google integration · Google Calendar event creation and Meet link support. · `src/backend/Infrastructure/Services/GoogleCalendarService.cs`
- [Token Service](https://github.com/parth-yangandul-df/calendar-booking/blob/main/src/backend/Infrastructure/Services/TokenService.cs): security 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**: database · Primary relational store for app data, identities, and Hangfire state.
- **SMTP**: external service · Outbound mail transport for booking notifications.
- **Google Calendar**: external service · Calendar and Meet integration target for bookings.
- **Hangfire**: job runner · Background job processing backed by the SQL Server store.

## Connections

- 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.
