STRIDE_Assistant

STRIDE Assistant — Policy‑First Retail AI for Footwear Complaints (Backend + AI)

STRIDE Assistant is a backend-first AI system for a premium footwear brand that automates complaint triage (return/refund, replacement, repair, paid repair, inspection, reject) using a policy‑first RAG pipeline.
It is designed to demonstrate production‑style backend engineering: clear service boundaries, deterministic decisioning, auditability, and safe LLM integration.

Core idea: The LLM helps with language understanding and customer communication, while the decision authority remains deterministic and policy-driven.


Why this project

Footwear complaint handling looks simple but isn’t: warranty windows, purchase dates, outlet constraints, stock availability, and misuse signals create a decision space where speed + consistency + traceability are hard requirements.

This project shows how to:


Key features


System diagram (end-to-end)

                         +------------------------+
                         | Customer / Chat UI     |
                         | (Web, WhatsApp-like)   |
                         +-----------+------------+
                                     |
                                     v
                         +------------------------+
                         | FastAPI Chat API       |
                         | /chat/auth,start,respond|
                         +-----------+------------+
                                     |
                                     v
                     +-----------------------------------+
                     | STRIDERAGPipeline (Orchestrator)  |
                     | - turn mgmt + signal arbitration  |
                     +-----------+-----------------------+
                                 |
                                 v
                      +----------------------------+
                      | Semantic Analyzer (LLM)    |
                      | Intent + misuse/accident   |
                      +-----------+----------------+
                                  |
                                  v
                  +------------------------------------+
                  | Policy Retriever (RAG)             |
                  | - eligible intents + day windows   |
                  | - semantic similarity over chunks  |
                  +----------------+-------------------+
                                   |
                                   v
                  +------------------------------------+
                  | Decision Engine (Deterministic)    |
                  | - returns/repairs/replacements     |
                  | - warranty + misuse handling       |
                  +------------------+-----------------+
                                     |
                                     v
                 +-------------------+-------------------+
                 |                                       |
                 v                                       v
   +---------------------------+                +--------+---------+
   | Auto Outcome  (Ticket)    |                |   Reject Signal  |
   | REPAIR / REPLACEMENT      |                |     GCD Token    |
   | PAID_REPAIR / REJECT      |                +--------+---------+
   |  INSPECTION / RETURN      |                         |
   | Manual / Inspection       |                         v
   +-------------+-------------+                +--------+---------+
                 |                              |   Close Chat     |
                 |                              +------------------+
                 |                         
                 |                         
                 |                         
                 |                                       
                 +---------------------+
                                       |
                                       v
                         +---------------------------+
                         | Ticket Created / Updated  |
                         | (Postgres)                |
                         +-------------+-------------+
                                       |
                                       v
                         +----------------------------+
                         | Prompt Builder (Safe UX)   |
                         | Policy-safe response text  |
                         +-------------+--------------+
                                       |
                                       v
                         +----------------------------+
                         | Ollama LLM (Streaming)     |
                         +-------------+--------------+
                                       |
                                       v
                         +----------------------------+
                         | Customer Response (SSE)    |
                         +----------------------------+

   Side services:
   - Redis: cached orders + inventory lookups
   - Postgres: tickets + staff audit logs + chat summaries

Tech stack

Repository structure

├── api/                 # FastAPI routers (chat, staff, admin)
├── cache/               # Redis-backed cache helpers (orders/inventory)
├── db/                  # Postgres operations (tickets, audit, auth, chat)
├── ingest/              # Policy ingestion scripts
├── policies/            # Markdown policies (source of truth)
├── rag/                 # analyzer, retriever, decision engine
├── Services/            # prompt builder, logger, embedder utilities
├── Logs/                # log files
├── main.py              # FastAPI entrypoint
└── README.md

How it works (decision philosophy)

This system intentionally splits responsibilities: 1) Semantic understanding (probabilistic)

2) Policy enforcement (deterministic)

This architecture prevents “LLM as judge” failure modes and keeps outcomes explainable.

Ticket types

The pipeline resolves requests into one of:

Redis

REDIS_HOST=redis REDIS_PORT=6379 REDIS_USER=stride_admin REDIS_PASSWORD=stride_password REDIS_DB=0

Postgres

DB_NAME=stride DB_USER=stride DB_PASSWORD=stride DB_HOST=postgres DB_PORT=5432

2) Start services
```bash
docker compose up --build

3) Verify API

curl http://localhost:8000/

Policy ingestion (RAG data build)

Policies are authored in Markdown under policies/. An ingestion script splits policies into chunks, embeds them, and stores them in a local policy DB (SQLite) for semantic retrieval.

Typical flow:

python ingest/ingest_policies.py

Testing

The test strategy is intentionally backend‑centric:

Run:

pytest -q

Engineering highlights (what this project shows off)

Roadmap

Author Shushant Rishav

Project: STRIDE Assistant