Skip to content

ankitv42/orca-retail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”± ORCA β€” Open Retail Command Agent

ORCA Banner

Live Demo API Docs GitHub

Python LangGraph FastAPI Docker License

A production-grade multi-agent AI system for retail inventory management.
Built with LangGraph Β· CrewAI Β· MCP Β· RAG Β· FastAPI Β· Streamlit Β· Docker


🎯 The Problem

During peak retail events β€” Ramadan, Dubai Shopping Festival, Eid β€” 200+ UAE retail stores face a critical operational bottleneck:

  • Demand surges are unpredictable and event-driven
  • Supplier lead times may not align with urgency
  • Capital approval for large orders requires human sign-off
  • Manual decisions are slow, inconsistent, and not auditable

Store managers spend hours on WhatsApp with suppliers, comparing spreadsheets, and escalating to finance β€” while stockouts happen and revenue is lost.

ORCA replaces this entire workflow with a 4-agent AI pipeline + one human decision.


πŸ€– How It Works

Alert Triggered (stock critical/at-risk)
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Agent 1 β€” Demand Intelligence (CrewAI crew)            β”‚
β”‚  β€’ Event uplift analysis (Ramadan 2.8Γ—, DSF 1.9Γ—)      β”‚
β”‚  β€’ Supplier constraint discovery                        β”‚
β”‚  β€’ Confidence scoring + demand forecasting              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Agent 2 β€” Replenishment Options                        β”‚
β”‚  β€’ Option A: Standard Replenishment                     β”‚
β”‚  β€’ Option B: Profit Maximisation (Tier-1 stores)       β”‚
β”‚  β€’ Option C: Expedite Air Freight                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Agent 3 β€” Capital Allocation & Scoring                 β”‚
β”‚  budget_score      = (1 - cost/budget) Γ— 40            β”‚
β”‚  availability_score = availability_pct Γ— 0.40 Γ— 100   β”‚
β”‚  margin_score      = (1/margin_rank) Γ— 20              β”‚
β”‚  lead_time_penalty = -20 if CRITICAL & lead > 30d     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Route Decision Node                                    β”‚
β”‚  β€’ AUTO_EXECUTE  β†’ cost < pool auto-approve limit      β”‚
β”‚  β€’ ESCALATE      β†’ cost > limit β†’ human required       β”‚
β”‚  β€’ SUSPEND       β†’ pool pressure HIGH                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
              β–Ό             β–Ό
         Human HITL     Auto Execute
         (Approve /     (reorder_triggered
          Reject)        = Yes β†’ DB)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Streamlit Dashboard                       β”‚
β”‚              (Command Centre / Pipeline Monitor / HITL)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚ HTTP (httpx)
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      FastAPI Layer                           β”‚
β”‚  POST /pipeline/run β†’ 202 + background task                 β”‚
β”‚  GET  /pipeline/{id}/state β†’ polling endpoint               β”‚
β”‚  POST /pipeline/{id}/approve β†’ HITL resume                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  LangGraph Pipeline                          β”‚
β”‚  agent1_node β†’ agent2_node β†’ agent3_node β†’ route_node      β”‚
β”‚       ↓              ↓            ↓              ↓          β”‚
β”‚  CrewAI crew    Options Gen   Scoring     ESCALATE/AUTO     β”‚
β”‚  (3 AI agents)  (3 options)  (formula)    EXECUTE/SUSPEND   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                    β”‚
           β–Ό                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MCP Server    β”‚    β”‚    RAG Pipeline      β”‚
β”‚  (tool discoveryβ”‚    β”‚  ChromaDB + BGE     β”‚
β”‚   via stdio)    β”‚    β”‚  Reranker           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               SQLite Database                                β”‚
β”‚  skus Β· stores Β· stock_positions Β· capital_pools            β”‚
β”‚  pipeline_log Β· supplier_data Β· events                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Key Features

Feature Description
πŸ€– Multi-Agent Pipeline 4 specialised LangGraph agents, each with a single responsibility
πŸ‘₯ CrewAI Integration 3-agent crew (Data Analyst, Market Analyst, Forecast Strategist) inside Agent 1
πŸ”Œ MCP Tool Discovery Dynamic tool registration via Model Context Protocol β€” no hardcoded calls
πŸ“š RAG Policy Retrieval BGE reranker + ChromaDB for policy-grounded decisions
βœ‹ HITL Approval Workflow LangGraph interrupt β†’ human reviews briefing β†’ approve/reject
⚑ Async FastAPI 202 pattern β€” pipeline runs as background task, client polls state
🎨 Industrial Dashboard Dark theme Streamlit UI β€” Command Centre / Pipeline Monitor / HITL tabs
🐳 Docker + Render Fully containerised, deployed on Render free tier
πŸ“Š Audit Trail Every decision logged with reviewer, timestamp, action taken

πŸ› οΈ Tech Stack

Layer              Technology
─────────────────────────────────────────────────
Orchestration      LangGraph 1.1.10
Multi-Agent        CrewAI 1.14.4
Tool Protocol      MCP (Model Context Protocol)
LLM                Groq / llama-3.1-8b-instant
Embeddings         nomic-ai/nomic-embed-text-v1.5
Reranker           BAAI/bge-reranker-v2-m3
Vector Store       ChromaDB 1.1.1
API Framework      FastAPI 0.136 + Uvicorn
Dashboard          Streamlit 1.57
HTTP Client        httpx 0.28
Database           SQLite + SQLAlchemy
Containerisation   Docker + docker-compose
Deployment         Render.com (free tier)
Observability      LangSmith (integrated β€” all LLM calls traced)

πŸš€ Quick Start

