A full-stack AI-powered paint consultation platform that helps users find the right Nash Paints products, get color recommendations, visualize paint applications, and chat with an AI consultant.
- AI Chat Consultant: Conversational AI assistant powered by GPT-4o mini that provides paint recommendations and answers questions
- Product Search: Semantic search using RAG (Retrieval-Augmented Generation) with ChromaDB for finding paint products
- Color Recommendation: AI-powered color extraction from uploaded images with matching Nash Paints product suggestions
- Virtual Repaint Preview: Generate visual previews of how paint colors would look on uploaded images
- Image Generation: DALL-E 3 integration for generating visual representations of paint applications
- Branch Locator: Find nearby Nash Paints branches with stock availability information
- Product Cards: Rich product displays with images, prices, and purchase links
- Conversation Context: Maintains conversation history for contextual responses
- Image Context Tracking: References previous images when generating variations
- Streaming Responses: Real-time streaming chat responses for better UX
- Markdown Rendering: Formatted text display in chat messages
- Product Recommendations: Automatic product card display when products are mentioned
- Framework: FastAPI (Python)
- Database: PostgreSQL (production) / SQLite (development)
- ORM: SQLAlchemy
- Vector DB: ChromaDB for semantic search
- AI/ML:
- OpenAI GPT-4o mini (chat)
- OpenAI DALL-E 3 (image generation)
- LangChain (RAG orchestration)
- OpenAI Embeddings (vector search)
- Image Processing: Pillow (PIL)
- Other: Pydantic, python-dotenv
- Framework: Next.js 15 (React)
- Language: TypeScript
- Styling: TailwindCSS 3.4
- UI Components: Custom components with shadcn/ui patterns
- Markdown: react-markdown with remark-gfm
nashpaint1/
โโโ backend/
โ โโโ app/
โ โ โโโ config.py # Application settings and environment variables
โ โ โโโ db.py # Database connection and session management
โ โ โโโ main.py # FastAPI application entry point
โ โ โโโ seed_data.py # Database seeding script
โ โ โโโ models/
โ โ โ โโโ product.py # Product data model
โ โ โ โโโ branch.py # Branch/location model
โ โ โ โโโ stock.py # Stock inventory model
โ โ โโโ routers/
โ โ โ โโโ chat.py # AI chat endpoint
โ โ โ โโโ products.py # Product search endpoint
โ โ โ โโโ colors.py # Color recommendation endpoint
โ โ โ โโโ repaint.py # Virtual repaint endpoint
โ โ โ โโโ upload.py # Image upload endpoint
โ โ โโโ services/
โ โ โโโ rag_service.py # RAG and vector search service
โ โ โโโ color_extractor.py # Color extraction from images
โ โ โโโ virtual_repaint.py # Image repainting service
โ โโโ uploads/ # Uploaded user images
โ โโโ repaints/ # Generated repaint previews
โ โโโ requirements.txt # Python dependencies
โโโ frontend/
โ โโโ app/
โ โ โโโ layout.tsx # Root layout with header
โ โ โโโ page.tsx # Home page
โ โ โโโ chat/
โ โ โ โโโ page.tsx # Chat interface
โ โ โโโ products/
โ โ โ โโโ page.tsx # Product search page
โ โ โโโ repaint/
โ โ โโโ page.tsx # Virtual repaint page
โ โโโ components/
โ โ โโโ ChatMessageBubble.tsx # Chat message component
โ โ โโโ ProductCard.tsx # Product display card
โ โ โโโ ColorSwatch.tsx # Color swatch component
โ โ โโโ ImageUploader.tsx # Image upload component
โ โ โโโ RepaintPreview.tsx # Repaint preview component
โ โโโ lib/
โ โ โโโ api.ts # API client functions
โ โ โโโ utils.ts # Utility functions
โ โโโ assets/
โ โ โโโ icon-02-primary.png # Nash Paints logo
โ โโโ package.json # Node.js dependencies
โโโ README.md # This file
- Python 3.12+
- Node.js 18+ and npm
- PostgreSQL (for production) or SQLite (for development)
- OpenAI API key (for AI features)
-
Navigate to project root:
cd /path/to/nashpaint1 -
Create virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r backend/requirements.txt
-
Create
.envfile in project root:# Database (use SQLite for development) DATABASE_URL=sqlite:///./nashpaints.db # For production PostgreSQL: # DATABASE_URL=postgresql+psycopg2://user:password@localhost:5432/nashpaints # OpenAI API (required for AI features) OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-4o-mini # Optional: HuggingFace token HF_API_TOKEN=your_hf_token_here
-
Seed the database:
DATABASE_URL=sqlite:///./nashpaints.db python -m backend.app.seed_data
This creates:
- Sample products (Decorative, Industrial, Automotive, Woodline)
- Dummy branch locations (Chitungwiza, Msasa, Graniteside)
- Stock inventory data
- ChromaDB vector index
-
Run the backend:
uvicorn backend.app.main:app --reload --port 8000
Backend will be available at
http://localhost:8000- API docs:
http://localhost:8000/docs - Health check:
http://localhost:8000/health
- API docs:
-
Navigate to frontend directory:
cd frontend -
Install dependencies:
npm install
-
Create
.env.local(optional, defaults to localhost:8000):NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
-
Run the development server:
npm run dev
Frontend will be available at
http://localhost:3000
POST /api/products/search- Search products using RAG + keyword search{ "query": "interior matt white", "limit": 10 }
POST /api/chat- Stream chat responses with AI consultantReturns: Streaming text response with{ "message": "What paint should I use for my roof?", "history": [ {"role": "user", "content": "...", "images": []}, {"role": "assistant", "content": "...", "images": []} ] }[PRODUCTS:...]and[IMAGE:...]markers
POST /api/colors/recommend- Extract colors from image and recommend products{ "image_path": "filename.jpg" }
POST /api/upload/image- Upload image file Returns:{"url": "/static/uploads/filename.jpg"}
POST /api/repaint- Generate virtual repaint previewReturns:{ "image_url": "/static/uploads/filename.jpg", "target_hex": "#E1251B" }{"repainted_image_url": "/static/repaints/repaint_xxx.jpg"}
- id (Integer, PK)
- name (String) - e.g., "Nash Decorative Interior Matt White"
- description (String, nullable)
- line (String) - Decorative, Industrial, Automotive, Woodline, Accessories
- type (String) - Acrylic, Enamel, 2K Urethane, etc.
- finish (String, nullable) - Matt, Silk, Gloss
- base (String, nullable) - Water-based, Solvent-based
- color_name (String, nullable)
- color_hex (String, nullable) - Hex color code
- image_url (String, nullable)
- coverage_m2_per_litre (Float, nullable)
- price (Float, nullable)
- purchase_link (String, nullable)- id (Integer, PK)
- name (String) - e.g., "Nash Paints Chitungwiza Makoni"
- city (String) - e.g., "Harare"
- area (String, nullable) - e.g., "Chitungwiza"
- address (String, nullable)
- phone (String, nullable)
- latitude (String, nullable)
- longitude (String, nullable)- id (Integer, PK)
- branch_id (Integer, FK -> branches.id)
- product_id (Integer, FK -> products.id)
- quantity_litres (Float) - Available stock in litres| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
Database connection string | postgresql+psycopg2://... |
OPENAI_API_KEY |
OpenAI API key for AI features | None |
OPENAI_MODEL |
OpenAI model to use | gpt-4o-mini |
HF_API_TOKEN |
HuggingFace API token (optional) | None |
CHROMA_PERSIST_DIR |
ChromaDB persistence directory | backend/chroma_data |
Backend allows requests from:
http://localhost:3000http://localhost:3001http://localhost:3002http://localhost:3003
Configure in backend/app/config.py if needed.
Backend:
uvicorn backend.app.main:app --reload --port 8000Frontend:
cd frontend
npm run devTo reset and reseed the database:
rm -f nashpaints.db backend/nashpaints.db
DATABASE_URL=sqlite:///./nashpaints.db python -m backend.app.seed_dataFrontend:
cd frontend
npm run build
npm startBackend:
# Use a production ASGI server like gunicorn with uvicorn workers
gunicorn backend.app.main:app -w 4 -k uvicorn.workers.UvicornWorker- Products are indexed in ChromaDB with embeddings
- User queries are embedded and matched against product descriptions
- Top matches are retrieved and passed to LLM for context-aware responses
- Uses Pillow for image processing
- Quantizes images to extract dominant colors
- Matches extracted colors to Nash Paints product color_hex values
- Applies color overlay effects to uploaded images
- Simulates paint application using image processing
- Saves results to
backend/repaints/directory
- Maintains full conversation history
- Tracks generated images for reference
- Extracts product mentions from both user and assistant messages
- Automatically displays product cards when products are mentioned
- Detects image generation requests in chat
- Uses DALL-E 3 to create visual representations
- Maintains context from previous images when generating variations
- Includes product recommendations with generated images
Import errors:
- Ensure virtual environment is activated
- Run
pip install -r backend/requirements.txt
Database connection errors:
- Check
DATABASE_URLin.env - For SQLite, ensure write permissions in project directory
- For PostgreSQL, ensure database exists and credentials are correct
OpenAI API errors:
- Verify
OPENAI_API_KEYis set in.env - Check API key is valid and has credits
ChromaDB errors:
- Delete
backend/chroma_datadirectory and re-run seed script - Ensure write permissions for ChromaDB directory
Module not found:
- Run
npm installinfrontend/directory - Clear
.nextcache:rm -rf frontend/.next
API connection errors:
- Verify backend is running on port 8000
- Check
NEXT_PUBLIC_API_BASE_URLin.env.local - Check CORS settings in backend config
Build errors:
- Clear node_modules and reinstall:
rm -rf node_modules && npm install - Check Node.js version (requires 18+)
This project is proprietary software for Nash Paints.
This is a private project. For contributions, contact the project maintainer.
- Real-time stock updates
- User authentication and saved projects
- Advanced image-to-image diffusion for repaints
- Multi-language support
- Mobile app
- Integration with Nash Paints e-commerce platform
- Advanced color matching algorithms
- Paint quantity calculator
- Project cost estimation
Built with โค๏ธ for Nash Paints