AI-powered system that enables users to query databases using natural language instead of writing SQL queries.
demovideo.mov
- Node.js 18+ and pnpm 8+
- PostgreSQL database
- OpenRouter API key
- Clone the repository:
git clone https://github.com/Nishal77/AskDB.git
cd Askyourdatabase- Install dependencies:
pnpm install- Setup environment variables:
pnpm setup:env- Configure environment variables:
Edit the
.envfile in the root directory and set the following required values:
OPENROUTER_API_KEY- Your OpenRouter API keyDATABASE_URL- PostgreSQL connection stringJWT_SECRET- Generate a secret key using:openssl rand -base64 32
- Setup database:
pnpm db:setupStart both API and web services:
pnpm devStart services individually:
pnpm dev:api # API only
pnpm dev:web # Web onlyStart all services with Docker:
pnpm docker:devStop Docker services:
pnpm docker:dev:down# Generate Prisma Client and run migrations
pnpm db:setuppnpm prisma:generate# Deploy migrations (production)
pnpm migrate
# Create new migration (development)
pnpm migrate:dev
# Check migration status
pnpm migrate:statuscd packages/prisma
pnpm prisma studiohttp://localhost:3000/api/v1
POST /api/v1/auth/register- Register a new userPOST /api/v1/auth/login- Login and get JWT tokenGET /api/v1/auth/me- Get current user profile (requires authentication)POST /api/v1/auth/openrouter-key- Update OpenRouter API key (requires authentication)DELETE /api/v1/auth/openrouter-key- Remove OpenRouter API key (requires authentication)
POST /api/v1/query/execute- Execute natural language query (requires authentication)GET /api/v1/query/history- Get query history (requires authentication)GET /api/v1/query/history/:id- Get specific query by ID (requires authentication)
GET /api/v1/schema/connection/:connectionId- Get database schema (requires authentication)GET /api/v1/schema/connection/:connectionId/embed- Get schema for embedding (requires authentication)GET /api/v1/schema/connection/:connectionId/tables- Get tables with row counts (requires authentication)
GET /api/v1/admin/connections- Get all database connections (requires authentication)
GET /health- Health check endpoint (no authentication required)GET /api/v1/health- Health check with API prefix (no authentication required)
Most endpoints require JWT authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
- API Server: http://localhost:3000/api/v1
- Web Application: http://localhost:3001
- Health Check: http://localhost:3000/health
Private