A multi-tenant chatbot API powered by Gemini AI and OpenRouter, with built-in analytics and usage tracking.
- 🤖 Advanced AI chat capabilities using Gemini AI (with OpenRouter fallback)
- 👥 Multi-tenant architecture for managing multiple clients
- 📊 Built-in analytics and usage tracking
- 💰 Usage-based billing system
- 🔒 Secure authentication and API key management
- ⚡ Rate limiting and quota management
- Runtime: Node.js
- Framework: Express
- Language: TypeScript
- ORM: Prisma
- Database: PostgreSQL (via Supabase)
- AI Providers:
- Gemini AI (Primary)
- OpenRouter (Fallback)
- Authentication: JWT + API Keys
- Documentation: OpenAPI/Swagger
- Node.js 18+
- PostgreSQL
- npm or yarn
-
Clone the repository:
git clone https://github.com/yourusername/kevinbot-api.git cd kevinbot-api -
Install dependencies:
npm install
-
Copy the environment variables file:
cp .env.example .env
-
Update the environment variables in
.envwith your values:- Database connection
- AI provider API keys
- JWT secret
- Stripe keys
- Other configuration
-
Initialize the database:
npx prisma migrate dev
-
Start the development server:
npm run dev
POST /api/v1/chat/messages- Send a message to the chatbotGET /api/v1/chat/history- Get chat historyDELETE /api/v1/chat/history- Clear chat history
POST /api/v1/tenants- Create a new tenantGET /api/v1/tenants/:id- Get tenant detailsPUT /api/v1/tenants/:id- Update tenantDELETE /api/v1/tenants/:id- Delete tenant
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- Login userPOST /api/v1/auth/api-keys- Generate API keyDELETE /api/v1/auth/api-keys/:id- Revoke API key
GET /api/v1/analytics/metrics- Get usage metricsGET /api/v1/analytics/usage- Get detailed usage statsGET /api/v1/analytics/reports- Get analytics reports
The API supports two authentication methods:
-
JWT Tokens: For dashboard/admin access
Authorization: Bearer <token> -
API Keys: For client applications
X-API-Key: <api_key>
- Rate limits are applied per tenant based on their plan:
- Starter: 1,000 messages/month
- Pro: 10,000 messages/month
- Enterprise: 100,000 messages/month
npm run testnpm run lintnpm run build-
Build the application:
npm run build
-
Set production environment variables
-
Run database migrations:
npx prisma migrate deploy
-
Start the server:
npm start
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email support@kevinbot.com or create an issue in the repository.