Skip to content

FawazAlhafiz/polling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Polling App

A modern, responsive polling application built with Frappe Framework and Vue.js

License Frappe Vue.js

✨ Features

🎯 Core Functionality

  • Create Polls: Easy-to-use interface for creating detailed polls
  • Smart Status Management: Automatic handling of Active, Upcoming, and Ended polls
  • Real-time Participation: Vote on active polls with instant feedback
  • Results Visualization: View poll results with clear data presentation
  • Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
  • Target Audience: Restrict polls to specific users, Frappe roles, or departments (ERPNext/HRMS)
  • Expiry Notifications: Notify poll owners and eligible voters before a poll closes

🎨 Modern UI/UX

  • Clean Card-based Layout: Professional, easy-to-scan poll cards
  • Emoji Icons: Lightweight design without external icon dependencies
  • Status Indicators: Color-coded badges for poll status (Active/Upcoming/Ended)
  • Loading States: Smooth loading animations and empty state handling
  • Hover Effects: Interactive elements with smooth transitions

πŸ› οΈ Technical Features

  • Frappe Framework Backend: Robust, scalable backend with DocType management
  • Vue.js Frontend: Modern, reactive frontend with Composition API
  • Production Ready: CSRF token security for production deployments
  • Error Handling: Comprehensive validation and user-friendly error messages
  • Tailwind CSS: Utility-first styling for consistent design
  • Frappe UI Components: Native integration with Frappe UI library
  • Date Management: Smart date formatting and poll scheduling
  • Audience Resolution: Efficiently resolves allowed voters by user, role, and department membership
  • Scheduled Tasks: Hourly expiry notification job scoped to the target audience

πŸš€ Quick Start

Prerequisites

  • Frappe Bench installed
  • Node.js and Yarn for frontend development
  • Python 3.10+ for backend
  • ERPNext/HRMS (optional) β€” required only for department-based audience targeting

Installation

  1. Get the app:
cd $PATH_TO_YOUR_BENCH
bench get-app https://github.com/fawaaaz111/polling.git
  1. Install the app:
bench install-app polling
  1. Start development (optional):
# For backend development
bench start

# For frontend development
cd apps/polling/frontend
yarn dev

πŸ“± Screenshots

Polls Dashboard

  • Clean, card-based layout showing all available polls
  • Status badges indicating poll state
  • Interactive voting and results buttons

Poll Management

  • Easy poll creation with title, description, and date settings
  • Status tracking throughout poll lifecycle
  • Responsive design for all devices

πŸ—οΈ Architecture

Backend (Frappe Framework)

polling/
β”œβ”€β”€ polling/
β”‚   β”œβ”€β”€ doctype/
β”‚   β”‚   β”œβ”€β”€ poll/              # Poll DocType β€” title, dates, status, target audience, options
β”‚   β”‚   β”œβ”€β”€ poll_option/       # Child table β€” vote options with vote counts
β”‚   β”‚   β”œβ”€β”€ poll_vote/         # Submittable DocType β€” records each cast vote
β”‚   β”‚   β”œβ”€β”€ poll_target/       # Child table β€” audience rows (user / role / department)
β”‚   β”‚   └── poll_result/       # Virtual DocType β€” computed results on-the-fly
β”‚   β”œβ”€β”€ tasks.py               # Scheduled tasks (hourly expiry notifications)
β”‚   β”œβ”€β”€ permissions.py         # Owner-based access control for Poll Vote
β”‚   β”œβ”€β”€ patches/               # Database migration patches
β”‚   β”œβ”€β”€ www/                   # Web pages served by Frappe
β”‚   └── public/                # Static assets

Frontend (Vue.js)

frontend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Polls.vue          # Main polls listing + voting interface
β”‚   β”‚   └── PollResults.vue    # Results page with vote distribution
β”‚   β”œβ”€β”€ components/            # Reusable Vue components
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   └── session.js         # Reactive session / auth state
β”‚   └── router.js              # Vue Router with auth guards
β”œβ”€β”€ package.json               # Dependencies and scripts
└── vite.config.js             # Build configuration

Key DocTypes

DocType Type Description
Poll Regular Core document β€” title, dates, status, options, target audience
Poll Option Child table Vote options; vote_count increments on submission
Poll Vote Submittable One record per cast vote; enforces audience, date, and dedup checks
Poll Target Child table Audience rows: user, role, or department (ERPNext/HRMS)
Poll Result Virtual Computes vote distribution on-the-fly from Poll + Poll Option data

Target Audience

When a poll has rows in its target_audience child table, only matching users may vote and receive expiry notifications. A voter is allowed if they match any of the following:

  • User β€” their Frappe user account is listed explicitly
  • Role β€” they hold one of the listed Frappe roles
  • Department β€” they are an active Employee in one of the listed departments (requires ERPNext/HRMS)

Polls with an empty target_audience are open to all users.

πŸ› οΈ Development

Setting up Development Environment

  1. Clone and install:
bench get-app https://github.com/fawaaaz111/polling.git
bench install-app polling
  1. Enable developer mode:
bench set-config developer_mode 1
  1. Start frontend development:
cd apps/polling/frontend
yarn install
yarn dev
  1. Build for production:
cd apps/polling/frontend
yarn build
# or
bench build --app polling
  1. Production deployment:
# After building, restart your server
bench restart

# The app handles CSRF tokens automatically for secure production use

Code Quality Tools

This app uses pre-commit for code formatting and linting:

cd apps/polling
pre-commit install

Configured tools:

  • ruff: Python linting and formatting
  • biome: JavaScript/Vue.js linting and formatting (yarn lint)
  • eslint: JavaScript linting (pre-commit hook)
  • prettier: JavaScript/Vue/SCSS formatting (pre-commit hook)

Running Tests

# Run all app tests
bench run-tests --app polling

# Run tests for a specific DocType
bench run-tests --app polling --doctype "Poll Vote"
bench run-tests --app polling --doctype "Poll"

πŸ“¦ Dependencies

Backend

  • Frappe Framework: Core backend framework
  • Python 3.10+: Runtime environment

Frontend

  • Vue.js 3.x: Progressive JavaScript framework
  • Tailwind CSS: Utility-first CSS framework
  • Frappe UI: Native Frappe component library
  • Vite: Fast build tool and dev server

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Install pre-commit: pre-commit install
  4. Make your changes and ensure they pass all checks
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Development Guidelines

  • Follow the existing code style and patterns
  • Write clear commit messages
  • Add comments for complex logic
  • Test your changes thoroughly
  • Update documentation as needed

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

πŸ™ Acknowledgments


Built with ❀️ using Frappe Framework and Vue.js

About

Modern polling app with Frappe Framework backend and Vue.js frontend for creating and managing interactive polls

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors