Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Move37 Ventures — Real-Time Polling (Backend)

Overview

This repository is a complete backend for a real-time polling application using:

  • Node.js + Express
  • PostgreSQL
  • Prisma (ORM)
  • Socket.IO (WebSocket)

Features

  • RESTful API for Users, Polls, Poll Options, and Votes.
  • Prisma schema modeling one-to-many and many-to-many relationships.
  • Real-time updates via Socket.IO rooms (one room per poll).

Quick start

  1. Clone / unzip the project.
  2. Copy .env.example to .env and update DATABASE_URL.
  3. Install dependencies:
    npm install
  4. Generate Prisma client:
    npx prisma generate
  5. Create your database (Postgres) and run migrations:
    npx prisma migrate dev --name init
  6. Start the server:
    npm run dev
    # or
    npm start
  7. Server defaults to http://localhost:4000.

REST API (summary)

  • POST /users — create user { "name","email","password" }
  • GET /users/:id — get user (no passwordHash returned)
  • POST /polls — create poll with options:
    {
      "question": "Your question?",
      "creatorId": 1,
      "options": ["a","b","c"],
      "isPublished": false
    }
  • GET /polls — list polls
  • GET /polls/:id — get poll with options and vote counts
  • POST /polls/:pollId/vote — submit a vote { "userId": 1, "optionId": 2 }
  • PATCH /polls/:id/publish — publish a poll (sets isPublished = true)

Real-time (Socket.IO)

  • Clients should join a poll room: socket.emit('join', { pollId })
  • Server emits poll:update to that room when a new vote arrives with the updated option vote counts.

Notes & Security

  • Passwords are hashed with bcrypt.
  • No authentication middleware included (left intentionally simple for screening). In a production system, add JWT/session-based auth, rate-limiting, validation, and input sanitization.
  • Use SSL/TLS in production and secure your DATABASE_URL.

Prisma Schema

See prisma/schema.prisma for the data model.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages