This is a minimal Chatbot Platform built as a technical task, demonstrating user authentication, project management, and integration with Large Language Models (LLMs) and file uploads.
- User Registration and Login (JWT authenticated)
- Create, read, and delete projects/agents.
- Store and manage prompts for each project.
- Chat interface to interact with agents via the OpenRouter API.
- Upload files to a project, which are stored securely in OpenAI's infrastructure.
This project is built with a modern, decoupled architecture featuring a React/TypeScript frontend (using Vite and React Bootstrap) and a Node.js/Express backend. Data is managed by a PostgreSQL database (via Supabase) through the Prisma ORM. File uploads are handled by the OpenAI Files API, while chat functionality is powered by LLMs accessed through the OpenRouter API.
Follow these steps to get the application running on your local machine.
- Node.js (LTS version recommended)
- npm (comes with Node.js)
- A Supabase account (for the database)
- An OpenRouter.ai account (for the LLM API key)
- An OpenAI account (for the File Upload API key)
-
Navigate to the
serverdirectory:cd chatbot-platform/server -
Install backend dependencies:
npm install
-
Create a
.envfile by copying the example:cp .env.example .env
-
Fill in the
.envfile with your credentials:DATABASE_URL: Your Supabase database connection string.JWT_SECRET: A strong, random secret key.OPENROUTER_API_KEY: Your key from OpenRouter.ai.OPENAI_API_KEY: Your key from OpenAI.CLIENT_URL_PROD: Leave blank for now.CLIENT_URL_LOCAL: Should behttp://localhost:5173.
-
Apply Database Schema:
npx prisma migrate dev --name init
-
Run the Backend Server:
npm run dev
The server will run on
http://localhost:3000.
-
In a new terminal, navigate to the
clientdirectory:cd chatbot-platform/client -
Install frontend dependencies:
npm install
-
Create a local environment file:
cp .env.example .env.local
The file will be pre-filled with
VITE_API_BASE_URL=http://localhost:3000, which is correct for local development. -
Run the Frontend Server:
npm run dev
The application will be available at
http://localhost:5173.
The following API endpoints are available:
POST /api/auth/register: User RegistrationPOST /api/auth/login: User LoginGET /api/projects: Get all projects for the logged-in user.POST /api/projects: Create a new project.DELETE /api/projects/:id: Delete a project.PUT /api/projects/:id: Update a project (used for prompts).POST /api/llm/:projectId/chat: Send a message to a project's agent.POST /api/llm/:projectId/files: Upload a file to a project.
This application is designed to be deployed with a decoupled frontend and backend.
- Push your code to a GitHub repository.
- Create a new "Web Service" on Render and connect it to your repository.
- Settings:
- Build Command:
npm install && npm run build - Start Command:
npm start
- Build Command:
- Environment Variables: Add all the variables from your
.envfile to the Render environment settings. ForCLIENT_URL_PROD, use the URL of your Vercel deployment (from the next step).
-
Create a new "Project" on Vercel and connect it to the same GitHub repository.
-
Build & Development Settings: Vercel will likely detect that you are using Vite and configure this automatically. The output directory should be
dist. -
Environment Variables: Add one variable:
VITE_API_BASE_URL: Set this to the public URL of your backend on Render (e.g.,https://your-backend.onrender.com).
-
Deploy. Vercel will automatically build and deploy your frontend.