# sammmuley-oss/swiftplay_turf architecture

> Architecture diagram of the GitHub repository sammmuley-oss/swiftplay_turf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sammmuley-oss/swiftplay_turf
- Repository: https://github.com/sammmuley-oss/swiftplay_turf

## Overview

Swiftplay Turf appears to be a sports-equipment rental kiosk: customers browse equipment, book a timed session, pay, and return gear; administrators have inventory and session views. The sampled code confirms catalog loading, OTP authentication, and the catalog’s payment calls. Rentals, returns, admin operations, and live updates are documented by the route/page structure and server setup, but their internal wiring is not shown in the excerpts, so those links are kept conservative.

Main entry points: [`backend/src/server.js`](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/server.js) (API server), [`backend/src/routes/admin.js`](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/admin.js) (Admin routes), [`frontend/src/App.tsx`](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/App.tsx) (Kiosk app), [`backend/src/models/RentalSession.js`](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/models/RentalSession.js) (Rental data models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer kiosk"]
  node_app["Kiosk app<br/>[App.tsx]"]
  node_catalog["Catalog and booking<br/>[CatalogScreen.tsx]"]
  node_active["Active rental"]
  node_return["Equipment return<br/>[ReturnScreen.tsx]"]
  node_login["Login<br/>[LoginScreen.tsx]"]
  node_equipment_service["Equipment service"]
  node_equipment_cache["Catalog cache<br/>[equipmentCache.ts]"]
  node_auth_api["Auth API proxy<br/>[initiate-2fa.js]"]
  node_verify_auth_api["OTP verify proxy<br/>[verify-2fa.js]"]
end

subgraph group_backend["Rental backend"]
  node_server["API server<br/>[server.js]"]
  node_auth_routes["Authentication routes<br/>[auth.js]"]
  node_equipment_routes["Equipment routes<br/>[equipment.js]"]
  node_rental_routes["Rental routes<br/>[rentals.js]"]
  node_payment_routes["Payment routes<br/>[payments.js]"]
  node_admin_routes["Admin routes<br/>[admin.js]"]
  node_models[("Rental data models<br/>[RentalSession.js]")]
  node_auth_middleware["Auth middleware<br/>[authMiddleware.js]"]
  node_realtime["Realtime service<br/>[realtime.js]"]
  node_iot["IoT simulation<br/>[iotSimulation.js]"]
end

subgraph group_operations["Admin operations"]
  node_admin_app["Admin dashboard"]
  node_admin_inventory["Inventory management"]
  node_admin_sessions["Session history"]
end

subgraph group_integrations["External services"]
  node_mongo[("MongoDB")]
  node_email["Email service<br/>[mailer.js]"]
  node_razorpay["Razorpay"]
  node_socket_clients(("Realtime clients"))
end

node_customer(("Customer"))

node_customer -->|"uses"| node_app
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_active
node_app -->|"routes to"| node_return
node_app -->|"routes to"| node_login
node_catalog -->|"loads catalog"| node_equipment_service
node_equipment_service -->|"reads and writes"| node_equipment_cache
node_equipment_service -->|"requests equipment"| node_equipment_routes
node_catalog -->|"creates and verifies orders"| node_payment_routes
node_login -->|"initiates OTP"| node_auth_api
node_login -->|"verifies OTP"| node_verify_auth_api
node_server -->|"mounts auth"| node_auth_routes
node_server -->|"mounts equipment"| node_equipment_routes
node_server -->|"mounts rentals"| node_rental_routes
node_server -->|"mounts payments"| node_payment_routes
node_server -->|"mounts admin"| node_admin_routes
node_server -->|"registers handlers"| node_realtime
node_server -->|"connects"| node_mongo
node_auth_routes -->|"uses OTP and user models"| node_models
node_auth_routes -->|"sends OTP"| node_email
node_auth_routes -->|"protected routes use"| node_auth_middleware
node_rental_routes -->|"rental data"| node_models
node_equipment_routes -->|"equipment data"| node_models
node_admin_routes -->|"protects admin access"| node_auth_middleware
node_admin_routes -->|"admin data"| node_models
node_payment_routes -->|"processes payments"| node_razorpay
node_payment_routes -->|"records rental payment"| node_models
node_realtime -->|"dispatches updates"| node_socket_clients
node_iot -.->|"simulates events"| node_realtime
node_admin_app -->|"admin requests"| node_admin_routes
node_admin_inventory -->|"manages inventory"| node_admin_routes
node_admin_sessions -->|"views sessions"| node_admin_routes

click node_app "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/App.tsx"
click node_catalog "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/CatalogScreen.tsx"
click node_active "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/ActiveRentalScreen.tsx"
click node_return "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/ReturnScreen.tsx"
click node_login "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/LoginScreen.tsx"
click node_equipment_service "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/lib/equipmentService.ts"
click node_equipment_cache "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/lib/equipmentCache.ts"
click node_auth_api "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/api/auth/initiate-2fa.js"
click node_verify_auth_api "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/api/auth/verify-2fa.js"
click node_server "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/server.js"
click node_auth_routes "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/auth.js"
click node_equipment_routes "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/equipment.js"
click node_rental_routes "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/rentals.js"
click node_payment_routes "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/payments.js"
click node_admin_routes "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/admin.js"
click node_models "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/models/RentalSession.js"
click node_auth_middleware "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/middleware/authMiddleware.js"
click node_realtime "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/services/realtime.js"
click node_iot "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/services/iotSimulation.js"
click node_admin_app "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/admin/AdminDashboardScreen.tsx"
click node_admin_inventory "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/admin/AdminInventoryScreen.tsx"
click node_admin_sessions "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/admin/AdminSessionsScreen.tsx"
click node_email "https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/services/mailer.js"

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_catalog,node_active,node_return,node_login,node_equipment_service,node_equipment_cache,node_auth_api,node_verify_auth_api toneBlue
class node_server,node_auth_routes,node_equipment_routes,node_rental_routes,node_payment_routes,node_admin_routes,node_models,node_auth_middleware,node_realtime,node_iot toneAmber
class node_admin_app,node_admin_inventory,node_admin_sessions toneMint
class node_mongo,node_email,node_razorpay,node_socket_clients toneRose
class node_customer toneIndigo
```

## Components

### Customer kiosk

- [Kiosk app](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Catalog and booking](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/CatalogScreen.tsx): `frontend/src/pages/CatalogScreen.tsx`
- [Active rental](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/ActiveRentalScreen.tsx): `frontend/src/pages/ActiveRentalScreen.tsx`
- [Equipment return](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/ReturnScreen.tsx): `frontend/src/pages/ReturnScreen.tsx`
- [Login](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/LoginScreen.tsx): `frontend/src/pages/LoginScreen.tsx`
- [Equipment service](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/lib/equipmentService.ts): `frontend/src/lib/equipmentService.ts`
- [Catalog cache](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/lib/equipmentCache.ts): `frontend/src/lib/equipmentCache.ts`
- [Auth API proxy](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/api/auth/initiate-2fa.js): `frontend/api/auth/initiate-2fa.js`
- [OTP verify proxy](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/api/auth/verify-2fa.js): `frontend/api/auth/verify-2fa.js`

### Rental backend

- [API server](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/server.js): `backend/src/server.js`
- [Authentication routes](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Equipment routes](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/equipment.js): `backend/src/routes/equipment.js`
- [Rental routes](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/rentals.js): `backend/src/routes/rentals.js`
- [Payment routes](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/payments.js): `backend/src/routes/payments.js`
- [Admin routes](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/routes/admin.js): `backend/src/routes/admin.js`
- [Rental data models](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/models/RentalSession.js): `backend/src/models/RentalSession.js`
- [Auth middleware](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/middleware/authMiddleware.js): `backend/src/middleware/authMiddleware.js`
- [Realtime service](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/services/realtime.js): `backend/src/services/realtime.js`
- [IoT simulation](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/services/iotSimulation.js): `backend/src/services/iotSimulation.js`

### Admin operations

- [Admin dashboard](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/admin/AdminDashboardScreen.tsx): `frontend/src/pages/admin/AdminDashboardScreen.tsx`
- [Inventory management](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/admin/AdminInventoryScreen.tsx): `frontend/src/pages/admin/AdminInventoryScreen.tsx`
- [Session history](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/frontend/src/pages/admin/AdminSessionsScreen.tsx): `frontend/src/pages/admin/AdminSessionsScreen.tsx`

### External services

- **MongoDB**
- [Email service](https://github.com/sammmuley-oss/swiftplay_turf/blob/main/backend/src/services/mailer.js): `backend/src/services/mailer.js`
- **Razorpay**
- **Realtime clients**

### Other components

- **Customer**

## Connections

- Customer → Kiosk app: uses
- Kiosk app → Catalog and booking: routes to
- Kiosk app → Active rental: routes to
- Kiosk app → Equipment return: routes to
- Kiosk app → Login: routes to
- Catalog and booking → Equipment service: loads catalog
- Equipment service → Catalog cache: reads and writes
- Equipment service → Equipment routes: requests equipment
- Catalog and booking → Payment routes: creates and verifies orders
- Login → Auth API proxy: initiates OTP
- Login → OTP verify proxy: verifies OTP
- API server → Authentication routes: mounts auth
- API server → Equipment routes: mounts equipment
- API server → Rental routes: mounts rentals
- API server → Payment routes: mounts payments
- API server → Admin routes: mounts admin
- API server → Realtime service: registers handlers
- API server → MongoDB: connects
- Authentication routes → Rental data models: uses OTP and user models
- Authentication routes → Email service: sends OTP
- Authentication routes → Auth middleware: protected routes use
- Rental routes → Rental data models: rental data
- Equipment routes → Rental data models: equipment data
- Admin routes → Auth middleware: protects admin access
- Admin routes → Rental data models: admin data
- Payment routes → Razorpay: processes payments
- Payment routes → Rental data models: records rental payment
- Realtime service → Realtime clients: dispatches updates
- IoT simulation → Realtime service: simulates events
- Admin dashboard → Admin routes: admin requests
- Inventory management → Admin routes: manages inventory
- Session history → Admin routes: views sessions
