Skip to content

djm-1/QuotePilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuotePilot

QuotePilot is an AI-assisted CPQ workflow for creating budgetary SaaS quotes from natural-language sales requests. A seller can describe the customer, country, products, quantities, and commercial intent in chat; QuotePilot resolves the structured quote, asks for missing information, prices from the backend catalog, retrieves policy context from Pinecone, shows an editable draft, and generates a professional PDF.

The core design rule is intentional: the LLM helps interpret the request and retrieve policy context, but exact products, prices, tax, discounts, totals, quote ownership, and PDF generation are controlled by Django backend logic.

What It Demonstrates

  • Stateful agent workflow with LangGraph for multi-turn quote creation.
  • RAG-backed policy retrieval using OpenAI embeddings and Pinecone.
  • Deterministic pricing, tax, discount, and quote-line snapshot logic.
  • Django REST APIs with token auth, quote ownership, admin-managed catalog data, and PDF downloads.
  • React + TypeScript dashboard with chat, live quote draft, editable line quantities, discount updates, quote history, CSV export, and knowledge upload.
  • ReportLab PDF generation with quote-time policy snapshots for auditability.
  • Production deployment configuration for Render Web Services, Render Postgres, and a static React frontend.

Stack

  • Backend: Django 5, Django REST Framework, LangGraph, ReportLab, Gunicorn, WhiteNoise
  • Frontend: Vite, React, TypeScript, Tailwind CSS, Playwright
  • Database: SQLite locally, PostgreSQL in production through DATABASE_URL
  • RAG: OpenAI text-embedding-3-small embeddings with Pinecone namespace retrieval
  • Deployment: Docker Compose for DigitalOcean VPS, plus optional Render blueprint

Architecture

flowchart LR
  User["Sales user"] --> UI["React TypeScript dashboard"]
  UI --> API["Django REST API"]
  API --> Agent["LangGraph quote agent"]
  Agent --> DB["Postgres products, quotes, tax rules"]
  Agent --> Pinecone["Pinecone policy vectors"]
  Agent --> OpenAI["OpenAI extraction + embeddings"]
  API --> PDF["ReportLab PDF generator"]
  PDF --> Media["Persistent media storage"]
Loading

Key Flows

  • Complete quote: Create a budgetary quote for Acme Corp in Singapore for 20 CRM Pro seats and analytics.
  • Missing info: Create a quote for 50 CRM users.
  • Ambiguous product: Quote CRM for Acme Corp in India.
  • Modification: Change CRM Pro to 17 seats and apply 10 percent discount.
  • Approval: Looks good, generate the PDF.

Local Development

Backend:

cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
python manage.py migrate
python manage.py seed_demo
python manage.py runserver

Frontend:

cd frontend
pnpm install
cp .env.example .env
pnpm dev

Open http://127.0.0.1:5173.

Required Environment

Backend variables:

SECRET_KEY=replace-me
DEBUG=False
ALLOWED_HOSTS=your-api.onrender.com
FRONTEND_URL=https://your-frontend.onrender.com
CORS_ALLOWED_ORIGINS=https://your-frontend.onrender.com
CSRF_TRUSTED_ORIGINS=https://your-api.onrender.com,https://your-frontend.onrender.com
DATABASE_URL=postgresql://...
MEDIA_ROOT=/var/data/media
OPENAI_API_KEY=...
OPENAI_MODEL=gpt-4o-mini
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_EMBEDDING_DIMENSIONS=1024
PINECONE_API_KEY=...
PINECONE_INDEX=quotepilot-kb
PINECONE_NAMESPACE=quotepilot-production

Frontend variable:

VITE_API_BASE_URL=https://your-api.onrender.com/api

DigitalOcean VPS Deployment

The repo includes a VPS deployment bundle in deploy/digitalocean:

  • Django API container
  • Postgres 16 container with persistent volume
  • Caddy reverse proxy with automatic HTTPS
  • conservative Postgres memory settings for a 1 GB Droplet
  • one Gunicorn worker with two threads for low-memory stability

Recommended split:

  • Backend + DB: DigitalOcean Droplet
  • Frontend: Vercel
  • DNS: Cloudflare or your domain registrar
  • RAG/LLM: Pinecone and OpenAI

Quick deployment shape:

git clone https://github.com/djm-1/QuotePilot.git
cd QuotePilot/deploy/digitalocean
cp .env.example .env
docker compose up -d --build

Read the full VPS guide in deploy/digitalocean/README.md.

For a 1 GB Droplet, enable 2 GB swap before starting containers. It can run QuotePilot for light portfolio traffic, but upgrade to 2 GB or 4 GB if you also host SupportBench on the same VPS.

Vercel Frontend Deployment

Use Vercel for the React frontend:

  1. Import https://github.com/djm-1/QuotePilot.git.
  2. Set the project root directory to frontend.
  3. Build command: pnpm build.
  4. Output directory: dist.
  5. Environment variable:
VITE_API_BASE_URL=https://api.yourdomain.com/api

After Vercel deploys, update the backend .env on the Droplet:

FRONTEND_URL=https://your-vercel-app.vercel.app
CORS_ALLOWED_ORIGINS=https://your-vercel-app.vercel.app
CSRF_TRUSTED_ORIGINS=https://api.yourdomain.com,https://your-vercel-app.vercel.app

Then restart the backend:

cd QuotePilot/deploy/digitalocean
docker compose up -d

Render Deployment

The repo includes a root-level render.yaml blueprint with:

  • quotepilot-api: Django web service
  • quotepilot-web: static React frontend
  • quotepilot-db: managed Postgres
  • /var/data persistent disk for generated PDFs
  • pre-deploy migrations and catalog seeding

Recommended Render flow:

  1. Push this repository to GitHub.
  2. In Render, create a new Blueprint from the repo.
  3. Set the unsynced backend env vars: OPENAI_API_KEY, PINECONE_API_KEY, PINECONE_INDEX, FRONTEND_URL, CORS_ALLOWED_ORIGINS, and CSRF_TRUSTED_ORIGINS.
  4. Set frontend VITE_API_BASE_URL to https://<api-service>.onrender.com/api.
  5. Deploy the API first, then update/redeploy the frontend after the API URL is known.
  6. Visit /healthz/ on the API service to confirm the backend is live.
  7. Register a user from the UI, download the vendor policy pack, upload it through Knowledge, then create a quote.

For production demos, use paid Render services. Free web services can sleep and make the portfolio feel unreliable.

Admin And Data Setup

Create an admin user:

cd backend
python manage.py createsuperuser

Seed catalog and tax data:

python manage.py seed_demo

Replace the active Pinecone policy pack from the bundled PDF:

python manage.py replace_policy_pack ../output/pdf/quotepilot-vendor-policy-pack.pdf --source-name quotepilot-vendor-policy-pack

Product catalog, tax rules, customers, quotes, and audit events live in Postgres. Active policy text lives in Pinecone; Django stores lightweight metadata previews and quote-time policy snapshots.

API Surface

  • POST /api/auth/register/
  • POST /api/auth/login/
  • POST /api/chat/sessions/
  • POST /api/chat/sessions/{id}/messages/
  • GET /api/products/
  • GET /api/quotes/
  • GET /api/quotes/{id}/
  • PATCH /api/quotes/{id}/
  • POST /api/quotes/{id}/generate-pdf/
  • GET /api/quotes/{id}/download/
  • GET /api/knowledge/documents/
  • POST /api/knowledge/upload/
  • GET /api/knowledge/policy-pack/download/

Testing

Backend:

cd backend
.venv/bin/python manage.py test quotes

Frontend build:

cd frontend
pnpm build

End-to-end smoke tests:

cd frontend
pnpm test:e2e

Portfolio Notes

QuotePilot is intentionally scoped as an MVP, but it is built around real production concerns: ownership boundaries, audit snapshots, deterministic pricing, Pinecone-primary knowledge retrieval, editable drafts, generated PDFs, and deployment-ready service configuration. The project is a better resume signal than a generic CRUD app because it combines full-stack engineering, backend business rules, agent workflow design, and practical AI integration.

About

AI agentic CPQ workflow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors