A Decision-Centric Agentic AI Operations Manager for MSMEs
CallOfCode Operations AI is an intelligent operational management system designed specifically for Micro, Small, and Medium Enterprises (MSMEs). Acting as a Digital Chief Operating Officer (COO), this system autonomously manages day-to-day operations through an advanced AI agent architecture built with LangGraph.
Unlike traditional workflow engines or task trackers, this system owns operational decisions, continuously observes business state, and acts proactively to optimize resource allocation, prevent bottlenecks, and ensure customer commitments are met.
The system operates on a continuous OBSERVE → DECIDE → ACT control loop, functioning as a stateful operational agent that:
- 🎯 Makes autonomous decisions about task assignments and resource allocation
- 🔄 Continuously re-evaluates plans as conditions change
- ⚡ Intervenes proactively when work is delayed or at risk
- 📊 Maintains explainable audit trails for all decisions
- 🚨 Escalates intelligently when blocked or uncertain
- Multi-Node Decision Graph: Observe → Orient → Decide → Plan → Act → Respond
- Context-Aware Reasoning: Uses Google Generative AI for intelligent decision-making
- Autonomous Task Assignment: Automatically assigns workers based on skills, workload, and priorities
- Promise Validation: Ensures commitments can be met before accepting requests
- Bottleneck Detection: Identifies and resolves operational constraints proactively
- Customer Dashboard: Track requests, view status updates, and communicate
- Worker Dashboard: View assigned tasks, update progress, manage availability
- Owner Dashboard: Full visibility into operations, decision audit trails, and override controls
- Real-time inventory tracking with Supabase Storage integration
- Image upload support for inventory items
- Automatic reorder point monitoring
- Supplier management and ETA tracking
- Role-based access control (Owner, Worker, Customer)
- JWT-based authentication with secure cookie management
- Bcrypt password hashing
- Protected routes with middleware validation
- WhatsApp webhook integration for customer requests
- Web-based request submission
- Automated normalization of raw inputs
- Every decision logged with actor, action, context, and reasoning
- Full traceability of agent decisions
- Request lifecycle tracking
- Performance analytics
CallOfCode_Operations-AI/
├── apps/
│ ├── server/ # Express.js API Backend
│ └── web/ # Next.js Frontend
├── packages/
│ ├── db/ # Prisma Database Layer
│ ├── config/ # Shared TypeScript Configurations
│ └── env/ # Environment Variable Validation
- Runtime: Bun (JavaScript Runtime)
- Framework: Express.js 5
- AI/LLM:
- LangGraph (Stateful Agent Workflows)
- @langchain/core & @langchain/langgraph
- Google Generative AI (@google/generative-ai)
- Database: PostgreSQL with Prisma ORM
- Storage: Supabase (Image & File Storage)
- Authentication: JWT + bcryptjs
- Validation: Zod
- Framework: Next.js 16 (React 19)
- Styling: TailwindCSS 4 + shadcn/ui
- Forms: TanStack React Form
- Animations: Framer Motion
- Icons: Lucide React
- HTTP Client: Axios
- Theme: next-themes (Dark/Light Mode)
- Notifications: Sonner
The system uses a comprehensive PostgreSQL schema with:
- Users: Unified user model with role-based differentiation (Owner, Worker, Customer)
- Requests: Customer service requests with status tracking and priority management
- Tasks: Granular work units with skill requirements and time estimates
- Inventory: SKU-based inventory with reorder points and image URLs
- Suppliers: Supplier reliability tracking and order ETAs
- Audit Logs: Complete decision history with actor and reasoning
- Bun: v1.2.21 or higher (Install Bun)
- PostgreSQL: v14 or higher
- Node.js: v20+ (for compatibility)
- Supabase Account: For storage and authentication services
-
Clone the repository
git clone https://github.com/Harish-Naruto/CallOfCode_Operations-AI.git cd CallOfCode_Operations-AI -
Install dependencies
bun install
-
Environment Setup
Create
.envfiles in the appropriate directories:apps/server/.env# Database DATABASE_URL="postgresql://user:password@localhost:5432/dbname" # JWT JWT_SECRET="your-super-secret-jwt-key" JWT_EXPIRES_IN="7d" # CORS CORS_ORIGIN="http://localhost:3001" # Supabase SUPABASE_URL="https://your-project.supabase.co" SUPABASE_ANON_KEY="your-anon-key" SUPABASE_SERVICE_ROLE_KEY="your-service-role-key" # Google AI GOOGLE_AI_API_KEY="your-google-ai-api-key" # Server PORT=3000
apps/web/.env.localNEXT_PUBLIC_API_URL="http://localhost:3000"
-
Database Setup
# Generate Prisma Client bun run db:generate # Push schema to database bun run db:push # Seed initial data (optional) cd apps/server bun run seed
-
Start Development Servers
# Start all services (server + web) bun run dev # Or start individually: bun run dev:server # API server on http://localhost:3000 bun run dev:web # Web app on http://localhost:3001
src/
├── agent/ # LangGraph Agent Implementation
│ ├── graph/ # State graph and nodes
│ │ ├── nodes/ # Observer, Orient, Decide, Plan, Act, Respond
│ │ └── index.ts # Graph builder and invocation helpers
│ ├── prompts/ # LLM prompts and state definitions
│ └── services/ # Agent-specific services
├── controllers/ # Request handlers
├── routes/ # API route definitions
│ ├── auth/ # Authentication routes
│ ├── customer/ # Customer-facing routes
│ ├── worker/ # Worker-facing routes
│ ├── owner/ # Owner dashboard routes
│ ├── inventory/ # Inventory management
│ └── internal/ # Agent internal routes
├── services/ # Business logic layer
├── middleware/ # Auth, error handling, idempotency
├── validation/ # Zod schemas
└── utils/ # Helper functions
src/
├── app/ # Next.js App Router
│ ├── auth/ # Login and signup pages
│ ├── customer/ # Customer dashboard
│ ├── worker/ # Worker dashboard
│ └── owner/ # Owner dashboard
├── components/ # Reusable UI components
│ ├── ui/ # shadcn/ui components
│ └── [features] # Feature-specific components
└── lib/ # Utilities and API clients
- Prisma schema definition
- Database client configuration
- PostgreSQL adapter setup
- Shared TypeScript configurations
- Build tool settings
- Environment variable validation
- Type-safe env access
bun run dev # Start all apps in development mode
bun run build # Build all applications
bun run check-types # TypeScript type checking across workspace
# Database operations
bun run db:push # Push schema changes to database
bun run db:generate # Generate Prisma Client
bun run db:migrate # Run database migrations
bun run db:studio # Open Prisma Studio GUIcd apps/server
bun run dev # Start server in hot-reload mode
bun run build # Build production server
bun run start # Start production server
bun run seed # Seed database with initial data
bun run compile # Compile to standalone binarycd apps/web
bun run dev # Start Next.js dev server
bun run build # Build production bundle
bun run start # Start production serverPOST /api/auth/signup- Register new userPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user
POST /api/requests- Submit new service requestGET /api/requests/:id/status- Get request statusPOST /api/webhooks/whatsapp- WhatsApp webhook handler
GET /api/tasks?assignedTo=me- Get assigned tasksPOST /api/tasks/:id/accept- Accept task assignmentPOST /api/tasks/:id/update- Update task progressPOST /api/tasks/:id/complete- Mark task completePOST /api/workers/:id/availability- Update availability
GET /api/owner/requests- List all requestsGET /api/owner/requests/:id- Request details with audit trailPOST /api/owner/requests/:id/force-assign- Manual overridePUT /api/owner/config/decision-rules- Update agent decision weightsGET /api/owner/workers- List all workersGET /api/owner/audit- Get audit logs
GET /api/inventory- List inventory itemsPOST /api/inventory- Create inventory item (with image upload)PUT /api/inventory/:id- Update inventory itemPOST /api/inventory/update- Adjust inventory quantity
POST /internal/agent/enqueue- Queue agent jobPOST /internal/agent/re-evaluate/:requestId- Trigger reevaluationPOST /internal/agent/simulate- Decision simulation (dry-run)
The LangGraph agent follows a structured decision-making process:
- OBSERVE - Monitor inputs, detect changes, and gather raw data
- ORIENT - Build decision-ready context from operational state
- DECIDE - Use LLM to determine the best action based on:
- Inventory availability
- Worker skills and workload
- Task dependencies
- Customer priorities
- Operational constraints
- PLAN TASKS - Break down accepted requests into executable tasks
- ACT - Execute decisions (assign tasks, update state, notify stakeholders)
- RESPOND - Generate user-facing responses and notifications
The agent prioritizes:
- Keeping customer commitments over starting new work
- Reducing bottlenecks over maximizing throughput
- Clear ownership over speed
- Small reversible actions over large irreversible ones
- Escalation over silent failure
- Modern UI/UX: Dark mode support, glassmorphism effects, smooth animations
- Responsive Design: Mobile-first approach with Tailwind CSS
- Real-time Updates: Dynamic status tracking and notifications
- Form Validation: Client-side and server-side validation with Zod
- Image Uploads: Integrated with Supabase Storage for inventory images
- Rich Components: Built with shadcn/ui and Radix UI primitives
- JWT-based authentication with secure HTTP-only cookies
- Password hashing with bcryptjs
- Role-based access control (RBAC)
- CORS configuration for cross-origin requests
- Idempotency key support for safe retries
- Input validation with Zod schemas
- SQL injection protection via Prisma ORM
- User: Unified user model with role differentiation
- Customer: Customer profile with contact details
- Worker: Worker profile with skills array
- Owner: Business owner profile
- Request: Service request with status tracking
- Task: Granular work units with assignments
- InventoryItem: Stock management with images
- Supplier: Supplier reliability tracking
- SupplierOrder: Purchase order management
- AuditAction: Complete decision audit trail
- UserRole:
OWNER | WORKER | CUSTOMER - RequestStatus:
NEW | IN_PROGRESS | BLOCKED | DONE | CANCELLED - TaskStatus:
PENDING | ASSIGNED | IN_PROGRESS | BLOCKED | DONE - AuditActor:
AGENT | OWNER | WORKER | CUSTOMER | WEBHOOK
-
Feature Development
- Create feature branch from
main - Implement changes in appropriate workspace package
- Run type checking:
bun run check-types - Test locally with hot reload
- Create feature branch from
-
Database Changes
- Update
packages/db/prisma/schema/schema.prisma - Generate client:
bun run db:generate - Push changes:
bun run db:push - Create migration (production):
bun run db:migrate
- Update
-
Testing
- Unit tests for services and utilities
- Integration tests for API endpoints
- Manual testing via Prisma Studio for database
- Agent simulation endpoint for decision testing
The project includes Docker configuration for containerized deployment:
# Build and run with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down- CLAUDE.md - System design principles and agent architecture
- API Specification - Complete API contract and interface definitions
- Prisma Schema - Database schema documentation
The system is currently configured for a clothing business use case (tailoring, alterations, order fulfillment) with:
- Request Types: Alteration, Order, Stitching
- Worker Skills: Tailoring, delivery, quality check
- Inventory: Fabric SKUs with sizes, colors, measurements
- Tasks: Sleeve shortening, hemming, stitching, etc.
This is a private project developed for MSME operational automation. For questions or contributions, please contact the development team.
Proprietary - All rights reserved
- Built with LangGraph for agentic AI workflows
- UI components from shadcn/ui
- Database management with Prisma
- Monorepo tooling by Turborepo
- Powered by Bun for blazing-fast JavaScript runtime
Built with ❤️ for MSME empowerment through AI-driven operations