How astlejoe789/transitops-smart-fleet-platform works
Purpose and deployable entry points
TransitOps is a modular-monolith fleet and transport-operations platform: dispatch/trips, fleet and drivers, fuel/maintenance/expenses, vendors/customers, billing/payments, reporting, analytics, notifications, and administration. The React SPA starts at apps/web/src/main.tsx and routes through apps/web/src/router/AppRouter.tsx. The Express REST API is bootstrapped by apps/api/src/server.ts and composed in apps/api/src/app.ts.
Web application shell and access boundary
The Vite/React 18 client provides public, auth, and operational layouts; route access is gated by authentication and role checks. Global providers establish auth, theme, and application-level data context before feature pages render.
• apps/web/src/providers/AppProviders.tsx
• apps/web/src/guards/AuthGuard.tsx
• apps/web/src/layouts/MainLayout.tsx
Client-to-API data flow
Feature pages and modals call a centralized API client and domain API wrappers, then render dashboard, operational records, and reports. This creates the frontend/backend boundary at HTTP rather than sharing backend services directly.
• apps/web/src/api/client.ts
• apps/web/src/api/trips.api.ts
• apps/web/src/modules/fleet/pages/VehiclesPage.tsx
API composition, security, and request pipeline
Express mounts the module route surface centrally. Requests cross CORS, rate limiting, JWT authentication, permission/role authorization, validation, and shared error handling before reaching controllers. JWT/password utilities and standardized exceptions/responses form the common security and API-contract layer.
• apps/api/src/routes/index.ts
• apps/api/src/middlewares/auth.middleware.ts
• apps/api/src/middlewares/permission.middleware.ts
Domain-module architecture
Backend capabilities follow a repeated vertical slice: routes → controller → service → repository, with DTOs and validation at the input boundary. Core operational modules include trips/dispatch, fleet, drivers, fuel, maintenance, and expenses; commercial and administration modules cover customers, vendors, billing, payments, settings, users/administration, notifications, reports, dashboard, and analytics.
• apps/api/src/modules/trips/routes.ts
• apps/api/src/modules/fleet/service.ts
• apps/api/src/modules/billing/repository.ts
AI and derived operational insights
The AI module is isolated behind a provider interface, allowing OpenAI, Gemini, or local implementations without leaking provider choices across other business modules. Dashboard, analytics, and reports are separate read/aggregation-oriented API domains.
• apps/api/src/modules/ai/providers/ai-provider.interface.ts
• apps/api/src/modules/ai/providers/openai.provider.ts
• apps/api/src/modules/analytics/service.ts
Persistence and infrastructure
PostgreSQL is the system of record, accessed through Prisma and a shared client. The schema, versioned initial migration, and seed script define database lifecycle. Local containers are coordinated with Docker Compose; production targets are Vercel for the SPA and Railway for API/PostgreSQL, with per-app Docker/deployment manifests.
• database/prisma/schema.prisma
• apps/api/src/database/prisma.ts
• docker-compose.yml
Main entry points: index.ts Central route surface · prisma.ts Prisma data access · server.ts API bootstrap · service.ts Dashboard, reports & analytics
Components 20
React SPA
- Web entry & router · Starts the SPA and selects public, auth, and operational routes.
apps/web/src/main.tsx - Global providers · Establishes auth, theme, and application data context.
apps/web/src/providers/AppProviders.tsx - Access guards & layout · Applies authentication and role access before operational screens.
apps/web/src/guards/AuthGuard.tsx - Operational feature pages · Fleet, trip, dashboard, record, and report screens.
apps/web/src/modules/fleet/pages/VehiclesPage.tsx - API client & domain wrappers · Centralizes browser requests to REST domain endpoints.
apps/web/src/api/client.ts
Express API
- API bootstrap · Starts the REST API application.
apps/api/src/server.ts - Express application · Composes shared middleware and route surface.
apps/api/src/app.ts - Central route surface · Mounts module REST routes.
apps/api/src/routes/index.ts - Security & request pipeline · CORS, rate limiting, JWT, permissions, validation, and errors.
apps/api/src/middlewares/auth.middleware.ts
Domain modules
- Trips & dispatch slice · Routes, controllers, services, repositories, DTOs, and validation.
apps/api/src/modules/trips/routes.ts - Fleet & drivers slice · Vehicle and driver operational workflows.
apps/api/src/modules/fleet/service.ts - Fuel, maintenance & expenses · Operational cost and upkeep workflows.
- Customers, vendors, billing & payments · Commercial records and financial workflows.
apps/api/src/modules/billing/repository.ts - Users, settings & notifications · Administration and notification capabilities.
- Dashboard, reports & analytics · Aggregation-oriented operational insights.
apps/api/src/modules/analytics/service.ts - AI provider boundary · Swaps OpenAI, Gemini, or local implementations.
apps/api/src/modules/ai/providers/ai-provider.interface.ts
Data & deployment
- Prisma data access · Shared ORM client used by repositories.
apps/api/src/database/prisma.ts - PostgreSQL system of record · Schema, migrations, and seed define database lifecycle.
database/prisma/schema.prisma - Local container stack · Coordinates local application and database containers.
docker-compose.yml - Production hosting · Vercel hosts the SPA; Railway hosts API and PostgreSQL.
Connections 28
- Web entry & router → Global providers: wraps
- Global providers → Access guards & layout: provides context to
- Access guards & layout → Operational feature pages: authorizes
- Operational feature pages → API client & domain wrappers: requests data through
- API client & domain wrappers → API bootstrap: HTTPS REST
- API bootstrap → Express application: starts
- Express application → Security & request pipeline: applies
- Security & request pipeline → Central route surface: permits requests to
- Central route surface → Trips & dispatch slice: mounts
- Central route surface → Fleet & drivers slice: mounts
- Central route surface → Fuel, maintenance & expenses: mounts
- Central route surface → Customers, vendors, billing & payments: mounts
- Central route surface → Users, settings & notifications: mounts
- Central route surface → Dashboard, reports & analytics: mounts
- Central route surface → AI provider boundary: mounts
- Trips & dispatch slice → Prisma data access: repositories use
- Fleet & drivers slice → Prisma data access: repositories use
- Fuel, maintenance & expenses → Prisma data access: repositories use
- Customers, vendors, billing & payments → Prisma data access: repositories use
- Users, settings & notifications → Prisma data access: repositories use
- Dashboard, reports & analytics → Prisma data access: reads aggregates via
- AI provider boundary → Dashboard, reports & analytics: provides derived insights
- Prisma data access → PostgreSQL system of record: persists to
- Local container stack → API bootstrap: runs locally
- Local container stack → PostgreSQL system of record: runs locally
- Production hosting → Web entry & router: deploys SPA
- Production hosting → API bootstrap: deploys API
- Production hosting → PostgreSQL system of record: hosts database