How itzviraj/sketchitup---guruom works
Purpose and Entry Points
This is a manufacturing operations platform spanning orders, procurement, inventory, production, QC, dispatch, subcontracting/outwork, invoicing, approvals, and audit governance. It has a React/Vite client, a TypeScript backend API/worker, and Supabase persistence.
• Client bootstrap: src/main.tsx, src/App.tsx
• Server/process entry points: server.ts, backend/src/worker.ts
• Database evolution: supabase/migrations/001_initial_schema.sql, supabase/apply_all_migrations.sql
Client Application and Console
The frontend combines public marketing/resource pages with an authenticated operational console. AuthContext and API/Supabase client layers are the boundary between UI state and remote services.
• Console composition/navigation: src/components/console/ConsoleContainer.tsx, src/components/console/ConsoleSidebar.tsx
• Core operational views: src/components/console/views/OrdersView.tsx, src/components/console/views/ProductionView.tsx, src/components/console/views/InventoryView.tsx
• Remote-access layer: src/context/AuthContext.tsx, src/lib/apiClient.ts, src/lib/supabase.ts
Backend Module Boundary
Backend capabilities follow a consistent route → controller → schema → service structure. Services own business operations while controllers expose HTTP-facing module APIs. Shared middleware enforces identity, role checks, request limits, and uploads before module handlers.
• Security boundary: backend/src/middleware/auth.middleware.ts, backend/src/middleware/rbac.middleware.ts, backend/src/middleware/rateLimit.ts
• Representative domain service: backend/src/modules/orders/orders.service.ts, backend/src/modules/orders/orders.controller.ts
• Validation/API boundary: backend/src/modules/inventory/inventory.schema.ts, backend/src/modules/inventory/inventory.routes.ts
Order-to-Fulfillment Workflow
Orders are the primary control flow: state-machine transitions govern progression, then drive purchasing/material receipt, production execution, quality control, finished goods, and dispatch. The same lifecycle is represented in backend services, frontend workflow utilities, and database migration rules.
• Order lifecycle authority: backend/src/modules/orders/orders.state-machine.ts, backend/src/modules/orders/orders.service.ts
• Execution stages: backend/src/modules/production/production.service.ts, backend/src/modules/qc/qc.service.ts, backend/src/modules/dispatch/dispatch.service.ts
• Client-side workflow modeling: src/utils/orderStateMachine.ts, src/components/console/views/OrderDetailView.tsx
Materials, Procurement, and External Processing
Material planning is modeled through BOMs, purchasing, GRNs, inventory movements, and outwork. Inventory movements form a ledger-style boundary rather than merely editable stock values; production and subcontracting consume or create traceable material events.
• Planning and receipt: backend/src/modules/bom/bom.service.ts, backend/src/modules/purchasing/purchasing.service.ts, backend/src/modules/grn/grn.service.ts
• Ledger/inventory: backend/src/modules/inventory/inventory_movements.service.ts, supabase/migrations/011_ledger_inventory_movements.sql
• Subcontracting and completion: backend/src/modules/outwork/outwork.service.ts, backend/src/modules/finished-goods/finished-goods.service.ts
Governance, Finance, and Notifications
Approvals, append-only audit logging, RBAC, invoices, and vendor bills provide governance around operational changes and financial outcomes. Notification delivery is separated into API/domain handling, asynchronous queue/worker support, realtime/pubsub facilities, and a Supabase Edge Function for email.
• Governance: backend/src/modules/approvals/approvals.service.ts, backend/src/services/auditLog.ts, supabase/migrations/010_append_only_audit_logs.sql
• Finance: backend/src/modules/invoices/invoices.service.ts, backend/src/modules/vendor-bills/vendor-bills.service.ts
• Delivery infrastructure: backend/src/lib/queues.ts, backend/src/lib/pubsub.ts, supabase/functions/send-notification-email/index.ts
Infrastructure and Persistence
Supabase supplies relational schema, row-level-security policies, realtime/storage configuration, and custom auth/session persistence. The backend additionally uses Redis-oriented cache, distributed lock, queue, and pub/sub abstractions; database and object-storage access are centralized behind configuration libraries.
• Supabase controls: supabase/migrations/002_rls_and_policies.sql, supabase/migrations/003_realtime_and_storage.sql, supabase/migrations/008_active_sessions_and_security_events.sql
• Backend infrastructure adapters: backend/src/config/database.ts, backend/src/lib/redis.ts, backend/src/lib/storage.ts
• Concurrency/asynchronous boundaries: backend/src/lib/lock.ts, backend/src/lib/queue-connection.ts, backend/src/worker.ts
Main entry points: inventory.routes.ts Module HTTP API · server.ts API server · orders.state-machine.ts Order lifecycle · inventory_movements.service.ts Inventory movement ledger
Components 21
React Client
- Client bootstrap
src/main.tsx - Operations console
src/components/console/ConsoleContainer.tsx - Auth & API access · Connects UI state to API and Supabase.
src/context/AuthContext.tsx - Order workflow UI
src/utils/orderStateMachine.ts
Backend API
- API server
server.ts - Security middleware
backend/src/middleware/auth.middleware.ts - Module HTTP API · Exposes validated domain module endpoints.
backend/src/modules/inventory/inventory.routes.ts
Operations Domain
- Order lifecycle · Primary workflow authority for order transitions.
backend/src/modules/orders/orders.state-machine.ts - Production, QC & dispatch
backend/src/modules/production/production.service.ts - BOM, purchasing & receipt
backend/src/modules/bom/bom.service.ts - Inventory movement ledger · Records material events rather than editable balances.
backend/src/modules/inventory/inventory_movements.service.ts - Outwork & finished goods
backend/src/modules/outwork/outwork.service.ts
Governance & Delivery
- Approvals & audit · Captures approvals and append-only operational audit events.
backend/src/modules/approvals/approvals.service.ts - Invoices & vendor bills
backend/src/modules/invoices/invoices.service.ts - Notifications
backend/src/lib/pubsub.ts - Async worker
backend/src/worker.ts - Notification email
supabase/functions/send-notification-email/index.ts
Persistence & Infrastructure
- Supabase data platform · Relational persistence and managed platform controls.
supabase/migrations/001_initial_schema.sql - Ledger schema
supabase/migrations/011_ledger_inventory_movements.sql - Redis concurrency layer
backend/src/lib/redis.ts - Object storage adapter
backend/src/lib/storage.ts
Connections 25
- Client bootstrap → Operations console: renders
- Operations console → Auth & API access: uses
- Operations console → Order workflow UI: models orders
- Auth & API access → API server: API requests
- Auth & API access → Supabase data platform: auth/session access
- API server → Security middleware: applies
- Security middleware → Module HTTP API: guards
- Module HTTP API → Order lifecycle: invokes
- Order lifecycle → BOM, purchasing & receipt: plans materials
- BOM, purchasing & receipt → Inventory movement ledger: receipts create movements
- Order lifecycle → Production, QC & dispatch: drives fulfillment
- Production, QC & dispatch → Inventory movement ledger: consumes and produces
- Production, QC & dispatch → Outwork & finished goods: subcontracts or completes
- Outwork & finished goods → Inventory movement ledger: records material events
- Order lifecycle → Invoices & vendor bills: creates financial outcomes
- Module HTTP API → Approvals & audit: governed changes
- Module HTTP API → Notifications: emits events
- Notifications → Async worker: queues delivery
- Async worker → Notification email: sends email
- Async worker → Redis concurrency layer: consumes queue
- Module HTTP API → Supabase data platform: persists domain data
- Inventory movement ledger → Ledger schema: stored as
- Ledger schema → Supabase data platform: evolves schema
- API server → Object storage adapter: uploads
- API server → Redis concurrency layer: cache and locks