How nitinbollam/cosmos works
Cosmos is a multi-tenant ERP and distribution platform with a browser storefront, admin workspace, and mobile operations UI backed by a same-origin API. The main flow is a user action in a routed client surface, through API routing and session checks, into domain services for orders, inventory, fulfillment, finance, or other ERP work. Order orchestration coordinates payment, warehouse fulfillment, invoicing, and accounting. The README establishes the combined UI/API deployment; several product modules are represented from the source index, so their internal connections are omitted where excerpts do not verify them.
Main entry points: native-router.ts ERP API routes · api-router.ts HTTP API router · order-orchestration.ts Order orchestration · router.tsx Shop, admin, mobile routes
Components 25
Client Experience
- Client application
apps/client/src/App.tsx - Shop, admin, mobile routes
apps/client/src/router.tsx - Storefront and buyer portal
apps/client/src/pages/catalog/page.tsx - ERP administration
apps/client/src/pages/admin - Mobile operations
apps/client/src/pages/m
API and Identity
- HTTP API router
apps/web/server/api-router.ts - ERP API routes
apps/web/lib/server/native-router.ts - Session and access control
apps/web/lib/server/session.ts - Authentication and signup
apps/web/lib/server/auth.ts - Buyer context
apps/web/lib/server/buyer-context.ts - Prisma data stores
apps/web/lib/server/db.ts
Commerce Operations
- Order orchestration
apps/web/lib/server/order-orchestration.ts - Inventory and warehouses
apps/web/lib/server/inventory.ts - Warehouse fulfillment
apps/web/lib/server/wms-fulfillment.ts - CRM customers
apps/web/lib/server/crm.ts - Purchasing and suppliers
apps/web/lib/server/purchasing.ts - Dispatch
apps/web/lib/server/dispatch.ts
Finance and Insights
- Payments
apps/web/lib/server/payments.ts - Invoices
apps/web/lib/server/invoices.ts - Accounting ledger
apps/web/lib/server/operations-gl.ts - Analytics engine
packages/analytics-engine/src/stats.ts
Celestial Assistant
- Assistant orchestration
apps/web/lib/server/celestial/orchestrator.ts - LLM providers and streaming
apps/web/lib/server/celestial/llm.ts
Other components
- Business user
- External language model
Connections 32
- Business user → Client application: uses
- Client application → Shop, admin, mobile routes: renders routes
apps/client/src/App.tsx - Shop, admin, mobile routes → Storefront and buyer portal: routes to
apps/client/src/router.tsx - Shop, admin, mobile routes → ERP administration: routes to
apps/client/src/router.tsx - Shop, admin, mobile routes → Mobile operations: routes to
apps/client/src/router.tsx - Client application → HTTP API router: same-origin API
- HTTP API router → ERP API routes: dispatches ERP requests
apps/web/server/api-router.ts - HTTP API router → Authentication and signup: calls authentication
apps/web/server/api-router.ts - HTTP API router → Buyer context: loads auth profile
apps/web/server/api-router.ts - HTTP API router → Session and access control: checks session
apps/web/server/api-router.ts - HTTP API router → Analytics engine: runs analytics
apps/web/server/api-router.ts - ERP API routes → Session and access control: checks roles
apps/web/lib/server/native-router.ts - ERP API routes → Inventory and warehouses: routes warehouse calls
apps/web/lib/server/native-router.ts - ERP API routes → CRM customers: routes customer calls
apps/web/lib/server/native-router.ts - ERP API routes → Purchasing and suppliers: routes supplier calls
apps/web/lib/server/native-router.ts - ERP API routes → Dispatch: routes dispatch calls
apps/web/lib/server/native-router.ts - ERP API routes → Order orchestration: routes order operations
apps/web/lib/server/native-router.ts - ERP API routes → Warehouse fulfillment: routes fulfillment calls
apps/web/lib/server/native-router.ts - ERP API routes → Payments: routes payment calls
apps/web/lib/server/native-router.ts - ERP API routes → Invoices: routes invoice calls
apps/web/lib/server/native-router.ts - Order orchestration → Warehouse fulfillment: creates fulfillment task
apps/web/lib/server/order-orchestration.ts - Order orchestration → Payments: captures payment
apps/web/lib/server/order-orchestration.ts - Order orchestration → Invoices: issues invoice
apps/web/lib/server/order-orchestration.ts - Order orchestration → Accounting ledger: posts COGS
apps/web/lib/server/order-orchestration.ts - Warehouse fulfillment → Inventory and warehouses: resolves pick bins
apps/web/lib/server/wms-fulfillment.ts - Buyer context → CRM customers: finds buyer
apps/web/lib/server/buyer-context.ts - Authentication and signup → Prisma data stores: reads and writes
apps/web/lib/server/auth.ts - Order orchestration → Prisma data stores: persists order state
apps/web/lib/server/order-orchestration.ts - Inventory and warehouses → Prisma data stores: persists inventory
- HTTP API router → Assistant orchestration: routes assistant requests
- Assistant orchestration → LLM providers and streaming: completes chat
apps/web/lib/server/celestial/orchestrator.ts - LLM providers and streaming → External language model: streams prompts
apps/web/lib/server/celestial/llm.ts