Overview
Neuron Meet uses PostgreSQL as its database, managed through Prisma ORM. This guide covers setting up the database locally with Docker or using a managed service like Supabase.Database Schema
The application uses the following data models:Core Models
User
User
Stores user accounts and authentication data.Fields:
id- Unique identifier (CUID)email- User email (unique, indexed)name- Full namedisplayName- Optional display namepassword- Bcrypt hashed passwordavatarUrl- Optional avatar image URLcreatedAt- Account creation timestampupdatedAt- Last update timestamp
- Hosts multiple rooms
- Participates in multiple rooms
- Sends multiple messages
Room
Room
Video conference rooms.Fields:
id- Unique identifier (CUID)code- Unique room code (indexed)name- Room namehostId- User ID of the host (indexed)isActive- Whether the room is currently activeisLocked- Whether new participants are blockedstartedAt- Room start timeendedAt- Room end time (nullable)createdAt- Creation timestampupdatedAt- Last update timestamp
- Belongs to one host (User)
- Has one RoomSettings
- Has multiple participants
- Has multiple messages
RoomSettings
RoomSettings
Configuration for individual rooms.Fields:
id- Unique identifier (CUID)roomId- Associated room ID (unique)allowChat- Enable/disable chat (default: true)allowScreenShare- Enable/disable screen sharing (default: true)allowGuestAccess- Allow guest users (default: true)waitingRoom- Enable waiting room (default: false)muteParticipantsOnJoin- Auto-mute new participants (default: false)isLocked- Lock room (default: false)maxParticipants- Maximum participants (default: 100)
- Belongs to one room (cascade delete)
Participant
Participant
Tracks users and guests in rooms.Fields:
id- Unique identifier (CUID)roomId- Room ID (indexed)userId- User ID if authenticated (nullable, indexed)guestName- Name if joining as guest (nullable)isActive- Whether currently in the roomisHost- Whether this is the host participantjoinedAt- Join timestampleftAt- Leave timestamp (nullable)
- Belongs to one room (cascade delete)
- Optionally belongs to one user
Message
Message
Chat messages in rooms.Fields:
id- Unique identifier (CUID)roomId- Room ID (indexed)userId- User ID if authenticated (nullable)senderName- Sender name (nullable)content- Message contenttype- Message type: TEXT, SYSTEM, or FILEcreatedAt- Timestamp (indexed)
- Belongs to one room (cascade delete)
- Optionally belongs to one user
Option 1: Local PostgreSQL with Docker
The fastest way to set up PostgreSQL locally is using Docker.Start PostgreSQL with Docker Compose
The project includes a Docker Compose configuration for PostgreSQL:This starts:
- PostgreSQL 15 Alpine
- Container name:
neuron-meet-db - User:
neuronmeet - Password:
neuronmeet - Database:
neuronmeet - Port:
5432 - Health check: runs every 5 seconds
Option 2: Supabase (Managed PostgreSQL)
Supabase provides a managed PostgreSQL database with additional features.Create a Supabase project
- Sign up at supabase.com
- Create a new project
- Choose a region close to your users
- Set a strong database password
Get connection strings
Navigate to Project Settings → Database → Connection string:For DATABASE_URL (Transaction pooler):For DIRECT_URL (Session pooler):
Supabase’s free tier includes:
- 500 MB database space
- Automatic backups
- Direct access to PostgreSQL
- No credit card required
Prisma Commands
Common database operations using Prisma:Generate Client
Generate the Prisma Client after schema changes:prisma generate in the server directory.
Push Schema (Development)
Push schema changes directly to the database without creating migrations:prisma db push - useful for rapid prototyping.
Run Migrations (Production)
Create and apply migrations:prisma migrate dev which:
- Creates a new migration file
- Applies it to the database
- Regenerates the Prisma client
Prisma Studio (Database GUI)
Open a visual database editor:http://localhost:5555 where you can:
- Browse all tables
- View and edit data
- Test queries
Connection Pooling
For production deployments, consider connection pooling:With Supabase
Supabase provides built-in connection pooling:- Transaction pooler (port 6543): For serverless/edge functions
- Session pooler (port 5432): For long-running servers
DATABASE_URL and Session pooler for DIRECT_URL.
With PgBouncer
For self-hosted PostgreSQL, use PgBouncer:DATABASE_URL.
Backup and Restore
Backup Database
Restore Database
Troubleshooting
Connection Refused
Docker: Cannot connect to localhost:5432
Docker: Cannot connect to localhost:5432
Check if PostgreSQL container is running:View container logs:Restart the container:
Supabase: Connection timeout
Supabase: Connection timeout
- Verify your IP is allowed in Supabase dashboard
- Check if you’re using the correct connection string
- Ensure you’re using the pooler URL (not direct connection) for serverless
Migration Errors
Migration failed: database schema is not empty
Migration failed: database schema is not empty
Reset the database and migrations:
Prisma client not generated
Prisma client not generated
Regenerate the Prisma client:
Next Steps
Environment Variables
Configure all database connection variables
Production Checklist
Optimize and secure your database for production