An intelligent invoice assistant that turns user input into structured invoices, validates missing fields, and suggests additions before final generation. Enhanced with advanced AI features, structured validation, memory, and business capabilities.
- Real LLM Integration: Uses Google Gemini for intelligent parsing and response generation
- Structured Output Validation: Pydantic models ensure data integrity with schema validation
- RAG System: Retrieval-Augmented Generation for FAQ responses
- Multi-Model Fallback: Automatic fallback between different LLM providers
- Tool Calling: Integrated tools for currency conversion, calculations, and more
- Conversation History: Maintains context across multiple interactions
- Session Management: Tracks conversation state and invoice drafts
- Context-Aware Processing: Remembers previous inputs for seamless experience
- Professional PDF Generation: Automatically creates branded invoice PDFs
- Currency Conversion: Real-time currency conversion with caching
- Tax Calculations: GST/VAT calculations with configurable rates
- Invoice Storage: Persistent storage with JSON backup
- Streaming Responses: Real-time, typewriter-like response streaming
- Modern UI: React + Tailwind CSS with intuitive design
- Interactive Catalog: Browse and add products seamlessly
- Real-time Cart: Live cart updates and checkout flow
graph TB
A[User Interface] --> B[Frontend React App]
B --> C[Backend API]
C --> D[Invoice Assistant]
D --> E[LLM Manager]
E --> F[Gemini API]
E --> G[OpenAI API]
E --> H[Fallback Logic]
D --> I[RAG System]
I --> J[FAQ Database]
D --> K[Invoice Parser]
K --> L[Pydantic Validation]
D --> M[Session Manager]
M --> N[Conversation History]
D --> O[Invoice Engine]
O --> P[PDF Generator]
O --> Q[Storage System]
D --> R[Currency Converter]
R --> S[Exchange Rate API]
style A fill:#4CAF50,stroke:#388E3C,color:#fff
style F fill:#FF9800,stroke:#F57C00,color:#fff
style J fill:#2196F3,stroke:#1976D2,color:#fff
style P fill:#9C27B0,stroke:#7B1FA2,color:#fff
CustomerCare-ChatBot/
├── api/ # Vercel serverless API entrypoint
│ └── app.py
├── backend/ # Local Flask backend + core logic
│ ├── core/
│ │ ├── agent.py # Main agent logic
│ │ ├── models.py # Pydantic models
│ │ ├── rag_system.py # RAG implementation
│ │ ├── llm_manager.py # Multi-model management
│ │ └── currency_converter.py # Currency conversion
│ ├── scripts/
│ │ └── generate_invoice_pdf.py # Professional invoice PDF generation
│ ├── app.py
│ └── requirements.txt
├── frontend/ # Web chat interface
│ ├── src/
│ │ ├── data/
│ │ ├── App.jsx # Enhanced with streaming
│ │ ├── index.css
│ │ └── main.jsx
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── postcss.config.js
│ ├── script.js
│ ├── style.css
│ ├── tailwind.config.js
│ └── vite.config.js
├── .gitignore
├── README.md
├── package.json
└── vercel.json
cd backend
pip install -r requirements.txt
# Set environment variables
export GOOGLE_API_KEY="your-gemini-api-key"
export OPENAI_API_KEY="your-openai-api-key" # Optional
export EXCHANGE_RATE_API_KEY="your-exchange-rate-api-key" # Optional
# Run the backend
python app.pyBackend runs at http://localhost:5000.
cd frontend
npm install
npm run dev- Push this repo to GitHub.
- Import the project in Vercel.
- Vercel will auto-detect
vercel.jsonand deploy:- Static frontend from
frontend/ - Python API from
api/app.py(/api/chat,/api/stream-chat,/api/health) - Python dependencies from
api/requirements.txt
- Static frontend from
- After deploy, open your Vercel URL and chat with the assistant.
Frontend uses
http://localhost:5000/chatin local mode and automatically switches to/api/chatin production.
If you see 404: NOT_FOUND, make sure:
vercel.jsonexists in the repo root (this project already includes it).- Your Vercel Root Directory is set to the repository root (
CustomerCare-ChatBot). - You redeploy after pulling the latest commit (rewrites are required for
/and/api/*).
If you saw Function Runtimes must have a valid version, this repo now uses Vercel builds/routes instead of functions.runtime to avoid that error.
This repo now routes:
/→frontend/index.html/<asset>→frontend/<asset>/api/*→api/app.py
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/chat |
POST | Standard chat endpoint |
/api/stream-chat |
POST | Streaming chat endpoint |
/api/invoices |
GET | List all invoices |
/api/invoices/:id |
GET | Get specific invoice |
- Invoice generation from plain text (e.g.,
2x Sneakers @ 2499). - Intelligent validation for required fields:
- invoice number
- customer name
- customer email
- at least one line item
- AI-style suggestions for missing details.
- Dynamic totals with tax, shipping, and discount.
- Real-time streaming responses for better UX
- Context-aware conversation history for continuity
- Professional PDF invoice generation
- Multi-currency support with conversion API
- RAG-based FAQ system for common questions
- Multi-model fallback for reliability
- Tool calling capabilities for external functions
- Developed an AI-driven invoicing system with advanced LLM integration and structured validation.
- Implemented RAG system for FAQ retrieval and context-aware responses.
- Added multi-model fallback with automatic failover between providers.
- Created streaming response frontend for real-time interactions.
- Built tool calling architecture for currency conversion and other utilities.
- Enhanced session management with conversation history tracking.
Generate invoice: invoice number: INV-1001, customer: Alex, email: alex@shop.com, 2x Sneakers @ 2499, tax: 18, shipping: 99
Add 3 shirts to my order
Convert 100 USD to EUR
What payment methods do you accept?
- Response Time: Average 800ms for standard queries
- LLM Fallback: Seamless transition between providers
- Caching: Exchange rates cached for 30 minutes
- Scalability: Session-based state management