This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
pnpm devOpen http://localhost:3000 with your browser to see the result.
This repository also includes a scaffold for:
- Next.js web app with Vercel AI SDK (
ai) +@ai-sdk/google - Python LangGraph negotiation service
- Shared TypeScript contracts package
apps/web: Next.js App Router project with AI SDK endpointsservices/negotiation-langgraph: FastAPI + LangGraph negotiation backendpackages/contracts: shared zod schemas/types
Copy .env.example to .env.local and set values:
NEXT_PUBLIC_SUPABASE_URL/NEXT_PUBLIC_SUPABASE_ANON_KEY/SUPABASE_SERVICE_ROLE_KEYGEMINI_API_KEYNEXT_PUBLIC_CLERK_PUBLISHABLE_KEY/CLERK_SECRET_KEYELEVENLABS_API_KEY(optional)GOOGLE_GENERATIVE_AI_API_KEYNEGOTIATION_SERVICE_URLPAGEINDEX_API_KEY— PageIndex API key (Bearer token)PAGEINDEX_API_BASE_URL— REST host, defaulthttps://api.pageindex.ai(listing document upload)PAGEINDEX_UPLOAD_PATH— upload path (default/documents/upload)PAGEINDEX_MCP_URL— HTTP MCP endpoint for document search/read tools, defaulthttps://api.pageindex.ai/mcpWEB_EVIDENCE_MCP_URLA2A_AGENT_BASE_URL
The backend is split into buyer, seller, and gateway processes. The web app talks to the gateway on port 8000 (NEGOTIATION_SERVICE_URL).
From the repository root, build and run the Next.js app together with buyer, seller, and gateway:
cp .env.example .env
# Set at least GOOGLE_GENERATIVE_AI_API_KEY (chat). Optional: PAGEINDEX_*, SUPABASE_*.
docker compose up --build- Web UI: http://localhost:3000
- Gateway (REST): http://localhost:8000 — the
webcontainer usesNEGOTIATION_SERVICE_URL=http://negotiation-gateway:8000on the Docker network (you do not set this manually for Compose).
Details: docker/README.md. To expose the FastAPI negotiation gateway on the internet (CORS, HTTPS, PUBLIC_GATEWAY_URL), see "Expose the FastAPI gateway on the internet" in that file.
Docker Compose (negotiation services only, no web):
cd services/negotiation-langgraph
docker compose up --buildOr run three local shells (see services/negotiation-langgraph/README.md) and start uvicorn app.main:app on port 8000 for the gateway.
Web (Next.js):
POST /api/chatPOST /api/negotiations/startPOST /api/listings/{listingId}/documents(multipart withfiles)
Negotiation service:
GET /healthPOST /negotiations/startPOST /negotiations/{thread_id}/step
Official API host: https://api.pageindex.ai. The negotiation service and web upload both authenticate with PAGEINDEX_API_KEY as Authorization: Bearer <key>.
Cursor MCP (same tools as the negotiation service):
{
"mcpServers": {
"pageindex": {
"type": "http",
"url": "https://api.pageindex.ai/mcp",
"headers": {
"Authorization": "Bearer your_api_key"
}
}
}
}- Seller uploads listing documents through
POST /api/listings/{listingId}/documents. - The web route uploads files to PageIndex ingestion API with
folder_id = listingId. - During negotiation steps, the service queries PageIndex MCP tools within that same folder.
The Next.js API routes persist negotiation events to Supabase table thread_events.
create table if not exists public.thread_events (
id bigint generated always as identity primary key,
thread_id text not null,
event_type text not null,
source text not null,
request_id text,
payload jsonb not null,
created_at timestamptz not null default now()
);