A modern, real-time chat application built with React, TypeScript, and Supabase. OpenChat provides a clean, responsive interface for instant messaging with theme customization and user authentication.
- Real-time Messaging: Instant chat functionality powered by Supabase real-time subscriptions
- User Authentication: Secure user sessions and profile management
- Dual Chat Types:
- Direct messages (expire after 24 hours)
- Pinned messages (permanent, OP-only)
- Theme Support: Light and dark mode with user preferences
- Responsive Design: Modern UI built with TailwindCSS
- Modular Architecture: Clean, maintainable component structure
- TypeScript: Full type safety and enhanced developer experience
- React 19.1.1 - UI Framework
- TypeScript 5.8.3 - Type-safe JavaScript
- Vite 7.1.2 - Fast build tool and dev server
- TailwindCSS 3.4.17 - Utility-first CSS framework
- React Router DOM 7.8.2 - Client-side routing
- Lucide React 0.541.0 - Beautiful icons
- Supabase 2.56.0 - Backend-as-a-Service (Database, Auth, Real-time)
- PostgreSQL - Database (via Supabase)
- ESLint - Code linting and formatting
- PostCSS - CSS processing
- Autoprefixer - CSS vendor prefixes
Before running this project, make sure you have:
- Node.js 18.0 or higher
- npm or yarn package manager
- Supabase Account - For backend services
- Git - For version control
git clone <repository-url>
cd openchatnpm installCreate a .env.local file in the root directory:
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key- Create a new Supabase project
- Run the provided SQL schema in your Supabase SQL editor:
# Execute the database_schema.sql file in your Supabase dashboardnpm run devThe application will be available at http://localhost:5173
| Command | Description |
|---|---|
npm run dev |
Start development server with hot reload |
npm run build |
Build production bundle |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint code analysis |
openchat/
βββ src/
β βββ components/ # React components
β β βββ ChatLayout.tsx # Main chat interface
β β βββ DirectChat.tsx # Direct messaging component
β β βββ LoginPage.tsx # User authentication
β β βββ PinnedChat.tsx # Pinned messages display
β β βββ SettingsPage.tsx # User settings and preferences
β βββ contexts/ # React Context providers
β β βββ AuthContext.tsx # Authentication state management
β β βββ ThemeContext.tsx # Theme state management
β βββ lib/ # External service integrations
β β βββ supabase.ts # Supabase client configuration
β βββ services/ # Background services
β β βββ messageCleanup.ts # Automated message cleanup
β βββ types/ # TypeScript type definitions
β β βββ index.ts # Shared type interfaces
β βββ App.tsx # Main application component
β βββ main.tsx # Application entry point
β βββ index.css # Global styles
βββ database_schema.sql # Supabase database schema
βββ package.json # Project dependencies and scripts
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # TailwindCSS configuration
βββ tsconfig.json # TypeScript configuration
- Create tables using
database_schema.sql - Configure Row Level Security (RLS) policies
- Enable real-time subscriptions
- Set up authentication providers if needed
Required environment variables:
VITE_SUPABASE_URL- Your Supabase project URLVITE_SUPABASE_ANON_KEY- Your Supabase anonymous key
The project uses TailwindCSS v3.4.0 for styling. Configuration can be modified in tailwind.config.js.
- Anonymous user creation with unique usernames
- Session management via Supabase Auth
- OP (moderator) role support for administrative functions
- Direct Messages: Regular chat messages that automatically expire after 24 hours
- Pinned Messages: Important announcements that persist permanently (OP-only)
- Live message updates using Supabase real-time subscriptions
- Automatic UI updates when new messages arrive
- Real-time user activity tracking
- Light and dark mode support
- User preference persistence
- Seamless theme switching
- Row Level Security (RLS): Database-level access control
- Environment Variables: Secure configuration management
- Type Safety: TypeScript prevents runtime errors
- Input Validation: Proper data validation and sanitization
npm run build- Vercel: Zero-config deployment for Vite apps
- Netlify: Static site hosting with continuous deployment
- GitHub Pages: Free hosting for static sites
- Any static hosting service
Ensure environment variables are properly configured in your hosting platform.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Use ESLint for code formatting
- Write meaningful component and function names
- Keep components focused and reusable
- Add proper type definitions for new features
This project is open source and available under the MIT License.
Build Errors
- Ensure all environment variables are set
- Check Node.js version compatibility
- Clear node_modules and reinstall dependencies
Supabase Connection Issues
- Verify environment variables are correct
- Check Supabase project status
- Ensure database schema is properly applied
Real-time Not Working
- Confirm Supabase real-time is enabled
- Check browser console for connection errors
- Verify RLS policies allow required operations
For questions, issues, or contributions:
- Open an issue on GitHub
- Check existing documentation
- Review the database schema for data structure questions
- v0.0.0 - Initial release with core chat functionality
- Real-time messaging with Supabase
- User authentication and session management
- Theme customization support
- Mobile-responsive design
Built with β€οΈ using React, TypeScript, and Supabase