Prerequisites

Option 1 β€” Docker (recommended)

# Clone
git clone https://github.com/ankitv42/orca-retail.git
cd orca-retail

# Create .env
cat > .env << EOF
GROQ_API_KEY=your_groq_key_here
GROQ_MODEL=llama-3.1-8b-instant
LLM_PROVIDER=groq
LANGCHAIN_TRACING_V2=false
EOF

# Build and run
docker-compose up --build

Open:

Option 2 β€” Local Development

# Clone and setup
git clone https://github.com/ankitv42/orca-retail.git
cd orca-retail
python -m venv venv
venv\Scripts\activate  # Windows
pip install -r requirements.txt

# Create .env (same as above)

# Terminal 1 β€” API
uvicorn api.main:app --port 8080 --reload

# Terminal 2 β€” Dashboard
streamlit run dashboard/app.py

πŸ“ Project Structure

orca-retail/
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ graph.py          # LangGraph pipeline β€” all 4 agents + route logic
β”‚   β”œβ”€β”€ prompts.py        # Agent prompts + scoring formula
β”‚   β”œβ”€β”€ crew.py           # CrewAI crew (3 agents)
β”‚   β”œβ”€β”€ llm_factory.py    # LLM provider abstraction
β”‚   └── tools.py          # MCP tool definitions
β”‚
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ main.py           # FastAPI app β€” 7 endpoints
β”‚   └── models.py         # Pydantic schemas
β”‚
β”œβ”€β”€ dashboard/
β”‚   β”œβ”€β”€ app.py            # Streamlit UI β€” 3 tabs
β”‚   └── api_client.py     # HTTP client wrapper
β”‚
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ rag/
β”‚   β”‚   β”œβ”€β”€ ingest.py         # PDF β†’ chunks β†’ ChromaDB
β”‚   β”‚   └── retriever.py      # BGE reranker retrieval
β”‚   └── adr/                  # Architecture Decision Records (ADR-001 to ADR-005)
β”‚
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ queries.py        # SQLite query layer
β”‚   β”œβ”€β”€ pipeline_log.py   # Audit log
β”‚   └── schema.sql        # Database schema
β”‚
β”œβ”€β”€ mcp_server/
β”‚   └── server.py         # MCP stdio server
β”‚
β”œβ”€β”€ data/
β”‚   └── scheduler.py      # Alert generation scheduler
β”‚
β”œβ”€β”€ Dockerfile.api         # API container
β”œβ”€β”€ Dockerfile.dashboard   # Dashboard container
β”œβ”€β”€ docker-compose.yml     # Orchestration
└── requirements.txt       # Dependencies

πŸ”Œ API Reference

Base URL: https://orca-retail.onrender.com

Method Endpoint Description
GET /health System status β€” DB, RAG, LLM, MCP
GET /api/v1/alerts 102 critical/at-risk SKU alerts
POST /api/v1/pipeline/run Trigger pipeline β†’ returns 202 + pipeline_id
GET /api/v1/pipeline/{id}/state Poll pipeline state (progressive)
GET /api/v1/pipeline/{id}/briefing HITL briefing text
POST /api/v1/pipeline/{id}/approve Approve or reject HITL decision
GET /api/v1/pipelines Session audit log

Full interactive docs: https://orca-retail.onrender.com/docs


🎬 Demo Flow

  1. Open https://orca-dashboard.onrender.com
  2. Command Centre tab β†’ click Analyse on any SKU (try Ajwa Dates 1kg β€” Class A, Ramadan event)
  3. Pipeline Monitor tab β†’ watch 4 agents complete progressively (auto-refreshes every 3s)
  4. If pipeline is ESCALATED β†’ go to HITL Approval tab
  5. Enter your email β†’ read the briefing β†’ click APPROVE
  6. reorder_triggered = Yes is written to the database

⚠️ Free tier note: Render free instances spin down after inactivity. First load may take 30–60 seconds to wake up.


πŸ“ Architecture Decision Records

Full ADR documents are in docs/adr/.

ADR Decision Choice
ADR-001 Graph framework LangGraph β€” stateful, interruptible, production-grade checkpointing
ADR-002 Tool protocol MCP β€” dynamic discovery vs hardcoded tool calls
ADR-003 Eval metrics Native RAGAS metrics over RAGAS library
ADR-004 ChromaDB index Committed to repo for reproducible CI
ADR-005 HITL routing Cost vs auto-approve limit β€” pure Python, no LLM

πŸ—ΊοΈ Sprint Roadmap

Sprint Focus Status
Sprint 1 Data Foundation (SQLite, 100 SKUs, 200 stores, scheduler) βœ… Complete
Sprint 2 LangGraph Pipeline + MCP Integration βœ… Complete
Sprint 3 RAG (ChromaDB + BGE) + CrewAI βœ… Complete
Sprint 4 FastAPI + Streamlit HITL Dashboard βœ… Complete
Sprint 5 Docker + Render Deployment βœ… Complete
Sprint 6 LangSmith Tracing + ADRs βœ… Β· Redis πŸ”œ πŸ”„ In Progress

🀝 About

Built by Ankit Kumar Verma
Data Science Manager @ Accenture | Palantir Foundry | GCP Professional Data Engineer

This project is an open-source rebuild of the Retail Command Centre (RCC) β€” a production HITL multi-agent inventory system deployed across 200+ UAE retail stores on Palantir Foundry.

ORCA is my bridge from proprietary enterprise AI to portable, open-source agentic systems.

LinkedIn GitHub


πŸ“„ License

MIT License β€” see LICENSE for details.


If this project helped you, give it a ⭐ β€” it helps others find it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors