bcornick/collaborative-ai-chat-rooms
Live multi-user chat rooms with AI agents centered around specific subjects.
Venture Science Doctorate Subject-Specific Collaborative AI Chatrooms
This is a PartyKit project using Next.js bootstrapped with partykit-nextjs-chat-template.
PartyKit is an open source platform for developing multiplayer, real-time applications.
Getting Started
First, copy the .env.example file to .env in the project root.
cp .env.example .envThen, open the created .env file and fill in the missing environment variables.
Then, run the development server:
npm install
npm run devThis will start the PartyKit development server at port 1999, and a Next.js development server at port 3000.
Open http://localhost:3000 with your browser to see the result.
What's included
This template application demonstrates various use cases of PartyKit.
The /party directory contains partykit servers with the following examples:
- โน๏ธ main.ts โ Simplest possible HTTP and WebSocket server.
- ๐ฌ chatRoom.ts โ Real-time chat room with persistence
- ๐ฉโ๐ฉโ๐ฆโ๐ฆ chatRooms.ts โ Presence and room-to-room communication
- ๐โโ๏ธ user.ts โ User session management and authentication with NextAuth.js
- ๐ค ai.ts โ AI NPC chatroom participant using LLMs
- ๐ญ cursors.ts โ Shared cursors
The /app directory contains a Next.js 13 application, demonstrating client-side usage of PartyKit, including:
- ๐ก chat/page.tsx โ Server Rendering in React Server Components
- ๐ฑ RoomList.tsx โ Client Rendering with live WebSockets
- ๐ฎโโ๏ธ Room.tsx โ A real-time chatroom with authentication
- ๐ NewRoom.tsx - Form for creating new subject-specific chatrooms
- ๐ฑ๏ธ Cursors.tsx โ Live cursors
- ๐ฅ ConnectionStatus.tsx โ Connection status indicator
Deploy
Deploy the PartyKit Server on PartyKit
When you're ready to deploy your application to the internet, run the following command to deploy the PartyKit Server:
npx partykit deployThis will deploy the code to your PartyKit account โ and if you don't have an account yet, we'll create one as part of the deployment.
Configure environment variables
In development mode, PartyKit uses your .env file to read configuration values.
For production, you'll need to set the production environment variables:
# Set the production URL of your Next.js application for authentication
npx partykit env add NEXT_APP_URL
# (Optional) Set your OpenAI API key to enable the AI chat participant in production
npx partykit env add OPENAI_API_KEY
# Redeploy with new variables
npx partykit deployDeploy the website on Vercel
The easiest way to deploy the Next.js frontend for your PartyKit app is to use the Vercel Platform from the creators of Next.js.
Remember to configure the environment variables for your website hosting provider!
Learn More
To learn more about PartyKit, take a look at PartyKit documentation.