A full-stack AI agent application with a React frontend and Node.js backend services. The project includes an intelligent agent with various tools (currency conversion, weather, news) and a separate code execution service.
AIAgent/
├── client/ # React frontend application
│ ├── src/
│ ├── public/
│ ├── package.json
│ └── vite.config.ts
└── server/
├── agent/ # AI agent service with tools
│ ├── agent.js
│ ├── demo/ # Demo scripts
│ ├── tools/ # Agent tools (currency, weather, news)
│ └── package.json
└── executor/ # Code execution service
├── index.js
└── package.json
- Node.js (v16 or higher)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd AIAgent
-
Install dependencies for all services
Client (React app):
cd client npm installAgent service:
cd server/agent npm installExecutor service:
cd server/executor npm install -
Environment Setup
Create a
.envfile in theserver/agentdirectory with your required environment variables:cd server/agent touch .envAdd your API keys and configuration variables to the
.envfile.
cd server/executor
node index.js✅ Server will be running on port 3000
cd server/agent
node --env-file=.env index.js✅ Server will be running on port 3001
cd client
npm run dev✅ Frontend will be available at the URL shown in terminal (typically http://localhost:5173)
You can test the AI agent service using curl:
curl -X POST http://localhost:3001/generate \
-H "Content-Type: application/json" \
-d '{"prompt":"convert 5 USD to PKR","thread_id":123}'Currency Conversion:
curl -X POST http://localhost:3001/generate \
-H "Content-Type: application/json" \
-d '{"prompt":"convert 100 EUR to USD","thread_id":456}'Weather Information:
curl -X POST http://localhost:3001/generate \
-H "Content-Type: application/json" \
-d '{"prompt":"What is the weather like in New York?","thread_id":789}'The AI agent comes with several built-in tools:
- 🔄 Currency Tool (
currencyTool.js) - Real-time currency conversion - 🌤️ Weather Tool (
weatherTool.js) - Weather information and forecasts - 📰 News Tool (
newsTool.js) - Latest news and updates - ⚡ JavaScript Executor (
jsExecutor.js) - Execute JavaScript code safely
server/agent/agent.js- Main AI agent logic and tool integrationserver/agent/index.js- Agent service server and API endpointsserver/executor/index.js- Code execution serviceclient/src/App.tsx- Main React application component
The project includes demo scripts in server/agent/demo/:
basicLLM.js- Basic language model interactionaddingTools.js- Tool integration examplesaddingMemory.js- Memory management examples
Run demos:
cd server/agent
node demo/basicLLM.jsAgent Service (Port 3001):
POST /generate- Generate AI responses with tool usage
Executor Service (Port 3000):
- Available for code execution requests
- Port conflicts: Make sure ports 3000, 3001, and 5173 are available
- Environment variables: Ensure all required API keys are set in
.env - Dependencies: Run
npm installin each service directory if modules are missing - CORS issues: Check that the frontend URL is allowed in backend CORS settings
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding! 🎉