FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
ikeali
ikealimy-first-val
Public
Like
my-first-val
Home
Code
9
backend
3
frontend
4
shared
2
01_script.tsx
H
02_http.tsx
E
04_email.tsx
README.md
new-file-2619.tsx
new-file-8443.tsx
Branches
1
Pull requests
Remixes
1
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
02_http.tsx
https://ikeali--3369502e3f9f11f0976576b3cceeab13.web.val.run
README.md

Online Voting System

A comprehensive online voting platform built with Val Town, featuring secure authentication, poll management, and real-time results.

Features

  • User Authentication: Secure login/registration system
  • Poll Management: Create, edit, and manage voting polls
  • Voting Interface: Clean, intuitive voting experience
  • Real-time Results: Live vote counting and result display
  • Admin Dashboard: Manage polls and view analytics
  • Security: One vote per user per poll enforcement

Project Structure

├── backend/
│   ├── database/
│   │   ├── migrations.ts    # Database schema setup
│   │   └── queries.ts       # Database query functions
│   ├── routes/
│   │   ├── auth.ts         # Authentication endpoints
│   │   ├── polls.ts        # Poll management endpoints
│   │   ├── votes.ts        # Voting endpoints
│   │   └── static.ts       # Static file serving
│   └── index.ts            # Main Hono app entry point
├── frontend/
│   ├── components/
│   │   ├── App.tsx         # Main React app
│   │   ├── Login.tsx       # Login/register component
│   │   ├── PollList.tsx    # List of available polls
│   │   ├── PollDetail.tsx  # Individual poll voting interface
│   │   ├── CreatePoll.tsx  # Poll creation form
│   │   └── Results.tsx     # Results display component
│   ├── index.html          # Main HTML template
│   ├── index.tsx           # Frontend entry point
│   └── style.css           # Custom styles
└── shared/
    ├── types.ts            # Shared TypeScript types
    └── utils.ts            # Shared utility functions

Database Schema

Users Table

  • id (PRIMARY KEY)
  • username (UNIQUE)
  • email (UNIQUE)
  • password_hash
  • is_admin
  • created_at

Polls Table

  • id (PRIMARY KEY)
  • title
  • description
  • creator_id (FOREIGN KEY)
  • start_date
  • end_date
  • is_active
  • created_at

Poll Options Table

  • id (PRIMARY KEY)
  • poll_id (FOREIGN KEY)
  • option_text
  • vote_count

Votes Table

  • id (PRIMARY KEY)
  • poll_id (FOREIGN KEY)
  • user_id (FOREIGN KEY)
  • option_id (FOREIGN KEY)
  • voted_at

API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • GET /api/auth/me - Get current user

Polls

  • GET /api/polls - List all active polls
  • GET /api/polls/:id - Get specific poll details
  • POST /api/polls - Create new poll (authenticated)
  • PUT /api/polls/:id - Update poll (creator/admin only)
  • DELETE /api/polls/:id - Delete poll (creator/admin only)

Voting

  • POST /api/votes - Cast a vote
  • GET /api/polls/:id/results - Get poll results

Getting Started

  1. The system uses SQLite for data storage
  2. Authentication uses session-based cookies
  3. The frontend is a React SPA with TailwindCSS
  4. Real-time updates use polling (can be upgraded to WebSockets)

Security Features

  • Password hashing with bcrypt
  • Session-based authentication
  • CSRF protection
  • One vote per user per poll enforcement
  • Input validation and sanitization
HTTP
  • 02_http.tsx
    ikeali--33…13.web.val.run
Email
  • 04_email.tsx
Code
backendfrontendshared01_script.tsx
H
02_http.tsx
E
04_email.tsx
README.mdnew-file-2619.tsxnew-file-8443.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.