How benni2013/kp-bps works
Project Type and Purpose
• E-Voisy is a full-stack web application (Node.js/Express backend + Handlebars/TailwindCSS frontend) that facilitates two‐stage electronic voting and reporting for BPS Kota Padang.
File Structure
• app.js & bin/www: Application entry point and server launcher
• config/: Database configuration (Sequelize + MySQL)
• models/ & migrations/ & seeders/: Sequelize ORM layer, schema migrations, and seed data
• routes/: Express route definitions (e.g., auth, admin, voting)
• controllers/: Business logic for each route
• views/: Handlebars templates for Admin, User, Supervisor UIs
• public/: Static assets (CSS, images, generated PDFs)
• package.json: Dependencies (Express, Sequelize, ExcelJS, PDFKit, etc.)
Read README for Additional Insights
• Users & roles: Admin, Pegawai (voter), Supervisor
• Workflow:
1) Data input (CKP & attendance)
2) Voting stage 1 (top-3 candidate selection)
3) Voting stage 2 (criteria-based scoring)
4) Real-time monitoring & report generation
• Key libraries: Sequelize (ORM), ExcelJS/PDFKit (file generation), Handlebars (templating)
Main Components and Interactions
• Client Browser (Frontend)
• UI templates (Handlebars + TailwindCSS)
• Static files (JS/CSS/images) served from public/
• Web Server (Backend – Express.js)
• Routes → Controllers → Services → Models
• Session or JWT‐based Authentication (SECRET_KEY)
• File‐generation modules (ExcelJS, PDFKit)
• Database (MySQL via Sequelize)
• Tables: anggota (members), indikator (criteria), periode, pemilihan (elections), detail_pemilihan, data_nilai, voting1/voting2
• File Storage (local filesystem)
• Uploaded proofs, generated reports (PDFs, Excel) in public/files
• (Optional) External/Devops
• .env for environment variables, config/config.json for DB credentials
• Deployment container or PaaS
Architectural Patterns & Design Principles
• MVC Pattern:
• Models (Sequelize) ↔ Controllers (business logic) ↔ Views (Handlebars)
• Modular Routing: Each feature (auth, admin, voting, reports) has its own route module
• Layered File‐Generation Service: Controllers invoke ExcelJS/PDFKit for report exports
• Real‐Time Monitoring: Controllers fetch live voting data and push to views (can evolve into WebSocket layer)
Essential Elements
• “Browser (Admin/User/Supervisor)”
• “Express Server” subdivided into:
– Routes
– Controllers (AuthController, GenerateController, HandleVote controllers…)
– Services (ExcelJS/PDFKit modules)
– Models (Sequelize models & migrations)
• “MySQL Database” (tables)
• “File Storage” (public/files)
• Relationships:
• Route → Controller → Model
• Controller → File Service → File Storage
• Controller → View (Handlebars) → Browser
• Annotations for the two‐stage voting flow
• Environment/config layer for .env and config/config.json