Forward Deployed Engineering (FDE) Capstone Project
Developed as a production-grade enterprise deployment bridging legacy supply-chain databases with agentic LLM reasoning loops, real-time corridor IoT telemetry, zero-trust RBAC database security, and automated standard operating procedure (SOP) compliance.π½οΈ Implementation Reference: Based on the end-to-end architectural blueprint from Complete End To End AI Forward Deployed Engineer (FDE) Project Implementation.
- Executive Overview
- The Forward Deployed Engineering (FDE) Problem
- System Architecture (HLD & LLD)
- Enterprise Security & Zero-Trust Governance
- High-Density RAG & Vector Engine
- Agentic ReAct Orchestrator & Tool Contracts
- Interactive Control Tower Console
- 100% Free Deployment Playbook ($0 Cost)
- Local 5-Minute Quickstart
- Repository File Tree
- Verification & Golden Evaluation Scenarios
- Interview & Resume Impact Portfolio
In global cold-chain logistics (pharmaceuticals, biological vaccines, and perishable food transit), temperature excursions and transit bottlenecks result in over $35 Billion in annual cargo losses.
While modern fleets are equipped with IoT telemetry sensors, control tower dispatchers face a critical operational bottleneck:
- Data Silos: Sensor telemetry is trapped inside 20-year-old legacy relational schemas (
TBL_SC_FLEET_HIST_RAW) with cryptic column keys. - Unstructured Knowledge: Standard Operating Procedures (SOPs), emergency triage rules, and regulatory temperature bands reside in static Markdown and PDF documents.
- Decoupled Real-Time Hazards: Meteorological disturbances, corridor wind risks, and transit congestion live in disparate external REST APIs.
This repository implements an autonomous Cold-Chain AI Assistant & Control Tower. Powered by LangGraph, Pinecone Serverless, and Streamlit, it allows enterprise dispatchers to converse directly with real-time operational data, cross-reference external environmental hazards, and automatically execute cited regulatory SOP action plansβall enforced by strict Zero-Trust database access controls.
Dispatcher Query βββΊ [LangGraph ReAct Brain]
β
βββββββββββββββββββΌβββββββββββββββββββ
βΌ βΌ βΌ
[MSSQL Semantic View] [Open-Meteo REST] [Pinecone Vector Store]
(Telemetry Telematics) (Live Corridor) (Incident SOP Rules)
β β β
βββββββββββββββββββΌβββββββββββββββββββ
βΌ
[Enterprise Structured Action Plan]
+ Immutable SQL Audit Trail
Forward Deployed Engineers operate on client frontlines, turning messy, uncooperative corporate infrastructure into production AI systems. Standard hackathon AI demos fail in enterprise environments for three reasons:
| Hackathon Prototype | Enterprise FDE Reality (This Implementation) |
|---|---|
| Raw Text-to-SQL with DB Admin privileges | Hardened Semantic Views + RBAC Service Accounts (USR_FDE_RO) with physical DENY on DML/DDL |
| Naive single-shot RAG chunking | Polymorphic Markdown/PDF parsers with SHA-256 hash caching to prevent duplicate embedding costs |
| Hallucinated answers without auditability | Deterministic output contract + append-only immutable SQL audit logging (AgentAuditLog) |
| Vendor lock-in on one LLM provider | Dynamic multi-model runtime supporting OpenAI GPT-4o, DeepSeek-V4, and local air-gapped Ollama |
The platform follows a decoupled, three-tier enterprise architecture ensuring strict isolation between user interaction, agentic reasoning, and data layers:
flowchart TD
subgraph Tier1["Tier 1: Presentation Tier (Streamlit Console)"]
UI["Mission Control UI (src/ui.py)"]
SessionState["Session State & Thread IDs (UUIDv4)"]
AuditViewer["Live Telemetry & Audit Stream"]
end
subgraph Tier2["Tier 2: Orchestration Engine (LangGraph State Machine)"]
Reasoner["StateGraph Reasoner Node (DeepSeek / GPT-4o / Ollama)"]
MemorySaver["Checkpointer (MemorySaver Session History)"]
ToolsCondition{"tools_condition Router"}
ToolNode["ToolNode Execution Sandbox"]
end
subgraph Tier3["Tier 3: Distributed Tool Integration & Security Layer"]
T1["query_telemetry_db (SQLAlchemy / pyodbc)"]
T2["fetch_corridor_conditions (Open-Meteo API)"]
T3["search_compliance_sop (Pinecone Vector DB)"]
subgraph DataStores["Enterprise Data Stores"]
MSSQL[("Legacy MSSQL Server (Docker / EC2)")]
SemanticView["FDE_VIEWS.VW_ACTIVE_FLEET (Read-Only)"]
RawTable["dbo.TBL_SC_FLEET_HIST_RAW (DENIED)"]
AuditTable[("FDE_VIEWS.AgentAuditLog (Append-Only)")]
PineconeIndex[("Pinecone Serverless Index (SOPs)")]
end
end
UI -->|"User Prompt"| Reasoner
Reasoner <--> MemorySaver
Reasoner --> ToolsCondition
ToolsCondition -->|"Requires Data"| ToolNode
ToolsCondition -->|"Final Answer"| UI
ToolNode --> T1
ToolNode --> T2
ToolNode --> T3
T1 -->|"Least Privilege Login"| SemanticView
SemanticView -.-> RawTable
T2 -->|"Live Weather / Wind"| OpenMeteo["api.open-meteo.com"]
T3 -->|"Dense Vector Search"| PineconeIndex
ToolNode -->|"Tool Execution Output"| Reasoner
UI -->|"Silent Trace Log"| AuditTable
Allowing an LLM to generate unrestricted SQL against enterprise databases is an unacceptable risk. This architecture enforces a Defense-in-Depth security strategy:
graph LR
subgraph ClientSpace["Agent Execution Space"]
Agent["LangGraph Agent (USR_FDE_RO)"]
end
subgraph SecurityBoundary["Database Security Perimeter"]
Gatekeeper["T-SQL AST & Keyword Inspector (SELECT only)"]
SemanticView["FDE_VIEWS.VW_ACTIVE_FLEET"]
AuditLog["FDE_VIEWS.AgentAuditLog"]
LegacyTable["dbo.TBL_SC_FLEET_HIST_RAW"]
end
Agent -->|"1. Validated T-SQL"| Gatekeeper
Gatekeeper -->|"2. Read Permitted"| SemanticView
Gatekeeper -.->|"3. Physical DENY (DROP/UPDATE/INSERT)"| LegacyTable
Agent -->|"4. Silent Audit Insert"| AuditLog
style LegacyTable fill:#ff6b6b,stroke:#c92a2a,stroke-width:2px;
style SemanticView fill:#51cf66,stroke:#2b8a3e,stroke-width:2px;
Raw telemetry tables often feature cryptic column names and unscrubbed fields. The semantic view (scripts/setup_security_and_view.sql) projects clean business terminology:
CREATE VIEW FDE_VIEWS.VW_ACTIVE_FLEET AS
SELECT
TS_UTC AS [Timestamp],
V_LAT AS [Latitude],
V_LON AS [Longitude],
CAST(IOT_TEMP_VAL_C AS FLOAT) AS [Current_Temperature_C],
CGO_COND_CD AS [Cargo_Condition_Code],
RISK_CLS_TXT AS [Risk_Classification],
DELAY_PROB_DEC AS [Delay_Probability],
PRT_CNG_LVL AS [Port_Congestion_Level],
RT_RSK_IDX AS [Route_Risk_Index]
FROM dbo.TBL_SC_FLEET_HIST_RAW;The AI agent connects using a dedicated service account (USR_FDE_RO) with strictly partitioned grants:
-- Grant access ONLY to the semantic view
GRANT SELECT ON FDE_VIEWS.VW_ACTIVE_FLEET TO USR_FDE_RO;
-- Explicitly DENY access to the raw legacy table and schema modifications
DENY SELECT ON dbo.TBL_SC_FLEET_HIST_RAW TO USR_FDE_RO;
DENY INSERT, UPDATE, DELETE, ALTER ON SCHEMA::dbo TO USR_FDE_RO;
-- Grant INSERT ONLY to the audit log table
GRANT INSERT ON FDE_VIEWS.AgentAuditLog TO USR_FDE_RO;Every decision step, tool invocation, and LLM reasoning trace is automatically logged to FDE_VIEWS.AgentAuditLog for compliance inspection:
LogID: Auto-incrementing primary keyTimestamp: UTC event timeSessionID: Unique user thread identifierNodeExecuted: State machine node (reasonerortools)ToolName: Active tool executed (query_telemetry_db,fetch_corridor_conditions,search_compliance_sop)Content: Full serialized payload
The RAG pipeline (scripts/ingest_sop_pinecone.py) processes enterprise SOP documents (data/policy/Cold_Chain_Incident_SOP_v2.md) and stores vector representations in Pinecone Serverless.
Policy Documents βββΊ [SHA-256 Hash Verification] βββΊ [Polymorphic Parser]
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
[Semantic Header Chunking] (Recursive 600 chars / 60 overlap)
β
βΌ
[Embedding Engine] βββΊ Local BAAI/bge-m3 (1024-dim) OR Cloud OpenAI (1536-dim)
β
βΌ
[Pinecone Serverless Index] βββΊ Self-healing index dimension check & upsert
- Incremental Hash Caching (
ingestion_hash_cache.json):
Computes the SHA-256 digest of each file before processing. If a policy file has not changed, ingestion is bypassedβeliminating wasted API tokens and index write operations. - Polymorphic Document Ingestion:
Detects document extensions dynamically. Markdown files are partitioned viaMarkdownHeaderTextSplitterto preserve regulatory header hierarchies, while PDFs are extracted viapypdfwith character chunking. - RAM Model Caching (
@st.cache_resource):
Local Hugging Face embeddings (BAAI/bge-m3) are cached directly into system RAM to prevent reload overhead during Streamlit UI reruns. - Self-Healing Index Provisioning:
The script inspects existing Pinecone index dimensions against the target model (1024 vs. 1536 dim) and automatically reprovisions mismatched indexes if configuration switches between local and cloud embeddings.
The core reasoning agent (src/orchestrator.py) is assembled as a compiled LangGraph State Machine:
stateDiagram-v2
[*] --> Reasoner : START with User Message
Reasoner --> ToolsCondition : LLM Evaluates Intent
ToolsCondition --> ToolNode : Requires Telemetry / SOP / Weather
ToolsCondition --> [*] : Complete (Outputs Business Action Plan)
ToolNode --> Reasoner : Returns Tool Observation Output
- Purpose: Executes parameterized T-SQL queries against
FDE_VIEWS.VW_ACTIVE_FLEET. - Constraint: Enforces strict client-side validation ensuring only
SELECTqueries reach the database engine. Returns maximum 10 formatted rows.
- Purpose: Queries the live Open-Meteo REST API for external temperature, wind speed, and computes dynamic transit disruption scores.
- Resiliency: Handles timeout exceptions gracefully, returning fallback status strings rather than breaking the agent reasoning loop.
- Purpose: Performs cosine semantic vector retrieval against the Pinecone SOP index, injecting verbatim regulatory thresholds into the agent state.
The system prompt (src/prompts/system_prompt.txt) enforces an executive output contract for all operational inquiries:
### 1. Executive Summary
* [1-2 sentences summarizing core anomaly or situation]
* [State immediate operational risk]
### 2. Telemetry & Environment Analysis
| Location (Lat/Lon) | Current Temp | Cargo Risk | Weather / Congestion |
| :--- | :--- | :--- | :--- |
| ... | ... | ... | ... |
*Analysis:* [Identifies whether equipment failure or external conditions triggered anomaly]
### 3. Required Action Plan
1. **[Immediate Step 1]**: [Action derived directly from SOP]
2. **[Immediate Step 2]**: [Action derived directly from SOP]
*SOP Compliance Citation:* [Specific cited clause driving action plan]The Streamlit UI (src/ui.py) delivers a mission-critical command console for dispatch operators:
- Mission Control Chat: Conversational interface with streaming updates, tool trace expanders, and session memory.
- Active Fleet Telemetry Grid: Live viewer querying the SQL semantic view, displaying coordinates, internal sensor temperatures, risk classifications, and route risk scores.
- Dispatcher Quick-Test Actions: Preloaded scenario buttons for 1-click execution of complex multi-tool triage tasks.
- Admin Verification Console: Built-in SQL query tester for demonstrating RBAC security barriers (proves that
USR_FDE_ROcan access views but is denied access to raw tables). - Execution Audit Stream: Live tabular viewer of the append-only
AgentAuditLogtable.
This architecture can be hosted completely free using industry-standard free tiers without credit card commitments:
| Component | Free Provider | Free Tier Specification | Cost |
|---|---|---|---|
| Frontend / App Server | Streamlit Community Cloud | Unlimited public apps, 1GB RAM, auto-deploy from GitHub | $0 |
| Vector Database | Pinecone Serverless | 1 Starter Index, 100,000 vectors, AWS us-east-1 | $0 |
| External Weather API | Open-Meteo | Live meteorological API, no key required, 10,000 req/day | $0 |
| LLM Reasoner | Ollama (Local) or DeepSeek | Ollama (Local CPU/GPU: free) / DeepSeek (~$0.14/1M tokens) | $0 |
| Embeddings | Hugging Face (BAAI/bge-m3) |
Local open-source model running on CPU/RAM | $0 |
| Relational Database | AWS EC2 Free Tier or Local Docker | AWS EC2 t2.micro/t3.micro (750 hrs/month for 12 months) |
$0 |
- Fork or Push this repository to your GitHub account:
https://github.com/ansh1325/Forward-Deployed-Engg.git - Navigate to share.streamlit.io and click "New App".
- Configure the deployment settings:
- Repository:
ansh1325/Forward-Deployed-Engg - Branch:
main - Main file path:
src/ui.py
- Repository:
- Expand "Advanced settings..." and configure your Secrets (maps directly to your
.envvariables):SQL_SERVER_HOST = "your-ec2-public-ip-or-host" SQL_SERVER_PORT = "1433" SQL_ADMIN_USER = "sa" SQL_ADMIN_PASSWORD = "FdeEnterprisePass123!" SQL_AGENT_USER = "USR_FDE_RO" SQL_AGENT_PASSWORD = "AgentPassword2026!" PINECONE_API_KEY = "your-pinecone-api-key" Embeddings_model = "LOCAL" Local_Embedding_Model = "BAAI/bge-m3" Agent_llm = "DEEPSEEK" DEEPSEEK_API_KEY = "your-deepseek-api-key"
- Click Deploy! Streamlit Cloud automatically installs dependencies via
requirements.txtand system ODBC drivers viapackages.txt.
- Launch an AWS EC2
t2.microort3.microinstance running Ubuntu 24.04 LTS (eligible under AWS Free Tier). - Configure your EC2 Security Group:
- Inbound: Port
22(SSH from your IP) - Inbound: Port
1433(MSSQL from Streamlit Cloud or restricted IP) - Inbound: Port
8501(Streamlit Web UI)
- Inbound: Port
- SSH into your EC2 instance and enable a 4GB swapfile (essential for running MSSQL container on 1GB RAM instances):
sudo fallocate -l 4G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
- Install Docker and launch the MSSQL container:
curl -fsSL https://get.docker.com | sh sudo usermod -aG docker ubuntu newgrp docker docker run -d \ --name legacy-mssql \ -p 1433:1433 \ -e "ACCEPT_EULA=Y" \ -e "MSSQL_SA_PASSWORD=FdeEnterprisePass123!" \ --restart unless-stopped \ mcr.microsoft.com/mssql/server:2022-latest
- Python 3.11 or 3.12 installed
- Docker Desktop or Docker Engine installed
- Microsoft ODBC Driver 18 for SQL Server installed on your host OS
- Free Pinecone API Key (app.pinecone.io)
git clone https://github.com/ansh1325/Forward-Deployed-Engg.git
cd Forward-Deployed-Engg
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: .\venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create your .env from template
cp .env.example .envEdit .env with your API keys (PINECONE_API_KEY, DEEPSEEK_API_KEY or OPENAI_API_KEY).
docker compose up -dVerify the container is healthy:
docker pspython scripts/ingest_legacy_data.pyOutput: Loads 32,000+ IoT fleet records from data/raw/dynamic_supply_chain_logistics_dataset.csv into dbo.TBL_SC_FLEET_HIST_RAW.
python scripts/ingest_sop_pinecone.pyOutput: Hashes policy markdown files, provisions fde-sop-index-local on Pinecone, and upserts dense embeddings.
Open your preferred SQL tool (Azure Data Studio, VS Code SQL Server extension, or sqlcmd) and execute:
# Execute scripts/setup_security_and_view.sql against master DB as 'sa'Output: Creates FDE_VIEWS.VW_ACTIVE_FLEET, creates service user USR_FDE_RO, and enforces DENY constraints on raw tables.
streamlit run src/ui.pyVisit http://localhost:8501 in your browser.
Forward-Deployed-Engg/
βββ .github/
β βββ workflows/
β βββ deploy.yml # Automated SSH CI/CD deployment pipeline for EC2
βββ .streamlit/
β βββ config.toml # Dark-themed enterprise UI styling parameters
βββ assets/
β βββ resume_bullet_points.png # Resume and portfolio reference asset
βββ data/
β βββ cache/
β β βββ ingestion_hash_cache.json # SHA-256 state tracking for incremental RAG
β βββ policy/
β β βββ Cold_Chain_Incident_SOP_v2.md # Enterprise cold-chain SOP rules
β βββ raw/
β β βββ dynamic_supply_chain_logistics_dataset.csv # 32,000+ IoT telemetry rows
β βββ source/
β βββ data.txt # Kaggle upstream data source attribution
βββ docs/
β βββ instrutions.md # Original lab notes & step-by-step procedures
βββ Misc/
β βββ Materials/ # Technical Design Document (TDD) & Presentation
βββ scripts/
β βββ ingest_legacy_data.py # Phase 0: Pipeline loading raw CSV to MSSQL
β βββ ingest_sop_pinecone.py # Phase 1: High-density RAG parser & Pinecone upsert
β βββ setup_security_and_view.sql # Phase 2: RBAC service account & semantic view creation
βββ src/
β βββ prompts/
β β βββ system_prompt.txt # Structured executive output prompt contract
β βββ agent_tools.py # Core LangGraph tools (SQL, Weather, SOP)
β βββ orchestrator.py # LangGraph ReAct StateGraph definition
β βββ ui.py # Multi-threaded Streamlit Control Tower Console
βββ .env.example # Clean environment configuration template
βββ .gitignore # Comprehensive Python/Docker/Secrets ignore rules
βββ docker-compose.yml # 1-click local MSSQL legacy server deployment
βββ notes.pdf # Supplementary engineering architecture notes
βββ packages.txt # System ODBC dependencies for Streamlit Cloud
βββ README.md # Comprehensive project documentation
βββ requirements.txt # Pinned production Python dependencies
To demonstrate system robustness to an interviewer, execute these two standardized evaluation tests:
Dispatcher Query:
"Find any active shipments near Los Angeles (Latitude ~33.8, Longitude ~-118.1). Check the local weather there, and tell me if the current cargo temperature violates the SOP for fresh perishables."
Expected Autonomous Tool Execution Sequence:
- Tool 1 (
query_telemetry_db): QueriesFDE_VIEWS.VW_ACTIVE_FLEETfor records matching coordinates around(33.8, -118.1). Retrieves internal temperature (e.g.,8.2Β°C) and risk category. - Tool 2 (
fetch_corridor_conditions): Calls Open-Meteo REST API at coordinates(33.77, -118.19). Retrieves ambient temperature and wind speed to assess external heat soak. - Tool 3 (
search_compliance_sop): Queries Pinecone for "fresh perishables temperature range breach". Retrieves clause specifying standard range of0Β°C to 4Β°Cand critical breach threshold at>6Β°Cfor 60+ minutes. - Final Synthesis: Emits structured Markdown table, diagnoses cooling unit malfunction vs. ambient corridor conditions, and prescribes immediate re-routing to cold storage facility with citation of SOP Section 4.2.
Dispatcher Query:
"I'm a new dispatcher on the night shift. Can you quickly explain the difference between a Tier 1 and Tier 2 escalation?"
Expected Behavior:
- Agent recognizes this is a conceptual procedural question.
- Zero redundant SQL or weather tool calls are made.
- Queries SOP vector store once or responds directly from conversational context, conserving token latency and database compute.
In the Streamlit UI Admin panel or SQL console, test both queries with the agent account USR_FDE_RO:
-- TEST 1: Permitted (Access to clean semantic view)
SELECT TOP 5 * FROM FDE_VIEWS.VW_ACTIVE_FLEET;
-- Output: SUCCESS - Returns 5 rows
-- TEST 2: Prohibited (Access to raw legacy table)
SELECT TOP 5 * FROM dbo.TBL_SC_FLEET_HIST_RAW;
-- Output: FAILED - "The SELECT permission was denied on the object 'TBL_SC_FLEET_HIST_RAW'"**Forward Deployed AI Engineer β Cold-Chain Logistics Control Tower**
- Architected an autonomous incident response control tower using LangGraph, Python, and Streamlit, ingesting 32,000+ IoT fleet records and cross-referencing real-time telemetry with Open-Meteo weather APIs and enterprise SOPs.
- Hardened database security by implementing a Zero-Trust semantic view layer (FDE_VIEWS) and least-privilege RBAC service accounts, eliminating prompt injection SQL vulnerabilities with physical DML/DDL denial.
- Built a high-density Pinecone vector RAG pipeline with SHA-256 incremental hash caching and dynamic embedding dimension validation, cutting redundant embedding API costs by 100% on unmodified documents.
- Designed an automated CI/CD pipeline using GitHub Actions and AWS EC2 systemd daemons, enabling zero-downtime rolling deployments and append-only audit logging for regulatory compliance.- "Why LangGraph instead of a simple linear LangChain chain?"
Because cold-chain incident triage requires dynamic branching and cycles. The agent must reason, inspect SQL telemetry, decide whether external weather data is required based on temperature delta, query vector SOPs if an anomaly is detected, and loop back if clarifications are needed. - "How did you prevent the LLM from hallucinating SQL queries that could destroy tables?"
We decoupled LLM access through two physical barriers: client-side keyword validation restricting input to SELECT queries, and a hardened database layer where the agent's database role (USR_FDE_RO) is physically denied access to underlying tables and all DML/DDL schemas. - "How do you ensure auditability in a regulated supply-chain setting?"
Every state transition in the UI silently executes an append-only transaction intoFDE_VIEWS.AgentAuditLog, capturing the session thread ID, active tool invoked, raw payloads, and agent rationale for full post-incident postmortems.
This project is licensed under the MIT License β see the LICENSE file for details.