Skip to content

nithinbhandari7/Think-Twice

Repository files navigation

Think Twice

Think Twice is an AI-powered financial decision-making app that simulates a boardroom of expert agents debating whether you should make a purchase. Instead of a simple yes or no, four specialized AI agents analyze your real financial data, argue their cases over three rounds, vote, and deliver a reasoned verdict.


How It Works

When you submit a purchase (e.g., "AirPods Pro, $249"), four AI agents each examine your finances from a different angle:

Agent Focus
Spending Agent Can you actually afford it right now?
Savings Agent Does this fit your budget and spending patterns?
Investment Agent What's the opportunity cost long-term?
Risk Agent Are there any red flags in your spending behavior?

The agents debate across three rounds, respond to each other's arguments, then cast votes (APPROVE, DENY, or HOLD). A Board Chair AI synthesizes the debate and delivers the final verdict with reasoning.


Features

  • AI Agent Debate — Multi-agent deliberation powered by Claude (Anthropic)
  • Real Financial Data — Connects to Nessie banking API for your actual account balance, transactions, and spending history
  • Streaming Debate — Watch the debate unfold in real time via Server-Sent Events
  • Persistent History — All decisions are stored in MongoDB so you can review past verdicts
  • Follow-up Chat — Ask the Board Chair questions after a verdict
  • Tradeoff Analysis — Compare two purchases head-to-head
  • Custom Budgets — Set per-category spending limits
  • Browser Extension — Quick purchase evaluations from any webpage
  • Voice Assistant — Vapi-powered voice interaction with the Board

Tech Stack

Frontend

  • Next.js 14 (App Router) + TypeScript
  • React 19
  • Tailwind CSS
  • Firebase Authentication

Backend

  • FastAPI (Python)
  • Anthropic Python SDK (claude-sonnet-4-20250514)
  • Motor (async MongoDB driver)
  • Uvicorn

External Services

  • Anthropic Claude API — AI agents
  • MongoDB Atlas — User data and decision history
  • Firebase — Authentication
  • Nessie — Banking API sandbox
  • Vapi — Voice AI

Project Structure

TheBoard/
├── frontend/                  # Next.js application
│   ├── app/
│   │   ├── page.tsx           # Main boardroom page
│   │   ├── login/page.tsx     # Login/signup
│   │   └── api/deliberate/    # Server-side API route
│   ├── components/
│   │   ├── BoardroomUI.tsx    # Core boardroom interface
│   │   ├── AgentDebateArena.tsx
│   │   └── AuthForm.tsx
│   └── lib/
│       ├── firebase.ts        # Firebase config
│       └── auth.ts            # Auth helpers
│
├── main.py                    # FastAPI backend (all endpoints + agent logic)
├── nessie.py                  # Nessie banking API integration
├── users_store.py             # User data persistence layer
├── requirements.txt           # Python dependencies
│
├── extension/                 # Chrome browser extension
│   └── manifest.json
│
├── scripts/
│   └── seed_boardroom_nessie.py   # Seed test banking data
│
└── data/
    └── boardroom_customers.json   # Firebase <-> Nessie ID mappings

Getting Started

Prerequisites

  • Python 3.13+
  • Node.js 18+
  • A MongoDB Atlas cluster
  • API keys for Anthropic, Firebase, and Nessie (see Environment Variables)

1. Clone the repo

git clone https://github.com/your-org/TheBoard.git
cd TheBoard

2. Set up the backend

# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Create your environment file and fill in your keys
cp .env.example .env

3. Set up the frontend

cd frontend
npm install

# Create your frontend environment file and fill in your Firebase keys
cp .env.local.example .env.local

4. Run the application

Open two terminals:

Terminal 1 — Backend

source venv/bin/activate
uvicorn main:app --reload --host 0.0.0.0 --port 8000

Terminal 2 — Frontend

cd frontend
npm run dev

Visit http://localhost:3000, sign in, and submit your first purchase for debate.


Environment Variables

Backend (.env)

ANTHROPIC_API_KEY=sk-ant-...          # Anthropic API key
MONGODB_URI=mongodb+srv://...         # MongoDB Atlas connection string
NESSIE_API_KEY=...                    # Nessie banking API key
NESSIE_BASE_URL=https://api.nessieisreal.com
VAPI_PRIVATE_KEY=...                  # Vapi voice AI key (optional)

Frontend (frontend/.env.local)

NEXT_PUBLIC_FIREBASE_API_KEY=...
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=...
NEXT_PUBLIC_FIREBASE_APP_ID=...
NEXT_PUBLIC_VAPI_PUBLIC_KEY=...       # Vapi public key (optional)

API Reference

Method Endpoint Description
POST /deliberate Stream a purchase debate (SSE)
POST /chat Ask the Board Chair a follow-up question
POST /tradeoff Compare two purchase options
POST /users/bootstrap Create a new user and Nessie account
GET /users/snapshot Get user financial data
PATCH /users/settings Update budget and category settings
POST /purchases/record Record a completed purchase
POST /account/deposit Add funds to user account
GET /health Health check

Example: Starting a Debate

curl -X POST http://localhost:8000/deliberate \
  -H "Content-Type: application/json" \
  -d '{"item": "AirPods Pro", "price": 249, "firebaseUid": "uid_123"}'

The response is a Server-Sent Events stream with the following event types:

  • meta — User's financial snapshot pulled from Nessie/MongoDB
  • message — Individual agent arguments per round
  • verdict — Final Board Chair verdict and vote tally
  • done — Debate complete

Browser Extension

The extension/ folder contains a Chrome extension for evaluating purchases directly from any product page.

To load it in Chrome:

  1. Go to chrome://extensions
  2. Enable Developer mode
  3. Click Load unpacked and select the extension/ folder

Seeding Test Data

To populate your Nessie account with realistic banking data for testing:

source venv/bin/activate
python scripts/seed_boardroom_nessie.py

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes
  4. Open a pull request against main

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors