# Clone the project
git clone <your-repo>
cd debat-ia-agents
# Install dependencies
npm install
npm run install:all
# Configure
cd backend
cp .env.example .env
# Add your API keys to .env
# Run in dev mode
cd ..
npm run devbackend/src/
├── server.ts # Express entry point
├── agents/ # Agent logic
│ ├── router.ts # Request triage
│ ├── moderator.ts # Debate preparation
│ ├── advocate.ts # Argumentation
│ └── judge.ts # Final synthesis
├── graph/ # LangGraph
│ ├── state.ts # State types
│ └── workflow.ts # Orchestration
├── tools/ # External tools
│ └── webSearch.ts # Tavily API
└── config/ # Configuration
└── prompts.ts # System prompts
frontend/src/
├── App.tsx # Main component
├── components/
│ ├── DebateForm.tsx # Form
│ └── DebateResult.tsx # Display
└── types.ts # Shared types
- Create the file in
backend/src/agents/ - Define the prompt in
backend/src/config/prompts.ts - Add the node in
backend/src/graph/workflow.ts - Update
DebateStateinbackend/src/graph/state.ts
Example:
// backend/src/agents/new-agent.ts
import { ChatAnthropic } from "@langchain/anthropic";
import { DebateState } from "../graph/state.js";
const model = new ChatAnthropic({
modelName: "claude-3-opus-20240229",
temperature: 0.7,
});
export async function newAgentNode(
state: DebateState
): Promise<Partial<DebateState>> {
// Agent logic
const response = await model.invoke([
{ role: "system", content: "Your system prompt" },
{ role: "user", content: state.userQuery },
]);
return {
// State update
newField: response.content.toString(),
};
}Prompts are centralized in backend/src/config/prompts.ts.
export const PROMPTS = {
router: {
system: `Your new prompt...`,
},
// ...
};- Create the file in
backend/src/tools/ - Use the LangChain tool pattern:
import { tool } from "@langchain/core/tools";
import { z } from "zod";
export const myNewTool = tool(
async ({ param }: { param: string }) => {
// Tool logic
return "result";
},
{
name: "my_new_tool",
description: "Description of the tool",
schema: z.object({
param: z.string().describe("Description of the parameter"),
}),
}
);- Bind the tool to an agent:
const model = new ChatAnthropic({
modelName: "claude-3-opus-20240229",
}).bindTools([myNewTool]);The project uses TailwindCSS. Useful classes:
// Gradients
className="bg-gradient-to-br from-indigo-100 via-purple-50 to-pink-100"
// Cards
className="bg-white rounded-2xl shadow-xl p-8"
// Buttons
className="px-8 py-4 bg-indigo-600 text-white font-semibold rounded-xl hover:bg-indigo-700"
// Agent color codes
className="bg-blue-100 text-blue-800" // Advocate A
className="bg-purple-100 text-purple-800" // Advocate B
className="bg-amber-50 text-gray-900" // Judge# Automatic test script
npm run test
# Or manually
curl -X POST http://localhost:3000/api/debate \
-H "Content-Type: application/json" \
-d '{"query": "React vs Vue.js"}'Create a test file:
// backend/src/tests/test-agent.ts
import { routerNode } from "../agents/router.js";
const testState = {
userQuery: "What is React?",
// ... other fields
};
const result = await routerNode(testState);
console.log(result);Run with:
cd backend
npx tsx src/tests/test-agent.tsEnable debug mode in .env:
DEBUG_MODE=trueLogs will appear in the terminal:
🔀 Agent Router - Analyzing the request...
📋 Agent Moderator - Preparing the debate...
⚖️ Advocate A - Defending React...
Use React DevTools:
- Install the Chrome/Firefox extension
- Inspect components
- Observe state and props
# APIs
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
TAVILY_API_KEY=tvly-...
# Server
PORT=3000
NODE_ENV=development
# Models (customizable)
ROUTER_MODEL=claude-3-haiku-20240307
MODERATOR_MODEL=claude-sonnet-4-20250514
ADVOCATE_MODEL=claude-3-opus-20240229
JUDGE_MODEL=gpt-4o
# System
MAX_ITERATIONS=10
DEBUG_MODE=true# Build backend
cd backend
npm run build
# Build frontend
cd ../frontend
npm run build
# Or both
npm run buildProduction files will be in:
backend/dist/frontend/dist/
- Connect the GitHub repo
- Define environment variables
- Build command:
cd backend && npm install && npm run build - Start command:
cd backend && npm start
- Connect the GitHub repo
- Build command:
cd frontend && npm run build - Output directory:
frontend/dist - Configure the backend URL in environment variables
- Fork the project
- Create a branch:
git checkout -b feature/my-feature - Commit:
git commit -m "feat: add my feature" - Push:
git push origin feature/my-feature - Open a Pull Request
feat:New featurefix:Bug fixdocs:Documentationstyle:Formattingrefactor:Refactoringtest:Testschore:Maintenance
MIT