MetroFlow is a metro ticketing and journey simulation platform. Passengers can plan a trip, get a fare quote, pay with Razorpay Test Mode, receive a QR ticket, validate entry and exit, and follow the journey in an animated simulator. The project also includes operations dashboards for monitoring tickets, journeys, payments, gate events, email delivery, and lifecycle inconsistencies.
Status: Functional V1 prototype. The local payment flow uses Razorpay Test Mode, and the station route is demonstration data. Review V1 production readiness before deploying to real users.
Register or sign in -> Plan a journey -> Get a fare quote -> Pay
-> Receive a QR ticket -> Validate station entry -> Simulate the journey
-> Exit at a permitted station -> View the completed journey
Passengers can also view purchases, tickets, journey history, manage their account, change a password, and use email OTP or password reset flows. Staff with operations access can review service activity and audit records through the admin interface.
| Package or service | Path | Local port | Purpose |
|---|---|---|---|
| Web app | apps/web |
3000 | Passenger experience and operations dashboards |
| API Gateway | apps/api-gateway |
3001 | Public API boundary and service proxy |
| Core API | apps/core-api |
3002 | Authentication, stations, fares, purchases, tickets, gates, journeys and operations data |
| Payment service | apps/payment-service |
3003 | Razorpay orders, payment confirmation and webhooks |
| Worker | apps/worker |
3004 | Kafka event consumer and email delivery |
| Gate service | apps/gate-service |
3005 | Gate-device API boundary |
| Shared contracts | packages/contracts |
— | Shared API contracts |
| PostgreSQL | Docker | 5433 | Core and payment databases |
| Redis | Docker | 6379 | Cache and rate-limit infrastructure |
| Kafka | Docker | 9092 | Asynchronous events |
The browser calls the API Gateway. Internal services and credentials should remain server-side.
- Node.js 20 or newer
- pnpm 10 (the repository specifies pnpm 10.34.4)
- Docker Desktop with Docker Compose
- Razorpay Test Mode credentials for payment testing
- ngrok only if you need to receive Razorpay webhooks on your local machine
From the repository root, install dependencies and start the development infrastructure:
pnpm install
Copy-Item .env.example .env
docker compose -f docker-compose.dev.yml up -d
pnpm --filter @metroflow/core-api db:migrate
pnpm --filter @metroflow/core-api db:seed
pnpm devOpen http://localhost:3000. The development Compose file also starts pgAdmin at http://localhost:5050. Local pgAdmin defaults are listed in .env.example; change them before exposing that service beyond your machine.
pnpm dev starts the web app and all services through Turborepo. To stop the development containers, run:
docker compose -f docker-compose.dev.yml downTo also remove local database and pgAdmin data volumes, run docker compose -f docker-compose.dev.yml down -v.
Copy .env.example to .env. The template includes local database, Redis, Kafka, service port, internal service, email, OTP, and optional staff seed settings. Set Razorpay Test Mode values for payment testing:
RAZORPAY_KEY_ID=your_test_key_id
RAZORPAY_KEY_SECRET=your_test_key_secret
RAZORPAY_WEBHOOK_SECRET=your_webhook_secretFor email delivery, configure RESEND_API_KEY and RESEND_FROM_EMAIL. The seeded operations accounts are optional; configure METROFLOW_ADMIN_EMAIL, METROFLOW_ADMIN_PASSWORD, METROFLOW_OPERATOR_EMAIL, and METROFLOW_OPERATOR_PASSWORD before seeding if you need local staff logins. Use unique local-only credentials.
Never commit .env or put private credentials in browser-visible variables. In particular, keep Razorpay secrets, GATE_API_KEY_SECRET, and INTERNAL_SERVICE_KEY on the server.
To test webhooks, start the services, then expose the payment service:
ngrok http 3003Configure the Razorpay Test Mode webhook URL as https://your-ngrok-domain/webhooks/razorpay and enable events such as payment.captured and payment.failed. Check the payment service health endpoint with:
Invoke-RestMethod http://localhost:3003/healthThe ngrok request inspector is at http://127.0.0.1:4040.
The simulator is available from a ticket at /journey/simulator/[ticketId]. It displays the ordered route and supports entry validation, animated station stops, speed controls, intermediate and destination exits, expiry handling, refresh/resume, reduced-motion preferences, and journey completion.
The development seed contains 35 stations. Chandni Chowk to Hauz Khas includes Civil Lines, Vishwavidyalaya, Vidhan Sabha, Model Town, and Azadpur as intermediate demonstration stops. This simplified single-line route is not an authoritative Delhi Metro map or live service feed.
The API Gateway exposes versioned passenger and operations routes under /api/v1. Main route groups include:
| Area | Routes |
|---|---|
| Authentication | /api/v1/auth/* — registration, password and OTP login, sessions, password reset and password change |
| Stations and fares | GET /api/v1/stations, POST /api/v1/fare-quotes |
| Purchases and payments | /api/v1/purchases/*, /api/v1/payments/*, POST /webhooks/razorpay |
| Tickets | /api/v1/tickets/* — ticket list, details, route and operations view |
| Journeys | /api/v1/journeys/* — passenger journey history and operations view |
| Gate validation | POST /api/v1/gate/validate-entry, POST /api/v1/gate/validate-exit |
| Operations | /api/v1/admin/* and operations endpoints for analytics, audits, outbox and inconsistencies |
The repository provides type checks, lifecycle and permissions checks, service-delivery checks, and Playwright browser coverage. Run a check from the repository root:
pnpm typecheck
pnpm test:lifecycle
pnpm test:permissions
pnpm test:admin-queries
pnpm test:worker-delivery
pnpm test:worker-notifications
pnpm test:e2eThe simulator browser test is skipped unless E2E_TICKET_ID is provided. See playwright.config.ts and the scripts in package.json for details.
- AWS EC2 deployment guide
- V1 production readiness checklist
- Implementation audit
- Simulator guide
- Journey simulator UX specification
- Backend architecture and planning
- Frontend planning documents
Production deployment still needs environment-specific secret management, credential rotation, deployment configuration, monitoring and alerting, backup and restore procedures, and operational review. The checklist documents this work in detail.