A modern, real-time customer support chat application built with Next.js 15 and Supabase.
- Ticket Creation: Create support tickets with subject, priority, and initial message
- Real-time Chat: Chat with support agents in real-time
- Ticket History: View all your support tickets and their status
- Status Tracking: Track ticket progress (open, in_progress, resolved, closed)
- Agent Dashboard: Comprehensive ticket queue management
- Ticket Assignment: Assign tickets to yourself or view assigned tickets
- Multi-ticket Management: Handle multiple customer conversations
- Ticket Status Management: Update ticket status and close resolved issues
- Real-time Messaging: Instant messaging with customers
- Real-time Communication: Powered by Supabase Realtime
- Role-based Access Control: Customer and agent roles with appropriate permissions
- Responsive Design: Works on desktop and mobile devices
- Authentication: Secure user authentication with Supabase Auth
- Database Security: Row Level Security (RLS) policies for data protection
- Node.js 18+
- A Supabase project
-
Clone the repository
-
Install dependencies:
npm install
-
Set up environment variables in
.env.local:NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key -
Set up the database by running the SQL schema in your Supabase project:
# Copy the contents of supabase_schema.sql and run it in your Supabase SQL editor -
Start the development server:
npm run dev
The application uses the following main tables:
- user_profiles: Extended user information with roles
- support_tickets: Customer support tickets
- chat_messages: Real-time chat messages
- Can create support tickets
- Can chat with assigned agents
- Can view their own ticket history
- Can view and manage all tickets
- Can assign tickets to themselves
- Can chat with customers
- Can update ticket status
- Can access agent dashboard
- Same permissions as agents
- Can be extended for additional administrative features
- Frontend: Next.js 15, React 19, TypeScript
- Backend: Supabase (PostgreSQL + Realtime)
- Authentication: Supabase Auth
- Styling: Tailwind CSS
- UI Components: Radix UI
- Real-time: Supabase Realtime subscriptions
To run the application in development mode:
npm run devTo build for production:
npm run build
npm startMessages are delivered instantly using Supabase's real-time subscriptions. The chat interface automatically scrolls to new messages and shows typing indicators.
The application automatically routes users based on their role:
- Customers are directed to their support dashboard
- Agents are directed to the agent dashboard
- Cross-role navigation is available via the header
Tickets progress through states:
- Open: New ticket awaiting assignment
- In Progress: Agent assigned and actively working
- Resolved: Issue resolved, pending customer confirmation
- Closed: Ticket completed and archived
- Row Level Security (RLS) ensures users can only access their own data
- Agents can access tickets assigned to them or unassigned tickets
- All database operations are secured with appropriate policies
- Authentication is handled by Supabase Auth with secure session management