Complete guide for setting up the AiSearch development environment.
- Node.js 18+ (LTS recommended)
- pnpm 8+ (package manager)
- Docker & Docker Compose (for containerized development)
- Git (version control)
node --version # Should be 18+
pnpm --version # Should be 8+
docker --version # Should be recent version
docker compose versionThe fastest way to get started:
# Clone and enter the repository
git clone https://github.com/mrkeshav-05/AiSearch.git
cd AiSearch
# Start development environment (auto-installs dependencies)
./scripts/start.shThis will:
- ✅ Check all prerequisites
- ✅ Install dependencies
- ✅ Set up environment files
- ✅ Start all services (Frontend, Backend, SearXNG)
- ✅ Open development URLs
If you prefer manual control:
git clone https://github.com/mrkeshav-05/AiSearch.git
cd AiSearch# Install all workspace dependencies
pnpm install
# Build shared package (required first)
pnpm run build:sharedcp backend/.env.example backend/.envConfigure your API keys:
# AI API Keys (at least one required)
GOOGLE_API_KEY=your_gemini_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
# External Services
SEARXNG_API_URL=http://localhost:4000
# Server Configuration
PORT=8000
NODE_ENV=development
# CORS Configuration
CORS_ORIGIN=http://localhost:3000cp frontend/.env.example frontend/.env.localConfigure frontend settings:
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000
# Application URLs
NEXT_PUBLIC_APP_URL=http://localhost:3000./scripts/start.sh- Hot reload enabled
- Debug logging
- Development builds
- Port 3000 (Frontend), 8000 (Backend), 4000 (SearXNG)
./scripts/start.sh --prod- Optimized builds
- Production logging
- Performance optimizations
./scripts/start.sh --docker- Full containerization
- Production-like environment
- Isolated services
./scripts/stop.sh- Graceful shutdown
- Port cleanup
- Process termination
pnpm run devBackend Only:
pnpm run dev:backend
# Available at: http://localhost:8000Frontend Only:
pnpm run dev:frontend
# Available at: http://localhost:3000SearXNG (Search Engine):
docker run -d \
--name searxng \
-p 4000:8080 \
searxng/searxng:latest
# Available at: http://localhost:4000AiSearch/
├── backend/ # Node.js/Express API Server
│ ├── src/
│ │ ├── api/v1/ # RESTful API endpoints
│ │ ├── services/ # Business logic layer
│ │ │ ├── ai/ # AI agents and models
│ │ │ ├── external/ # External integrations
│ │ │ └── websocket/ # WebSocket handlers
│ │ ├── config/ # Configuration management
│ │ ├── types/ # Backend TypeScript types
│ │ └── utils/ # Utility functions
│ └── tests/ # Backend test suites
├── frontend/ # Next.js React Application
│ ├── src/
│ │ ├── app/ # Next.js 13+ App Router
│ │ ├── components/ # React components
│ │ │ ├── chat/ # Chat interface
│ │ │ ├── search/ # Search components
│ │ │ └── ui/ # UI components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/ # Frontend utilities
│ │ └── types/ # Frontend TypeScript types
│ └── tests/ # Frontend test suites
├── shared/ # Shared Code
│ └── src/
│ ├── types/ # Common TypeScript types
│ └── constants/ # Application constants
├── scripts/ # Automation Scripts
│ ├── build.sh # Build automation
│ ├── start.sh # Multi-mode startup
│ └── stop.sh # Clean shutdown
├── infrastructure/ # Docker & Deployment
│ └── docker/ # Dockerfiles
└── docs/ # Documentation
- Edit files in
backend/,frontend/, orshared/ - TypeScript compilation happens automatically
- Hot reload updates browser instantly
# Run all tests
pnpm test
# Backend tests only
pnpm run test:backend
# Frontend tests only
pnpm run test:frontend
# Test with coverage
pnpm run test:coverage# Build everything
./scripts/build.sh
# Or build individually
pnpm run build:shared # Must be first
pnpm run build:backend
pnpm run build:frontendWorkspace Root:
pnpm add <package> -wSpecific Package:
pnpm add <package> --filter backend
pnpm add <package> --filter frontend
pnpm add <package> --filter sharedDevelopment Dependencies:
pnpm add -D <package> --filter <workspace># Install all dependencies
pnpm install
# Clean all node_modules
pnpm clean
# Lint all packages
pnpm lint
# Format all code
pnpm formatPort Already in Use:
./scripts/stop.sh # Clean shutdown
./scripts/start.sh # RestartDependencies Out of Sync:
pnpm clean
pnpm install
pnpm run build:sharedDocker Issues:
docker system prune -f
./scripts/start.sh --dockerTypeScript Errors:
# Rebuild shared package
pnpm run build:shared
# Clear TypeScript cache
rm -rf backend/dist frontend/.next- Always build shared package first when making changes to shared types
- Use the automation scripts for consistent environment setup
- Check logs in individual terminals for debugging
- Use Docker mode to test production-like behavior
- Run tests before committing changes
Install these extensions:
- TypeScript and JavaScript Language Features
- ESLint
- Prettier
- Tailwind CSS IntelliSense
- Docker
Add to .vscode/settings.json:
{
"typescript.preferences.importModuleSpecifier": "relative",
"eslint.workingDirectories": ["backend", "frontend"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}- Architecture Guide - Deep dive into system design
- API Documentation - Backend API reference
- Docker Guide - Container deployment
- Contributing Guide - How to contribute