How not-rishi/quickpool works
1. QuickPool is split into two main runtime applications: a Node/Express backend in backend/ and an Expo/React Native client in frontend/. The backend exposes the business API and admin endpoints; the frontend is the mobile UI that consumes those APIs.
2. The backend entrypoint is backend/server.js, with config/db.js establishing the database connection. The code is organized in a standard request pipeline: routes map HTTP paths to controllers, controllers implement domain actions, middleware handles auth/error cross-cutting concerns, and models represent persisted records.
3. The domain model is centered on route-based ride pooling. Core entities include User, Route, Group, Queue, Swap, RideHistory, plus incident/exception records like PanicReport and NoShowReport. This suggests the system tracks users, available routes, group formation, queueing, swaps, and ride outcomes over time.
4. Authentication is OTP-based rather than password-based. authController, OTP model, generateOTP, generateToken, and emailService indicate a flow where the backend generates a one-time code, emails it to the user, verifies it, then issues a token for subsequent requests.
5. Matching and assignment logic is separated into services/matchingService.js, which is the main business-logic boundary beyond basic CRUD. That service likely computes route/group placement and queue decisions, while controllers remain thin orchestration layers.
6. Emergency and exception handling are explicit subsystems. emergencyRoutes.js and emergencyController.js work with PanicReport and NoShowReport, indicating a separate path for safety events and absence reporting, distinct from normal route participation.
7. Admin functionality is also isolated. adminRoutes.js, adminController.js, and backend/admin.html imply a lightweight admin interface served from the backend for oversight or manual operations, separate from the mobile user flows.
8. The frontend is organized with Expo Router navigation. app/(auth) contains login and OTP verification screens, app/(tabs) contains the main authenticated app sections, and dedicated screens such as create-route.tsx and routes/[routeId].tsx cover route creation and route detail views.
9. Frontend state and API access are split cleanly. context/auth-context.tsx manages session/auth state, utils/storage.ts handles local persistence, and services/api.ts, services/auth.ts, and services/routes.ts wrap backend calls so UI components do not talk to HTTP directly.
10. Shared data shapes are mirrored on the client in frontend/types/, including group, history, queue, route, and user. This aligns the mobile app with backend models and reduces mismatch between API payloads and UI expectations.
11. The overall request flow is: user action in the mobile app → frontend service layer → backend route/controller → middleware checks → model/service logic → database and/or email side effect → response back to the app. Special-case flows branch off for OTP email verification, incident reporting, and admin operations.
12. The repo also includes architecture support artifacts: docs/api-contract.md and docs/architecture.md document the intended system behavior, while the screenshots folder and readme assets capture the product UX. These are useful reference points when drawing the system diagram but are not runtime components.
Main entry points: _layout.tsx App Router · api.ts API Clients · server.js Server · architecture.md Architecture Doc
Components 22
Backend
Node/Express API, business logic, and persistence
- Server · Bootstraps the API runtime and mounts routes
backend/server.js - DB Config · Initializes the database connection
backend/config/db.js - API Routes · Request boundaries for auth, users, groups, routes, emergencies, and admin
- Controllers · Orchestrate business actions for auth, users, groups, routes, emergencies, and admin
- Middleware · Auth and error handling around protected requests
- Models · Persistent entities for users, routes, queues, swaps, history, and reports
- Matching Service · Route and group placement, queue decisions, and assignment logic
backend/services/matchingService.js - Email Service · Sends OTP and related mail flows
backend/services/emailService.js - OTP + Token · Generates one-time codes and session tokens
backend/utils/generateOTP.js - OTP Record · Stores OTP verification data
backend/models/OTP.js - Ride Records · Core ride-pooling entities: users, routes, groups, queues, swaps, history, and incident reports
backend/models/Route.js - Admin UI · Backend-served HTML for oversight and manual operations
backend/admin.html
Frontend
Expo/React Native mobile app and client state
- App Router · Expo Router layout and screen composition
frontend/app/_layout.tsx - Auth Flow · Login and OTP verification screens
frontend/app/(auth)/login.tsx - Main Tabs · Authenticated app sections for group, history, profile, and home
frontend/app/(tabs)/index.tsx - Route Screens · Create and inspect ride routes
frontend/app/create-route.tsx - Auth Context · Session and authentication state management
frontend/context/auth-context.tsx - API Clients · Typed wrappers around backend HTTP calls for auth and routes
frontend/services/api.ts - Local Storage · Persists client session and app data on-device
frontend/utils/storage.ts - Shared Types · Client-side shapes for users, routes, groups, queues, and history
frontend/types/route.ts
Docs
Architecture and API reference materials
- API Contract · System behavior and endpoint contract reference
docs/api-contract.md - Architecture Doc · High-level design and component overview
docs/architecture.md
Connections 24
- Server → API Routes: mounts · Server wires route modules into the HTTP app
- Server → DB Config: connects · Boot sequence establishes database connectivity
- API Routes → Controllers: dispatches · Routes hand requests to domain controllers
- Controllers → Middleware: guards · Protected paths rely on auth and error handling
- Controllers → Models: reads/writes · Controllers persist and fetch domain state
- Controllers → Matching Service: delegates · Route and group assignment uses matching logic
- Controllers → Email Service: sends mail · Auth flows trigger OTP email delivery
- OTP + Token → Email Service: supports · OTP generation feeds the email verification flow
- Controllers → OTP + Token: issues tokens · Authentication verifies OTP and returns session tokens
- Models → OTP Record: includes · OTP is part of the backend persistence layer
- Models → Ride Records: includes · Core ride-pooling and incident entities
- API Routes → Admin UI: serves · Admin endpoints back the lightweight admin interface
- App Router → Auth Flow: navigates · Auth screens are composed in the app router
- App Router → Main Tabs: navigates · Main authenticated sections are mounted after login
- App Router → Route Screens: navigates · Route creation and detail screens are part of the app flow
- Auth Flow → Auth Context: updates · Login and OTP screens update session state
- Auth Context → Local Storage: persists · Auth context stores session data locally
- Main Tabs → API Clients: fetches · Authenticated views load backend data through API clients
- Route Screens → API Clients: fetches · Route screens call backend route APIs
- API Clients → API Routes: calls · Mobile client talks to backend HTTP endpoints
- Shared Types → API Clients: types · Shared client shapes align request and response payloads
- API Contract → API Routes: describes · API contract documents backend endpoints
- Architecture Doc → Server: describes · Architecture docs outline the runtime structure
- Architecture Doc → App Router: describes · Architecture docs cover the client navigation structure