A modern, full-stack Polling & Voting application built with a Spring Boot REST API backend and a Flutter mobile client. The application enables users to create customizable polls with dynamic options, vote in real-time, and view live percentage-based results with interactive visualizations.
- Live Polls Feed: View all available community polls with question details, live vote counts, and total voter turnout badges.
- Interactive Voting: Instant voting with live progress bars, vote counts, and calculated percentages for each option.
- Dynamic Poll Creation:
- Add or remove options dynamically with real-time UI updates.
- Validation ensuring questions are non-empty and at least 2 valid options are provided.
- Clean Architecture & State Management:
- Predictable unidirectional data flow powered by BLoC (
flutter_bloc). - Robust functional programming and error handling with fpDart (
Either<Failure, T>). - Network requests managed using Dio with centralized error interceptors and timeout configurations.
- Predictable unidirectional data flow powered by BLoC (
- Robust REST API Backend:
- Spring Boot Data JPA with MySQL database persistence.
- Standardized JSON responses via
ApiResponse<T>. - Global exception handling and request validations.
- Framework: Flutter (Dart 3.x)
- State Management: flutter_bloc
- Networking: dio
- Functional Programming: fpdart
- Design System: Material 3 (with Light and Dark theme support)
- Language & Framework: Java 17+, Spring Boot (Spring Web MVC, Spring Data JPA)
- Database: MySQL (Hibernate ORM)
- Utilities: Project Lombok
- Build Tool: Maven
Spring-Boot-Polling-Application/
├── Backend/ # Spring Boot REST API
│ ├── src/main/java/com/faizan/voting_application/
│ │ ├── controllers/ # REST Controllers (PollController)
│ │ ├── dto/ # Data Transfer Objects (ApiResponse, Vote)
│ │ ├── middleware/ # GlobalExceptionHandler
│ │ ├── model/ # JPA Entities (Poll, OptionVote)
│ │ ├── repositories/ # Spring Data Repositories
│ │ └── services/ # Business Logic Services
│ ├── pom.xml
│ └── src/main/resources/application.properties
│
├── flutter_voting_app/ # Flutter Mobile Application
│ ├── lib/
│ │ ├── core/
│ │ │ ├── constants/ # API Endpoints & Base URLs
│ │ │ ├── error/ # Failure classes for fpDart
│ │ │ └── network/ # Dio ApiClient
│ │ ├── data/
│ │ │ ├── models/ # PollModel, OptionVoteModel, ApiResponseModel
│ │ │ └── repositories/ # PollRepository (fpDart Either implementation)
│ │ ├── presentation/
│ │ │ ├── bloc/ # PollListBloc & CreatePollBloc
│ │ │ ├── screens/ # HomeScreen, CreatePollScreen
│ │ │ └── widgets/ # PollCard, DynamicOptionInput
│ │ └── main.dart
│ └── pubspec.yaml
│
└── images/ # Screenshots & Assets
| Method | Endpoint | Description | Request Body |
|---|---|---|---|
GET |
/api/polls |
Retrieve all polls | None |
GET |
/api/polls/{id} |
Retrieve a single poll by ID | None |
POST |
/api/polls |
Create a new poll | { "question": "...", "options": [ { "voteOption": "...", "voteCount": 0 } ] } |
POST |
/api/polls/vote |
Cast a vote on a poll option | { "pollId": 1, "optionIndex": 0 } |
- Java JDK 17+
- MySQL Server (running on port
3306) - Flutter SDK (v3.12+ recommended)
- Android Studio / Xcode for emulators or a physical device
-
Configure Database: Create a MySQL database named
voting_app:CREATE DATABASE voting_app;
-
Configure
application.properties: Update/Backend/src/main/resources/application.propertieswith your database credentials:spring.datasource.url=jdbc:mysql://localhost:3306/voting_app spring.datasource.username=YOUR_MYSQL_USERNAME spring.datasource.password=YOUR_MYSQL_PASSWORD
-
Run the Backend:
cd Backend ./mvnw spring-boot:runThe backend will start on
http://localhost:8080.
-
Navigate to the Flutter project:
cd flutter_voting_app -
Install dependencies:
flutter pub get
-
Run the App:
- For iOS Simulator / macOS / Web:
flutter run
- For Android Emulator:
The app is preconfigured to route requests to
http://10.0.2.2:8080.flutter run
- For iOS Simulator / macOS / Web:
- Flutter Tests:
cd flutter_voting_app flutter test
- Backend Tests:
cd Backend ./mvnw test
This project is licensed under the MIT License - see the LICENSE file for details.

