chat2cart is an AI-powered shopping assistant that lets users interact via chat to build, modify, and check out a shopping cart. Through a natural conversation, users can discover products, add or remove items, and complete or cancel their purchase—all from the chat interface.
docker compose up --build- 💬 Natural Language Shopping: Chat with AI to find and purchase products
- 🛒 Smart Cart Management: Add, remove, and modify items through conversation
- 🔍 Product Discovery: Search across multiple categories with AI assistance
- 🛍️ Real-time Cart Updates: See your cart update instantly as you chat
- 💳 Seamless Checkout: Complete purchases through the chat interface
- 📱 Responsive Design: Works perfectly on desktop and mobile devices
- Backend: Go with Gin web framework
- AI Integration: OpenAI GPT-4 with function calling for tool use
- Frontend: Vanilla JavaScript with modern CSS
- Data Storage: In-memory (perfect for demo/development)
chat2cart/
├── Makefile # Build and development commands
├── main.go # Application entry point
├── config/
│ └── config.go # Configuration management
├── internal/
│ ├── handlers/ # HTTP request handlers
│ ├── models/ # Data models and structures
│ ├── services/ # Business logic services
│ └── tools/ # AI tool definitions
└── web/
├── static/ # CSS and JavaScript files
└── templates/ # HTML templates
- Go 1.18 or higher
- OpenAI API key
-
Clone the repository
git clone https://github.com/ilopezluna/chat2cart.git cd chat2cart -
Install dependencies
make setup
-
Set your OpenAI API key
export OPENAI_API_KEY=your_api_key_hereOr create a
.envfile:echo "OPENAI_API_KEY=your_api_key_here" > .env
-
Run the application
make run
-
Open your browser Navigate to
http://localhost:8080
- Open the chat interface in your browser
- Start typing natural language requests like:
- "I need a new laptop for work"
- "Show me some running shoes under $200"
- "Add an iPhone to my cart"
- "What's in my cart?"
- "Remove the headphones from my cart"
- "I'm ready to checkout"
The demo includes 50+ products across categories:
- Electronics: iPhones, laptops, headphones, cameras
- Clothing: Jeans, sneakers, jackets, accessories
- Books: Fiction, non-fiction, business, self-help
- Home: Kitchen appliances, smart devices, furniture
- Sports: Fitness equipment, outdoor gear, athletic wear
make help # Show available commands
make setup # Install dependencies
make run # Start development server
make build # Build the application
make clean # Clean build artifactsOPENAI_API_KEY: Your OpenAI API key (required)PORT: Server port (default: 8080)ENVIRONMENT: Environment mode (default: development)
# 1. Clone and setup
git clone https://github.com/ilopezluna/chat2cart.git
cd chat2cart
make setup
# 2. Set API key
export OPENAI_API_KEY=sk-your-key-here
# 3. Run
make run
# 4. Open browser to http://localhost:8080
# 5. Start chatting: "I need a new laptop"The AI assistant uses OpenAI's function calling to execute shopping actions:
search_products: Find products by name, description, or categoryadd_to_cart: Add products with specified quantitiesremove_from_cart: Remove items from the shopping cartview_cart: Display current cart contents and totalsupdate_quantity: Modify item quantitiescheckout: Process the purchase