Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗳️ Spring Boot & Flutter Polling Application

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.


📱 App Screenshots

Live Polls & Voting

Live Polls Screen
Create Dynamic Poll

Create Poll Screen

✨ Features

  • 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.
  • Robust REST API Backend:
    • Spring Boot Data JPA with MySQL database persistence.
    • Standardized JSON responses via ApiResponse<T>.
    • Global exception handling and request validations.

🛠️ Tech Stack

Mobile Frontend (Flutter)

  • Framework: Flutter (Dart 3.x)
  • State Management: flutter_bloc
  • Networking: dio
  • Functional Programming: fpdart
  • Design System: Material 3 (with Light and Dark theme support)

Backend (Spring Boot)

  • Language & Framework: Java 17+, Spring Boot (Spring Web MVC, Spring Data JPA)
  • Database: MySQL (Hibernate ORM)
  • Utilities: Project Lombok
  • Build Tool: Maven

📂 Project Structure

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

🔌 API Endpoints

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 }

🚀 Getting Started

Prerequisites

  • Java JDK 17+
  • MySQL Server (running on port 3306)
  • Flutter SDK (v3.12+ recommended)
  • Android Studio / Xcode for emulators or a physical device

1. Backend Setup

  1. Configure Database: Create a MySQL database named voting_app:

    CREATE DATABASE voting_app;
  2. Configure application.properties: Update /Backend/src/main/resources/application.properties with your database credentials:

    spring.datasource.url=jdbc:mysql://localhost:3306/voting_app
    spring.datasource.username=YOUR_MYSQL_USERNAME
    spring.datasource.password=YOUR_MYSQL_PASSWORD
  3. Run the Backend:

    cd Backend
    ./mvnw spring-boot:run

    The backend will start on http://localhost:8080.


2. Flutter App Setup

  1. Navigate to the Flutter project:

    cd flutter_voting_app
  2. Install dependencies:

    flutter pub get
  3. 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

🧪 Testing

  • Flutter Tests:
    cd flutter_voting_app
    flutter test
  • Backend Tests:
    cd Backend
    ./mvnw test

📄 License

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages