A modern React-based question and answer system built with TypeScript, Vite, Tailwind CSS, and Supabase.
- Ask Questions: Users can submit questions with optional names
- Display Active Questions: Display screen shows the currently active question
- Admin Panel: Moderators can manage and activate questions
- Real-time Updates: Questions update in real-time across all connected clients
- Responsive Design: Works on desktop and mobile devices
- Error Handling: Comprehensive error boundaries and user feedback
- Frontend: React 19 with TypeScript
- Build Tool: Vite
- Styling: Tailwind CSS
- Backend: Supabase (PostgreSQL database)
- Routing: React Router
- State Management: React Hooks
- Node.js (v18 or higher)
- npm or yarn
- Supabase account and project
- Clone the repository:
git clone <repository-url>
cd hg3- Install dependencies:
npm install- Set up environment variables:
Create a
.envfile in the root directory with your Supabase credentials:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key- Set up the database:
Create a
questionstable in your Supabase database with the following structure:
CREATE TABLE questions (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
question TEXT NOT NULL,
name TEXT,
status TEXT DEFAULT 'pending' CHECK (status IN ('pending', 'active', 'answered')),
inserted_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);-
Enable Realtime for the questions table:
- Go to your Supabase dashboard
- Navigate to Database → Replication
- Under "Source", select your database
- Find the "questions" table and toggle the Realtime switch to enable it
- This is required for real-time updates to work in the admin panel
-
Start the development server:
npm run dev- Navigate to the home page (
/) - Enter your question in the text area
- Optionally add your name
- Click "Submit Question"
- Navigate to
/displayto see the currently active question - The display automatically refreshes every 5 seconds
- Navigate to
/adminto access the moderator panel - View all submitted questions
- Click "Show" next to a question to make it active
- Only one question can be active at a time
src/
├── components/
│ └── ErrorBoundary.tsx # Error handling component
├── hooks/
│ └── useSupabaseQuery.ts # Custom hook for Supabase queries
├── pages/
│ ├── Ask.tsx # Question submission form
│ ├── Display.tsx # Active question display
│ └── Admin.tsx # Admin panel for moderation
├── types/
│ └── index.ts # TypeScript type definitions
├── App.tsx # Main application component
├── main.tsx # Application entry point
├── supabaseClient.ts # Supabase client configuration
└── index.css # Global styles and Tailwind imports
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.