CommerceOS is a reusable commerce operating layer for platforms that need products, carts, checkout, orders, POS, discounts, tax, inventory, permissions, events and analytics.
This implementation is a complete runnable TypeScript starter. It uses an in-memory repository so you can run and test it immediately. For production, replace the repositories with PostgreSQL/Prisma/TypeORM adapters and connect real SecurityOS, FinanceOS, payment gateway and message broker services.
- Product and category management
- Cart lifecycle
- Checkout engine
- Order lifecycle and status transitions
- POS sale flow
- Inventory tracking and rollback on cancellation
- Discount engine
- Tax calculation per product
- Pricing engine using minor currency units
- Event bus for OS-to-OS communication
- Permission middleware using demo roles
- Analytics summary
- PostgreSQL schema example
- Tests
All money values are stored as integer minor units.
Example for INR:
29900= ₹299.0059800= ₹598.00
npm install
npm run devThe API starts at:
http://localhost:4000Health check:
curl http://localhost:4000/healthThe server seeds demo data at startup:
tenantId: demo-tenant
products: Paneer Pizza, Cold Coffee
coupon: WELCOME10Use these headers for most examples:
x-tenant-id: demo-tenant
x-role: adminDemo roles:
customercashiermanageradminowner
curl "http://localhost:4000/commerceos/products?tenantId=demo-tenant"curl -X POST http://localhost:4000/commerceos/carts \
-H "Content-Type: application/json" \
-H "x-tenant-id: demo-tenant" \
-H "x-role: customer" \
-d '{"customerId":"CUS-1001"}'Replace CART_ID and PRODUCT_ID from the API response.
curl -X POST http://localhost:4000/commerceos/carts/CART_ID/items \
-H "Content-Type: application/json" \
-H "x-tenant-id: demo-tenant" \
-H "x-role: customer" \
-d '{"productId":"PRODUCT_ID","quantity":2}'curl -X POST http://localhost:4000/commerceos/carts/CART_ID/discount \
-H "Content-Type: application/json" \
-H "x-tenant-id: demo-tenant" \
-H "x-role: customer" \
-d '{"code":"WELCOME10"}'curl -X POST http://localhost:4000/commerceos/checkout \
-H "Content-Type: application/json" \
-H "x-tenant-id: demo-tenant" \
-H "x-role: customer" \
-d '{
"cartId":"CART_ID",
"customerId":"CUS-1001",
"orderType":"delivery",
"paymentMethod":"upi",
"deliveryAddress":{"line1":"MG Road","city":"Bengaluru","pincode":"560001"}
}'curl -X POST http://localhost:4000/commerceos/pos/sale \
-H "Content-Type: application/json" \
-H "x-tenant-id: demo-tenant" \
-H "x-role: cashier" \
-d '{
"cashierId":"EMP-001",
"items":[{"productId":"PRODUCT_ID","quantity":1}],
"paymentMethod":"cash"
}'curl "http://localhost:4000/commerceos/analytics/summary?tenantId=demo-tenant" \
-H "x-role: manager"curl http://localhost:4000/commerceos/events/recent \
-H "x-role: admin"src/
api/ Express routes, schemas, middleware
domain/ Commerce domain types
integrations/ Example OS-to-OS subscribers
modules/ CommerceOS modules
products/
inventory/
discounts/
tax/
pricing/
carts/
orders/
checkout/
pos/
analytics/
security/ Role/permission demo layer
shared/ IDs, errors, store, events
commerceos.ts Composition root
index.ts API server
seed.ts Demo data
database/
schema.sql PostgreSQL schema example
tests/
commerceos.test.ts Core flow testsCommerceOS emits events that other OS layers can consume:
product.createdinventory.updatedcart.createdcart.item.addedcheckout.startedorder.createdorder.status.updatedorder.cancelledorder.refundedpayment.completedpos.sale.completedfinance.invoice.requestedanalytics.revenue.update.requestedautomation.order.notification.requested
- Replace
InMemoryRepositorywith PostgreSQL repositories. - Replace demo permission middleware with SecurityOS JWT/RBAC.
- Replace payment simulation with FinanceOS/payment gateway integration.
- Replace in-memory
EventBuswith Kafka, RabbitMQ, NATS, Redis Streams or another broker. - Add idempotency keys for checkout and POS.
- Add audit logs through SecurityOS.
- Add observability, rate limits and background workers.
- Official package:
@appneurox/commerceos - Manifest:
manifest.json - Domain API namespace:
/v1/commerce - Modes: standalone and PlatformOS integrated
- Related systems: FinanceOS, ClientOS
See docs/planning.md for the planning contract applied from APPNEURAL Plannings/OSs.