Inspiration
ShadowBid was born from the frustration of navigating complex online marketplaces where finding the best deal requires juggling multiple negotiations simultaneously. The project aims to democratize expert negotiation tactics through AI, allowing anyone to leverage strategic bargaining across multiple sellers without the emotional toll and time investment of manual negotiations. Inspired by game theory principles and the emergence of accessible AI APIs, we set out to create a system that could negotiate better than humans by removing emotional bias and leveraging data-driven decision making.
How We Built It
Architecture Design
The system follows a layered architecture with clear separation of concerns:
- Frontend Layer: Next.js 14 with React and TypeScript provides a responsive interface for searching items and monitoring negotiations in real-time
- API Gateway: FastAPI handles routing, CORS, and serves as the central communication hub
- Business Logic: Orchestration services manage the negotiation flow and state transitions
- AI Intelligence Layer: Two specialized agents handle strategy and execution
- Data Persistence: PostgreSQL with SQLAlchemy stores all negotiation data
AI Agent System
The core innovation lies in our two-agent architecture:
GradientAgent: Provides strategic negotiation intelligence using Gradient AI's OpenAI-compatible API. This agent analyzes conversation history and market conditions to determine optimal actions.
RepoAgent: Executes the strategic decisions by interacting with the marketplace API. It handles the tactical implementation of offers, counter-offers, and acceptances.
Real-Time Communication
We implemented Server-Sent Events (SSE) for streaming negotiation updates to the frontend, providing users with live visibility into agent conversations. The system maintains active connections per negotiation session and broadcasts updates as they occur.
What We Learned
Mathematical Modeling of Negotiations
We discovered that successful negotiations follow predictable patterns. The optimal offer strategy can be modeled as:
$$\text{Offer}_{t+1} = \text{Offer}_t \times (1 - \alpha \times e^{-\beta t})$$
where $\alpha$ is the maximum discount rate and $\beta$ controls the convergence speed. Different seller personalities required different parameter tuning.
Real-Time State Management
Coordinating state across multiple concurrent negotiations taught us the importance of immutable event sourcing. Each negotiation action is logged as a Message record, creating an audit trail that allows reconstruction of any negotiation state.
Challenges Faced
Concurrent Negotiation Orchestration
Managing up to 5 parallel negotiations across multiple sellers proved complex. We implemented a sophisticated loop that tracks conversation states and determines when negotiations are conclusive. The system must detect mutual acceptance, rejections, or timeout conditions across all conversations.
Real-Time Update Reliability
Server-Sent Events provided challenges with connection management and message deduplication. We built a robust system that tracks active connections and falls back to polling when SSE fails.
Performance Optimization
The initial implementation made sequential API calls, resulting in slow negotiations. We refactored to use asyncio.gather() for parallel action execution, dramatically improving performance.
Impact
ShadowBid demonstrates how AI can transform e-commerce by automating complex decision-making processes. The system successfully negotiates average savings of 15-20% compared to initial listing prices, with the Negotiation Strength Index providing real-time confidence metrics. This project opens possibilities for AI-driven commerce tools that empower consumers in marketplace transactions.
Built With
- fastapi
- fastapi-staticfiles
- framer-motion
- google-fonts
- google-gemini
- gradient-ai
- groq
- httpx
- jinja
- next.js-14
- python
- react
- rest-api
- server-sent-events
- sqlalchemy
- sqlite
- tailwind-css
- typescript

Log in or sign up for Devpost to join the conversation.