# mustufa-asad8/home-serve architecture

> Architecture diagram of the GitHub repository mustufa-asad8/home-serve, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mustufa-asad8/home-serve
- Repository: https://github.com/mustufa-asad8/home-serve

## Overview

HomeServe is a home-services marketplace and operations platform. Customers discover and filter services, authenticate, and submit bookings; providers manage their assigned requests and publish services; administrators review analytics and intervene in appointments. The React app routes users into role-specific workspaces and calls the Express gateway, which owns public authentication and authorization before accessing the private Django data service and PostgreSQL. The README also documents Socket.IO updates and optional SMTP. Some detailed route and integration links are based on README or SOURCE INDEX references rather than shown source excerpts.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/App.tsx) (App routing), [`apps/web/src/lib/AppContext.tsx`](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/lib/AppContext.tsx) (App state), [`services/gateway/src/services/dataService.js`](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/services/dataService.js) (Internal API client), [`services/gateway/src/app.js`](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/app.js) (HTTP API router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Marketplace web app"]
  node_app["App routing<br/>[App.tsx]"]
  node_context["App state<br/>[AppContext.tsx]"]
  node_api["API client<br/>[api.ts]"]
  node_discovery["Service discovery<br/>[ServicesPage.tsx]"]
  node_servicecard["Service booking entry<br/>[ServiceCard.tsx]"]
  node_booking["Booking drawer<br/>[BookingDrawer.tsx]"]
  node_customerpages["Customer workspace<br/>[DashboardPage.tsx]"]
  node_appointments["Appointment history"]
  node_providerpages["Provider workspace<br/>[ProviderPage.tsx]"]
  node_adminpages["Admin operations<br/>[AdminPage.tsx]"]
  node_authpage["Sign in and register<br/>[AuthPage.tsx]"]
end

subgraph group_gateway["Public API gateway"]
  node_gatewayapp["HTTP API router<br/>[app.js]"]
  node_authroutes["Authentication routes<br/>[auth.js]"]
  node_serviceroutes["Service routes<br/>[services.js]"]
  node_appointmentroutes["Appointment routes<br/>[appointments.js]"]
  node_adminroutes["Admin routes<br/>[admin.js]"]
  node_authmw["Identity and roles<br/>[auth.js]"]
  node_transitions["Status policies<br/>[transitions.js]"]
  node_gatewaydata["Internal API client<br/>[dataService.js]"]
  node_realtime["Socket.IO server<br/>[server.js]"]
  node_email["Email notifications<br/>[email.js]"]
end

subgraph group_data["Private data service"]
  node_dataviews["Internal data API<br/>[views.py]"]
  node_serializers["Data serialization<br/>[serializers.py]"]
  node_models["Marketplace models<br/>[models.py]"]
end

subgraph group_integrations["External systems"]
  node_postgres[("PostgreSQL")]
  node_smtp["SMTP provider"]
end

node_customer(("Customer"))
node_provider(("Provider"))
node_admin(("Administrator"))

node_customer -->|"uses"| node_app
node_provider -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"provides state"| node_context
node_app -->|"routes to"| node_discovery
node_app -->|"routes to"| node_customerpages
node_app -->|"routes to"| node_appointments
node_app -->|"routes to"| node_providerpages
node_app -->|"routes to"| node_adminpages
node_app -->|"routes to"| node_authpage
node_discovery -->|"renders"| node_servicecard
node_servicecard -->|"opens booking"| node_context
node_booking -->|"submits booking"| node_context
node_authpage -->|"authenticates"| node_context
node_customerpages -->|"reads workspace"| node_context
node_appointments -->|"updates appointments"| node_context
node_providerpages -->|"manages jobs"| node_context
node_adminpages -->|"requests operations"| node_context
node_context -->|"requests data"| node_api
node_api -->|"REST requests"| node_gatewayapp
node_gatewayapp -->|"mounts"| node_authroutes
node_gatewayapp -->|"mounts"| node_serviceroutes
node_gatewayapp -->|"mounts"| node_appointmentroutes
node_gatewayapp -->|"mounts"| node_adminroutes
node_authroutes -->|"reads accounts"| node_gatewaydata
node_serviceroutes -->|"guards writes"| node_authmw
node_serviceroutes -->|"reads and writes"| node_gatewaydata
node_appointmentroutes -->|"guards requests"| node_authmw
node_appointmentroutes -->|"checks status"| node_transitions
node_appointmentroutes -->|"reads and writes"| node_gatewaydata
node_adminroutes -->|"authorizes admin"| node_authmw
node_adminroutes -->|"requests analytics"| node_gatewaydata
node_authmw -->|"reloads account"| node_gatewaydata
node_gatewaydata -->|"internal HTTP"| node_dataviews
node_dataviews -->|"serializes"| node_serializers
node_dataviews -->|"queries"| node_models
node_serializers -->|"maps records"| node_models
node_models -->|"persists"| node_postgres
node_customerpages -->|"receives updates"| node_realtime
node_providerpages -->|"receives updates"| node_realtime
node_realtime -->|"verifies account"| node_gatewaydata
node_appointmentroutes -.->|"may notify"| node_email
node_email -.->|"sends mail"| node_smtp

click node_app "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/App.tsx"
click node_context "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/lib/AppContext.tsx"
click node_api "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/lib/api.ts"
click node_discovery "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/ServicesPage.tsx"
click node_servicecard "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/components/ServiceCard.tsx"
click node_booking "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/components/BookingDrawer.tsx"
click node_customerpages "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/DashboardPage.tsx"
click node_appointments "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/AppointmentsPage.tsx"
click node_providerpages "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/ProviderPage.tsx"
click node_adminpages "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/AdminPage.tsx"
click node_authpage "https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/AuthPage.tsx"
click node_gatewayapp "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/app.js"
click node_authroutes "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/auth.js"
click node_serviceroutes "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/services.js"
click node_appointmentroutes "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/appointments.js"
click node_adminroutes "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/admin.js"
click node_authmw "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/middleware/auth.js"
click node_transitions "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/utils/transitions.js"
click node_gatewaydata "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/services/dataService.js"
click node_realtime "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/server.js"
click node_email "https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/services/email.js"
click node_dataviews "https://github.com/mustufa-asad8/home-serve/blob/main/services/data-service/core/views.py"
click node_serializers "https://github.com/mustufa-asad8/home-serve/blob/main/services/data-service/core/serializers.py"
click node_models "https://github.com/mustufa-asad8/home-serve/blob/main/services/data-service/core/models.py"

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_app,node_context,node_api,node_discovery,node_servicecard,node_booking,node_customerpages,node_appointments,node_providerpages,node_adminpages,node_authpage toneBlue
class node_gatewayapp,node_authroutes,node_serviceroutes,node_appointmentroutes,node_adminroutes,node_authmw,node_transitions,node_gatewaydata,node_realtime,node_email toneAmber
class node_dataviews,node_serializers,node_models toneMint
class node_postgres,node_smtp toneRose
class node_customer,node_provider,node_admin toneIndigo
```

## Components

### Marketplace web app

- [App routing](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [App state](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/lib/AppContext.tsx): `apps/web/src/lib/AppContext.tsx`
- [API client](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/lib/api.ts): `apps/web/src/lib/api.ts`
- [Service discovery](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/ServicesPage.tsx): `apps/web/src/pages/ServicesPage.tsx`
- [Service booking entry](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/components/ServiceCard.tsx): `apps/web/src/components/ServiceCard.tsx`
- [Booking drawer](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/components/BookingDrawer.tsx): `apps/web/src/components/BookingDrawer.tsx`
- [Customer workspace](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/DashboardPage.tsx): `apps/web/src/pages/DashboardPage.tsx`
- [Appointment history](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/AppointmentsPage.tsx): `apps/web/src/pages/AppointmentsPage.tsx`
- [Provider workspace](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/ProviderPage.tsx): `apps/web/src/pages/ProviderPage.tsx`
- [Admin operations](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/AdminPage.tsx): `apps/web/src/pages/AdminPage.tsx`
- [Sign in and register](https://github.com/mustufa-asad8/home-serve/blob/main/apps/web/src/pages/AuthPage.tsx): `apps/web/src/pages/AuthPage.tsx`

### Public API gateway

- [HTTP API router](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/app.js): `services/gateway/src/app.js`
- [Authentication routes](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/auth.js): `services/gateway/src/routes/auth.js`
- [Service routes](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/services.js): `services/gateway/src/routes/services.js`
- [Appointment routes](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/appointments.js): `services/gateway/src/routes/appointments.js`
- [Admin routes](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/routes/admin.js): `services/gateway/src/routes/admin.js`
- [Identity and roles](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/middleware/auth.js): `services/gateway/src/middleware/auth.js`
- [Status policies](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/utils/transitions.js): `services/gateway/src/utils/transitions.js`
- [Internal API client](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/services/dataService.js): `services/gateway/src/services/dataService.js`
- [Socket.IO server](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/server.js): `services/gateway/src/server.js`
- [Email notifications](https://github.com/mustufa-asad8/home-serve/blob/main/services/gateway/src/services/email.js): `services/gateway/src/services/email.js`

### Private data service

- [Internal data API](https://github.com/mustufa-asad8/home-serve/blob/main/services/data-service/core/views.py): `services/data-service/core/views.py`
- [Data serialization](https://github.com/mustufa-asad8/home-serve/blob/main/services/data-service/core/serializers.py): `services/data-service/core/serializers.py`
- [Marketplace models](https://github.com/mustufa-asad8/home-serve/blob/main/services/data-service/core/models.py): `services/data-service/core/models.py`

### External systems

- **PostgreSQL**
- **SMTP provider**

### Other components

- **Customer**
- **Provider**
- **Administrator**

## Connections

- Customer → App routing: uses
- Provider → App routing: uses
- Administrator → App routing: uses
- App routing → App state: provides state (evidence: `apps/web/src/App.tsx`)
- App routing → Service discovery: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Customer workspace: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Appointment history: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Provider workspace: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Admin operations: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Sign in and register: routes to (evidence: `apps/web/src/App.tsx`)
- Service discovery → Service booking entry: renders (evidence: `apps/web/src/pages/ServicesPage.tsx`)
- Service booking entry → App state: opens booking (evidence: `apps/web/src/components/ServiceCard.tsx`)
- Booking drawer → App state: submits booking (evidence: `apps/web/src/components/BookingDrawer.tsx`)
- Sign in and register → App state: authenticates (evidence: `apps/web/src/pages/AuthPage.tsx`)
- Customer workspace → App state: reads workspace (evidence: `apps/web/src/pages/DashboardPage.tsx`)
- Appointment history → App state: updates appointments (evidence: `apps/web/src/pages/AppointmentsPage.tsx`)
- Provider workspace → App state: manages jobs (evidence: `apps/web/src/pages/ProviderPage.tsx`)
- Admin operations → App state: requests operations (evidence: `apps/web/src/pages/AdminPage.tsx`)
- App state → API client: requests data (evidence: `apps/web/src/lib/AppContext.tsx`)
- API client → HTTP API router: REST requests
- HTTP API router → Authentication routes: mounts (evidence: `services/gateway/src/app.js`)
- HTTP API router → Service routes: mounts (evidence: `services/gateway/src/app.js`)
- HTTP API router → Appointment routes: mounts (evidence: `services/gateway/src/app.js`)
- HTTP API router → Admin routes: mounts (evidence: `services/gateway/src/app.js`)
- Authentication routes → Internal API client: reads accounts (evidence: `services/gateway/src/routes/auth.js`)
- Service routes → Identity and roles: guards writes (evidence: `services/gateway/src/routes/services.js`)
- Service routes → Internal API client: reads and writes (evidence: `services/gateway/src/routes/services.js`)
- Appointment routes → Identity and roles: guards requests (evidence: `services/gateway/src/routes/appointments.js`)
- Appointment routes → Status policies: checks status (evidence: `services/gateway/src/routes/appointments.js`)
- Appointment routes → Internal API client: reads and writes (evidence: `services/gateway/src/routes/appointments.js`)
- Admin routes → Identity and roles: authorizes admin (evidence: `services/gateway/src/routes/admin.js`)
- Admin routes → Internal API client: requests analytics (evidence: `services/gateway/src/routes/admin.js`)
- Identity and roles → Internal API client: reloads account (evidence: `services/gateway/src/middleware/auth.js`)
- Internal API client → Internal data API: internal HTTP
- Internal data API → Data serialization: serializes (evidence: `services/data-service/core/views.py`)
- Internal data API → Marketplace models: queries (evidence: `services/data-service/core/views.py`)
- Data serialization → Marketplace models: maps records (evidence: `services/data-service/core/serializers.py`)
- Marketplace models → PostgreSQL: persists
- Customer workspace → Socket.IO server: receives updates
- Provider workspace → Socket.IO server: receives updates
- Socket.IO server → Internal API client: verifies account (evidence: `services/gateway/src/server.js`)
- Appointment routes → Email notifications: may notify (evidence: `services/gateway/src/routes/appointments.js`)
- Email notifications → SMTP provider: sends mail
