Link to test the app:
For Auth and Database, I used Supabase with Postgres. I created simple NodeJS server in repository ai-chat-test-api Auth handled by Supabase. I use hook to track auth state and made protected routes.
You can chat with 5 bots. They are stored in DB and promt to act like a charecter. To store data I use Redux Toolkit.
In backend I have 3 api routes:
- GET
/api/chat/- get all chatbots and their last message - GET
/api/chat/messages- get messages for chatbot - POST
/api/chat/messages- send message and receive response
- Node.js (version 21 or later)
- npm or yarn
-
Install dependencies:
npm install -
Set up environment variables: Create a
.envfile in the root directory and add the following:VITE_SUPABASE_URL=[supabase-url] VITE_SUPABASE_ANON_KEY=[supabase-anon-key] VITE_API_URL=[backend-api] -
Start the development server:
npm run dev -
Run server
Add virtual scroll for messages to handle chats with a big message history, now it's just a simple list.
