An AI-powered documentation agent that helps users interact with their product documentation through natural language chat. Built with advanced RAG (Retrieval-Augmented Generation) using Claude AI and vector search.
Want to run this locally in 5 minutes? β Just run:
make setupThis will install dependencies, start all services, and initialize the database!
- Deploy to Render
- Features
- Repository Structure
- Quick Start with Docker
- Docker Commands
- Environment Variables
- API Endpoints
- Testing
- Troubleshooting
- Contributing
- License
This project is pre-configured for one-click deployment to Render using the included render.yaml blueprint.
What you get:
- β Automatic database migrations on deployment
- β Automatic vector index creation
- β PostgreSQL with pgvector extension
- β Auto-scaling and health checks
- β Separate backend and frontend services
- β Environment variable management
Deployment steps:
-
Fork this repository to your GitHub account
-
Create a new Blueprint Instance on Render:
- Go to Render Dashboard
- Click "New" β "Blueprint Instance"
- Connect your forked repository
- Select branch (usually
main)
-
Configure environment variables:
- Render will auto-detect
render.yaml - You'll be prompted to enter:
ANTHROPIC_API_KEY(Get one here)OPENAI_API_KEY(Get one here)
- All other variables are pre-configured
- Render will auto-detect
-
Deploy:
- Click "Apply" to create all services
- Render will:
- Create PostgreSQL database with pgvector
- Build and deploy backend with automatic migrations
- Automatically create vector indexes
- Build and deploy frontend
- Link services together
-
Access your deployed app:
- Frontend:
https://your-app-name-frontend.onrender.com - Backend API:
https://your-app-name-backend.onrender.com
- Frontend:
Cost Estimate (Render Free Tier):
- 2 Web Services (frontend + backend): Free
- 1 PostgreSQL Database: Free (with limitations)
- OpenAI/Anthropic API: Pay-as-you-go (minimal for embeddings)
- Total: ~$0/month recurring (with free tier limitations)
- π€ RAG-Powered Responses - Semantic search over documentation using vector embeddings
- π¬ Conversation History - Persistent multi-turn conversations with context awareness
- π Source Citations - Shows which documents informed each response
- π― Real-time Confidence Scores - Visual indication of answer quality
- π Document Upload - Upload Markdown files & OpenAPI specifications
- β‘ Lightning-Fast Search - HNSW indexing for 10-100x performance boost
- π¨ Beautiful Dark Mode UI - Inspired by Render.com's design system
- π± Mobile Responsive - Full functionality on all screen sizes
- βΏ Accessibility Features - ARIA labels, keyboard navigation, screen reader support
- π Easy Deployment - One-click Render.com deployment
.
βββ backend/ # Express + TypeScript API
β βββ src/
β β βββ services/ # RAG, embedding, Claude AI services
β β βββ routes/ # API endpoints (chat, documents, admin)
β β βββ controllers/ # Request handlers
β β βββ middleware/ # Rate limiting, validation, error handling
β β βββ utils/ # Markdown/OpenAPI parsers, context builder
β β βββ scripts/ # Database initialization scripts
β βββ prisma/
β β βββ schema.prisma # Database schema with pgvector
β β βββ migrations/ # Database migrations
β βββ Dockerfile # Production container with auto-migrations
β βββ API.md # Complete API documentation
βββ frontend/ # Next.js 14 + React app
β βββ src/
β β βββ components/ # Chat UI, document management
β β β βββ chat/ # Chat interface components
β β β βββ layout/ # Header, sidebar
β β β βββ ui/ # shadcn/ui components
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # API client, utilities
β βββ Dockerfile # Nginx-served production build
β βββ nginx.conf # Nginx configuration
βββ test-docs/ # Sample documentation files
βββ docker-compose.yml # Full-stack local development
βββ render.yaml # Production deployment configuration
βββ Makefile # Development shortcuts
βββ README.md # This file
- Docker and Docker Compose installed
- Anthropic API key
- OpenAI API key
# Clone the repo
git clone <your-repo-url>
cd render-docs-agent
# Create environment file from template
cp env.example .env
# Edit .env and add your API keys:
# ANTHROPIC_API_KEY=sk-ant-your-actual-key
# OPENAI_API_KEY=sk-your-actual-key
# IMPORTANT: Keep POSTGRES_DB=docs_agent (with underscore!)
# Run complete setup (install, start, migrate, initialize)
make setupThis will:
- β Install all dependencies
- β Start all services (database, backend, frontend)
- β Run database migrations automatically
- β Create vector indexes for fast search
# 1. Clone and navigate
git clone <your-repo-url>
cd render-docs-agent
# 2. Create environment file from template
cp env.example .env
# 3. Edit .env and add your API keys
# Required:
# ANTHROPIC_API_KEY=sk-ant-your-actual-key
# OPENAI_API_KEY=sk-your-actual-key
# IMPORTANT: Ensure POSTGRES_DB=docs_agent (with underscore)
# 4. Start all services
docker-compose up -d
# 5. Wait for initialization (30-60 seconds)
# Migrations and indexes are created automatically- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Database: localhost:5432
- Open http://localhost:3000
- Drag and drop a Markdown file or OpenAPI spec
- Wait for processing (~10-30 seconds)
- Start chatting!
Try the test documents:
# Upload via UI or via API
curl -X POST http://localhost:3001/api/documents/upload \
-F "file=@test-docs/example-api.md"Start all services:
docker-compose up -dStop all services:
docker-compose downView logs:
# All services
docker-compose logs -f
# Specific service
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f databaseRebuild after code changes:
docker-compose up -d --buildClean restart (removes all data):
docker-compose down -v
docker-compose up -d --buildUseful make commands:
make help # Show all available commands
make up # Start services
make down # Stop services
make logs # View all logs
make logs-backend # Backend logs only
make restart # Restart all services
make db-migrate # Run database migrations
make db-studio # Open Prisma Studio
make clean # Clean everything| Variable | Description | Required | Default |
|---|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes | - |
ANTHROPIC_API_KEY |
Anthropic API key for Claude | Yes | - |
OPENAI_API_KEY |
OpenAI API key for embeddings | Yes | - |
FRONTEND_URL |
Frontend URL for CORS | Yes | - |
PORT |
Server port | No | 3001 |
NODE_ENV |
Environment | No | development |
CLAUDE_MODEL |
Claude model to use | No | claude-3-5-sonnet-20241022 |
EMBEDDING_MODEL |
Embedding model | No | text-embedding-3-small |
CLAUDE_MAX_TOKENS |
Max tokens for responses | No | 4096 |
CLAUDE_TEMPERATURE |
Response creativity (0-1) | No | 0.3 |
| Variable | Description | Required | Default |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API URL | Yes | - |
NEXT_PUBLIC_APP_NAME |
Application name | No | Docs Agent |
All variables are documented in env.example. Just copy it and add your API keys!
POST /api/documents/upload- Upload documentationGET /api/documents- List all documentsGET /api/documents/:id- Get specific documentDELETE /api/documents/:id- Delete documentGET /api/documents/stats- Document statistics
POST /api/chat- Send message and get AI responseGET /api/chat/history/:sessionId- Get chat history
POST /api/admin/index/create- Create vector indexGET /api/admin/stats/search- Search statisticsPOST /api/admin/cache/clear- Clear RAG cacheGET /api/admin/sessions- List active sessionsDELETE /api/admin/sessions/:id- Clear session
GET /health- Basic health checkGET /health/detailed- Comprehensive status with database infoGET /health/ready- Readiness probe (for Kubernetes)GET /health/live- Liveness probe (for Kubernetes)
Complete API documentation: See backend/API.md
# 1. Upload a document
curl -X POST http://localhost:3001/api/documents/upload \
-F "file=@test-docs/example-api.md"
# 2. Test chat
curl -X POST http://localhost:3001/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "How do I authenticate?"}'
# 3. Check performance stats
curl http://localhost:3001/api/admin/stats/search
# 4. Create vector index for faster search
curl -X POST http://localhost:3001/api/admin/index/create-
Upload Test:
- Open http://localhost:3000
- Drag
test-docs/example-api.mdinto sidebar - Verify document appears in list
-
Chat Test:
- Click a suggested question OR
- Type "How do I authenticate?"
- Verify response with source citations
- Check confidence score
-
Features Test:
- Copy code blocks
- Clear conversation
- Test on mobile (resize browser)
- Try keyboard navigation (Tab, Enter, Escape)
cd backend
npm testError: database "docsagent" does not exist
This means your .env file has the wrong database name. Fix it:
# In .env, change this:
POSTGRES_DB=docsagent # β Wrong (no underscore)
# To this:
POSTGRES_DB=docs_agent # β
Correct (with underscore)
# Then recreate the database:
docker-compose down -v
docker-compose up -dOther database issues:
# Check database is running
docker-compose ps
# View database logs
docker-compose logs database
# Restart database
docker-compose restart database# Verify keys are set
cat .env | grep API_KEY
# Restart backend to pick up changes
docker-compose restart backend# Create vector index (10-100x faster searches)
curl -X POST http://localhost:3001/api/admin/index/create
# Check index was created
curl http://localhost:3001/api/admin/stats/searchIf ports 3000, 3001, or 5432 are already in use:
- Stop the conflicting service, OR
- Edit
docker-compose.ymlto use different ports:
ports:
- "3002:3001" # Backend on 3002
- "3001:3000" # Frontend on 3001
- "5433:5432" # Database on 5433# Full clean rebuild
docker-compose down -v
docker system prune -a
docker-compose up -d --build
# Check service status
docker-compose ps
# Check specific service logs
docker-compose logs -f backendCheck CORS configuration:
# Verify FRONTEND_URL matches
cat .env | grep FRONTEND_URL
# Verify NEXT_PUBLIC_API_URL is correct
cat .env | grep NEXT_PUBLIC_API_URL
# Restart both services
docker-compose restart backend frontendGetting more help:
- Check service logs:
docker-compose logs <service-name> - Verify environment variables are set correctly
- Ensure all containers are healthy:
docker-compose ps - Check the
backend/API.mdfor endpoint details
The agent uses advanced RAG to provide accurate answers:
- Query Processing - User question converted to vector embedding
- Semantic Search - Find relevant documentation chunks using cosine similarity
- Context Building - Assemble context with intelligent token management
- AI Generation - Claude generates answer with source citations
- Response - User gets accurate answer with confidence score
Performance:
- Vector search: ~20-50ms with HNSW indexing
- Cached queries: <5ms
- End-to-end: ~1-2 seconds (including Claude API)
- HNSW Indexing - 10-100x faster than naive search
- Cosine Similarity - Measures semantic relevance
- Dynamic Thresholds - Auto-adjusts for better results
- Reranking - Combines semantic + keyword + position scoring
- Caching - 5-minute TTL for repeated queries
- Token Counting - Prevents context overflow
- Smart Truncation - Includes most relevant chunks first
- Source Attribution - Every chunk tagged with source document
- History Integration - Balances documentation context vs conversation history
Edit frontend/src/app/globals.css:
.dark {
--primary: 262 83% 58%; /* Purple */
--accent: 180 100% 50%; /* Cyan */
}Edit backend code or environment variables:
// Backend configuration
defaultTopK: 10 // Number of chunks to retrieve
defaultThreshold: 0.5 // Similarity threshold (0-1)
cacheTTL: 5 * 60 * 1000 // Cache duration (5 minutes)
// Claude configuration
temperature: 0.3 // Response creativity (0-1)
maxTokens: 4096 // Max response length-
Create vector index - 10-100x faster searches
curl -X POST http://localhost:3001/api/admin/index/create
-
Upload quality docs - Better structure = better answers
-
Use specific questions - More specific = more accurate
-
Monitor confidence - Low scores may indicate missing documentation
curl http://localhost:3001/api/admin/stats/searchReturns:
- Total chunks in database
- Chunks with embeddings
- Index coverage percentage
- Cache size
Every chat response includes:
{
"confidence": 85.4,
"metadata": {
"documentCount": 2,
"chunkCount": 7,
"processingTime": 1243,
"usage": {
"inputTokens": 3421,
"outputTokens": 542
}
}
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Test locally with Docker Compose
- Commit changes:
git commit -am 'Add my feature' - Push to branch:
git push origin feature/my-feature - Submit a Pull Request
MIT
- Issues: Open a GitHub issue for bugs or questions
- Render Support: support@render.com
Built with β€οΈ for Render.com
Get started in 5 minutes with make setup!