Election Voting & Chat App

A real-time voting application with public chat functionality for election discussions.

Features

  • Voting System: Cast votes for different candidates/options
  • Public Chat Room: Real-time discussion about elections
  • Vote Results: Live vote tallies and percentages
  • User Authentication: Simple username-based system
  • Responsive Design: Works on desktop and mobile

Project Structure

├── backend/
│   ├── database/
│   │   ├── migrations.ts    # Database schema setup
│   │   └── queries.ts       # Database query functions
│   ├── routes/
│   │   ├── votes.ts         # Voting API endpoints
│   │   └── chat.ts          # Chat API endpoints
│   └── index.ts             # Main Hono server
├── frontend/
│   ├── components/
│   │   ├── App.tsx          # Main application component
│   │   ├── VotingPanel.tsx  # Voting interface
│   │   └── ChatRoom.tsx     # Chat interface
│   ├── index.html           # Main HTML template
│   └── index.tsx            # Frontend entry point
└── shared/
    └── types.ts             # Shared TypeScript types

Technology Stack

  • Backend: Hono (TypeScript API framework)
  • Frontend: React with TypeScript
  • Database: SQLite
  • Styling: TailwindCSS
  • Real-time: Server-Sent Events (SSE)

API Endpoints

  • GET / - Serve the main application
  • GET /api/votes - Get current vote results
  • 'GET'/api/votes' - Get total votes
  • POST /api/votes - Cast a vote and count
  • GET /api/chat/messages - Get chat messages
  • POST /api/chat/messages - Send a chat message
  • GET /api/chat/stream - SSE stream for real-time chat updates

Usage

  1. Enter your username to join
  2. Cast your vote for your preferred candidate
  3. Participate in the public chat discussion
  4. View live vote results and chat updates