Vending Machine is a full-stack application based off of Project Vend by Anthropic. It allows for purchasing virtual items offered on the vending machine through an AI Agent, where item selection and restocking is also orchestrated through other AI Agents.
- Backend: Python, FastAPI, LangGraph, LangChain, and OpenAI
- Frontend: Angular, TypeScript, and Vitest
.
|-- backend/ FastAPI service, agent graph, prompts, and backend tests
|-- frontend/ Angular application and frontend tests
- Python 3.10 or newer
- Node.js with npm
- An OpenAI API key for the backend
From the repository root, run:
cd backend
python -m venv venv
venv\Scripts\python.exe -m pip install -r requirements.txt
copy .env.example .envSet the backend values in backend/.env. The supported settings are:
AI_PROVIDERAI_API_KEYAI_MODELAI_TEMPERATUREAI_MAX_TOKENSVENDING_CURRENCY
Start the backend from the backend directory:
set PYTHONPATH=src
venv\Scripts\python.exe -m uvicorn vending_machine.main:app --reloadThe service runs at http://localhost:8000. FastAPI's interactive API documentation is available at http://localhost:8000/docs.
From the repository root, run:
cd frontend
npm install
npm startThe Angular development server runs at http://localhost:4200.
Run the backend and frontend in separate terminals during development.
GET /returns a service health response.POST /conversationscreates a conversation.POST /conversations/{conversation_id}/messagesstreams assistant output as server-sent events.GET /inventoryreturns every slot in the vending machine.
Run backend tests from backend:
set PYTHONPATH=src
venv\Scripts\python.exe -m unittest discover -s testsRun frontend tests and a production build from frontend:
npm test
npm run buildDo not commit backend/.env or any other secret values.