This is a chat application template built with Next.js and Supabase, providing a modern UI for conversations with AI assistants.
- Real-time chat interface
- Model selector for different AI models
- Public/private visibility for chats
- Document management
- Suggestions system
- User authentication via Supabase Auth
- Row-level security for data protection
- Frontend: Next.js, React, Tailwind CSS
- Backend: Supabase (PostgreSQL, Auth)
- Styling: Tailwind CSS
- Supabase CLI installed (for local development)
- A Supabase project (for production)
- Clone this repository
git clone <https://github.com/will-lp1/vercel-ai-chatbot-supabase.git>
cd <repository-name>- Install dependencies
pnpm install
- Set up Supabase locally
supabase init
supabase start- Copy the environment variables
cp .env.example .env.local-
Update the
.env.localfile with your Supabase URL and anon key (found in the Supabase dashboard or from the local setup) -
Run the development server
pnpm devOpen http://localhost:3000 to see the application running.
The application uses the following tables in Supabase:
Chat: Stores chat conversationsMessage: Stores individual messages in chatsMessageContent: Stores different types of content within messagesDocument: Stores document informationSuggestion: Stores suggestions for document improvementsVote: Tracks user votes on messages
See the supabase/README.md file for more details on the database structure and migration files.
The application uses Supabase Auth for user authentication. Users can:
- Sign up with email and password
- Log in with existing credentials
- Access their own chats and documents
You can deploy the Next.js application to Vercel:
- Push your code to a GitHub repository
- Import the project in Vercel
- Set the environment variables (from your Supabase project)
- Deploy
There are multiple ways to set up the database for this application:
- Create a Supabase project
- Link your local project to the Supabase project:
supabase link --project-ref your-project-ref- Push the migrations:
supabase db push- Navigate to your Supabase project dashboard
- Go to the SQL Editor tab
- Copy the contents of the migration files from either:
supabase/migrations/*.sqlfileslib/db/migrations/*.sqlfiles
- Paste and execute these SQL files in order in the SQL Editor
For example, first execute 20240601000000_initial_schema.sql, then 20240601000001_functions_and_types.sql.
For a seamless setup experience, you can use the supabase-mcp-server with AI coding tools to:
- Follow the setup
- Connect to your Supabase project through the server
- Have the AI assistant analyze the migration files and apply them to your project
This approach is particularly useful when working with AI coding IDEs, like Windsurf and Cursor, that can help automate the setup process and ensure all migrations are applied correctly.
/app: Next.js app router files/components: React components/lib: Utility functions and shared code/public: Static assets/supabase: Supabase configuration and migrations
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.