Skip to main content
Navigation
HomeTechnical ReferenceJournalGitHubGitHub
Sidebar — toggle document categories via the logo
Ballot Online — Voting Platform

Ballot Online — Voting Platform

June 10, 2020

Overview

Ballot Online is a full-stack voting platform that demonstrates modern web architecture with GraphQL at its core. The backend is a Django application using Graphene-Django — models are automatically transformed into a GraphQL schema, eliminating the need to manually define resolvers for CRUD operations. The frontend is a Gatsby.js React application using Apollo Client for data fetching.

Users can register accounts, create poll questions, browse existing questions, and cast votes. The platform uses JWT-based authentication with Django's session system, and the frontend serves as a static Progressive Web App via Gatsby.


Key Features

  • Auto-generated GraphQL schema: Django models are converted to GraphQL types by Graphene-Django — no manual schema definition needed
  • JWT authentication: Secure user registration, login, and session management
  • Question creation: Users create voting questions with multiple options
  • Voting on questions: Cast votes through GraphQL mutations
  • Static frontend: Gatsby.js pre-renders the React application for fast page loads and SEO
  • Apollo Client: Optimistic UI updates make voting feel instantaneous

Architecture

A backend + frontend split with GraphQL as the communication layer:

ServiceRole
backend (Django)GraphQL API with auto-generated schema, JWT auth
frontend (Gatsby)React SPA with Apollo Client, Material UI
PostgreSQLProduction database

The backend runs Django on port 8004 with Gunicorn for production. The frontend is built as a static Gatsby site and served through Nginx. The project uses a Makefile for build scripts and environment configuration.


Data Flow

User Action → Apollo Client → GraphQL Mutation/Query → Django Graphene → SQL → PostgreSQL

Optimistic UI Update (before server response)

All mutations use Apollo's optimistic response pattern — the UI updates immediately, then reconciles when the server confirms.


Tech Stack

LayerTechnology
FrontendGatsby.js, React, Apollo Client, Material UI
API BackendDjango, Graphene-Django, GraphQL
AuthenticationJWT (JSON Web Tokens)
DatabasePostgreSQL (production), SQLite (development)
DeploymentNginx (static files) + Gunicorn (Django WSGI)