A Next.js application for interacting with databases using natural language. Built with AI capabilities to help users query and visualize data.
Chat with your database using natural language queries powered by AI.
Create and customize dashboards with various chart types to visualize your data.
Explore your database schema and write SQL queries with visual query results.
- Runtime: Bun / Node.js
- Framework: Next.js 15
- Language: TypeScript
- Styling: Tailwind CSS, Shadcn/ui
- Database ORM: Prisma
- AI: Google Generative AI
The easiest way to start the project is using the startup script:
./start.shThis script will:
- Start the System Database (PostgreSQL on port 5433) - stores user data and application data
- Start the Northwind Database (PostgreSQL on port 5434) - sample database for querying
- Initialize and seed the system database if needed
- Start the Next.js development server
Requirements:
- Docker (must be running)
- One of: bun, pnpm, or npm
After startup, you can login with:
- Email: admin@example.com
- Password: 123456
The Northwind sample database will be automatically added as an external database connection.ssss
# Create the db/system-database directory if it doesn't exist
mkdir -p db/system-database
# Create Dockerfile for system-db
cat > db/system-database/Dockerfile << 'EOF'
FROM postgres:15-alpine
ENV POSTGRES_DB=chat_database_agent
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=postgres
EXPOSE 5432
EOF
# Build and run
docker build -t system-db-image -f db/system-database/Dockerfile db/system-database
docker run -d --name system-db -p 5433:5432 system-db-image# Build and run
docker build -t northwind-db-image -f db/northwind-database/Dockerfile db/northwind-database
docker run -d --name northwind-db -p 5434:5432 northwind-db-imageCopy the example environment file and update it:
cp .env.example .envUpdate .env with your settings:
# Google Generative AI API Key
GOOGLE_GENERATIVE_AI_API_KEY=your-api-key-here
# System Database (for user data and application data)
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/chat_database_agent?schema=public"# Install dependencies
bun install
# Run migrations
bun run prisma migrate deploy
# Seed the database
bun run prisma db seedbun run devOpen http://localhost:3000 in your browser.
| Database | Host | Port | Database | Username | Password |
|---|---|---|---|---|---|
| System DB | localhost | 5433 | chat_database_agent | postgres | postgres |
| Northwind | localhost | 5434 | northwind | postgres | postgres |
docker stop system-db northwind-dbdocker rm system-db northwind-dbdocker logs system-db
docker logs northwind-db# Stop and remove containers
docker stop system-db northwind-db
docker rm system-db northwind-db
# Remove images (optional, for full rebuild)
docker rmi system-db-image northwind-db-image
# Restart with start.sh
./start.sh├── agent/ # AI agent configuration
├── api-clients/ # API client functions
├── app/ # Next.js app directory
│ ├── (main)/ # Main application routes
│ └── api/ # API routes
├── components/ # React components
│ ├── ai-elements/ # AI-related components
│ ├── chart/ # Chart components
│ ├── chat/ # Chat components
│ └── ui/ # Shadcn/ui components
├── db/ # Database configurations
│ ├── northwind-database/ # Northwind sample database
│ └── system-database/ # System database configuration
├── lib/ # Utility functions
├── prisma/ # Prisma schema and migrations
└── tools/ # AI tools


