Skip to content

Genrec-Community/Openchat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenChat

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.

πŸš€ Features

  • 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

πŸ› οΈ Technology Stack

Frontend

  • 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

Backend & Services

  • Supabase 2.56.0 - Backend-as-a-Service (Database, Auth, Real-time)
  • PostgreSQL - Database (via Supabase)

Development Tools

  • ESLint - Code linting and formatting
  • PostCSS - CSS processing
  • Autoprefixer - CSS vendor prefixes

πŸ“‹ Prerequisites

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

πŸš€ Quick Start

1. Clone the Repository

git clone <repository-url>
cd openchat

2. Install Dependencies

npm install

3. Environment Setup

Create a .env.local file in the root directory:

VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key

4. Database Setup

  1. Create a new Supabase project
  2. Run the provided SQL schema in your Supabase SQL editor:
# Execute the database_schema.sql file in your Supabase dashboard

5. Start Development Server

npm run dev

The application will be available at http://localhost:5173

πŸ“œ Available Scripts

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

πŸ—οΈ Project Structure

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

πŸ”§ Configuration

Supabase Setup

  1. Create tables using database_schema.sql
  2. Configure Row Level Security (RLS) policies
  3. Enable real-time subscriptions
  4. Set up authentication providers if needed

Environment Variables

Required environment variables:

  • VITE_SUPABASE_URL - Your Supabase project URL
  • VITE_SUPABASE_ANON_KEY - Your Supabase anonymous key

TailwindCSS

The project uses TailwindCSS v3.4.0 for styling. Configuration can be modified in tailwind.config.js.

🌟 Key Features Explained

Authentication System

  • Anonymous user creation with unique usernames
  • Session management via Supabase Auth
  • OP (moderator) role support for administrative functions

Message Types

  1. Direct Messages: Regular chat messages that automatically expire after 24 hours
  2. Pinned Messages: Important announcements that persist permanently (OP-only)

Real-time Updates

  • Live message updates using Supabase real-time subscriptions
  • Automatic UI updates when new messages arrive
  • Real-time user activity tracking

Theme System

  • Light and dark mode support
  • User preference persistence
  • Seamless theme switching

πŸ” Security Features

  • 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

πŸš€ Deployment

Build for Production

npm run build

Deployment Options

  • 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

Environment Configuration

Ensure environment variables are properly configured in your hosting platform.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • 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

πŸ“ License

This project is open source and available under the MIT License.

πŸ› Troubleshooting

Common Issues

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

πŸ“ž Support

For questions, issues, or contributions:

  • Open an issue on GitHub
  • Check existing documentation
  • Review the database schema for data structure questions

πŸ”„ Version History

  • 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

Releases

No releases published

Packages

No packages published