This is the initial implementation of our AI-powered Marketplace Assistant. It's a monolithic application that handles all aspects of the shopping experience, from product recommendations to delivery estimation, purchase processing, and notifications.
This a classic Agent setup where an LLM uses tool calling to find info and execute tasks.
There's a minor twist where we also call another Agent using a tool call (simulated for delivery estimates).
- Understanding user requests
- Product recommendations
- Inventory management
- Purchase processing
- Delivery estimation
- Customer notifications
We can break this into a crew of agents, but we’d still be dealing with similar limitations for production!
This initial implementation has several limitations:
- High Latency: The monolithic agent must process all aspects of a user request sequentially.
- Token Inefficiency: The whole context is passed to the LLM for every operation, even for deterministic tasks.
- Reliability Issues: A failure in any component impacts the entire application.
- Debugging Complexity: Difficult to isolate issues within the monolith.
- Scalability Challenges: The entire application needs to scale together.
- Managing State Across failures is hard: When failures occur mid-transaction, the system can be left in an inconsistent state.
The application has a critical issue that demonstrates the need for proper transaction handling:
- When a user attempts to purchase a product, the inventory is reduced BEFORE payment processing
- If the payment fails (simulated 50% of the time) because the Payment Gateway is down, the inventory remains reduced
- This creates a data inconsistency where products appear out of stock but were never actually purchased
- In a production system, this would require manual intervention to fix
This bug was deliberately included to demonstrate why compensation handling is necessary in distributed systems, which we'll address in Stage 2 of the guide.
NOTE: We've kept the failure quite simple here. Payments can also be rejected quite a bit later in the future - in that case more complicated recovery is required.
- Install dependencies:
npm install
- Setup the appplication's data:
cp data.json-example data.json
- Start the application:
npm start
- Interact with the assistant via the terminal interface, using this interaction script.
In the next stage, we'll refactor this monolithic application into a multi-agent architecture using orra to orchestrate different specialised components.