A modern, conversational database assistant that allows you to query your databases using natural language. Built with Next.js 15, TypeScript, and powered by Hugging Face AI.
- Connect multiple PostgreSQL and MongoDB databases
- Encrypted credential storage
- Sidebar with all connected databases
- Add, edit, and remove connections
- PostgreSQL: Full schema introspection with table and column information
- MongoDB: Collection and field discovery
- Automatic schema detection and mapping
- React Flow powered flowchart view
- Draggable table/collection cards
- Expandable column/field details
- Zoom and pan functionality
- Dark mode support
- Natural language to SQL/MongoDB query conversion
- Hugging Face Inference API integration
- Real-time query execution
- Chat history persistence
- Error handling and feedback
- Semantic table mapping
- Context-aware query generation
- Schema-aware AI prompts
- Safe query execution
- Frontend: Next.js 15, React 18, TypeScript
- Styling: TailwindCSS, shadcn/ui components
- State Management: Zustand
- AI: Hugging Face Inference API
- Databases: PostgreSQL, MongoDB
- Visualization: React Flow (@xyflow/react)
- Icons: Lucide React
- Node.js 18+
- PostgreSQL or MongoDB instance
- Hugging Face API key
-
Clone the repository
git clone <repository-url> cd database-assistant
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local
Add your Hugging Face API key:
HUGGINGFACE_API_KEY=your_api_key_here
-
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
- Go to the "Connections" tab
- Click "Add Database Connection"
- Fill in your database credentials
- Test the connection
- Select a database from the sidebar
- Go to the "Schema" tab
- Explore your database structure visually
- Select a database from the sidebar
- Go to the "Chat" tab
- Ask questions like:
- "Show me all users from last month"
- "What's the total revenue by country?"
- "Get the top 10 customers by order value"
Generates database queries from natural language using AI.
Request:
{
"message": "Show me all users from last month",
"schema": {
/* database schema */
},
"mapping": {
/* table mappings */
},
"databaseType": "postgresql"
}
Response:
{
"success": true,
"query": "SELECT * FROM users WHERE created_at >= '2024-01-01' LIMIT 100"
}
Executes generated queries on the connected database.
Request:
{
"connection": {
/* database connection */
},
"query": "SELECT * FROM users LIMIT 10"
}
Response:
{
"success": true,
"result": [
/* query results */
]
}
src/
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main page
├── components/ # React components
│ ├── Chat.tsx # Chat interface
│ ├── DatabaseConnections.tsx
│ ├── SchemaVisualizer.tsx
│ └── Sidebar.tsx
├── lib/ # Utilities
│ ├── database.ts # Database operations
│ └── utils.ts # Helper functions
├── store/ # State management
│ └── useStore.ts # Zustand store
└── types/ # TypeScript types
└── index.ts
Variable | Description | Required |
---|---|---|
HUGGINGFACE_API_KEY |
Hugging Face API key for AI inference | Yes |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
For support, please open an issue on GitHub or contact the development team.