🚀 Live Demo: https://pollingapp-c178.onrender.com/
A modern full-stack polling web application featuring JWT authentication, real-time voting, dynamic result visualization, comments, likes, view counting, and a fully responsive Material UI design.
- 🔐 User Authentication — Secure registration and login with JWT (JSON Web Tokens) & BCrypt password hashing.
- 📊 Interactive Polls — Create polls with custom options and expiration dates.
- 🗳️ Real-Time Voting — Enforces one vote per user per poll with instant tallying.
- 📈 Dynamic Results — Visual progress bars with automated percentage calculations.
- 💬 Comments System — Engage in discussions under polls with instant updates.
- ❤️ Likes & Views Tracking — Like/unlike toggle mechanism and poll view analytics.
- 👤 User Dashboard ("My Polls") — View, manage, and delete polls created by the logged-in user.
- ⏳ Expiration Handling — Auto-closes polls upon reaching expiration time with distinct UI badges.
- 📱 Responsive UI — Built with Material UI 5 with support for mobile, tablet, and desktop viewports.
| Layer | Technology | Details |
|---|---|---|
| Frontend | React 18, Vite 5, JavaScript (ES6+) | Single Page Application (SPA) |
| UI Framework | Material UI (MUI v5), Emotion, Notistack | Modern responsive design & notification toasts |
| HTTP Client | Axios | Configured with automatic JWT request/response interceptors |
| Backend | Java 17 / 21, Spring Boot 3.2.5 | RESTful API built with Spring Data JPA & Hibernate |
| Security | Spring Security 6, JJWT (0.12.5) | Stateless authentication & BCrypt password hashing |
| Database | PostgreSQL (Neon Cloud) / H2 (Local) | Production cloud DB & fast zero-setup local DB |
| Containerization | Multi-stage Docker (Dockerfile) |
Monolithic container embedding React build into Spring Boot |
| Deployment | Render | Hosted full-stack web service |
Client Browser (HTTPS)
│
▼
Spring Boot Service (Render / Docker on Port 8080)
├── 🌐 Serves React Static UI (/src/main/resources/static)
└── 🔌 Exposes REST API (/api/**)
│
│ JPA / Hibernate (PostgreSQL Connection)
▼
Neon Cloud PostgreSQL Database
PollingApp/
├── backend/ # Spring Boot Backend
│ ├── pom.xml # Maven dependencies & plugins
│ ├── .env.example # Backend environment template
│ └── src/
│ ├── main/
│ │ ├── java/com/pollingapp/
│ │ │ ├── config/ # Security, CORS & Web forwarder config
│ │ │ ├── controller/ # REST API endpoints (Auth, Poll, Comment, Vote)
│ │ │ ├── dto/ # Request & Response DTOs
│ │ │ ├── entity/ # JPA Entities (User, Poll, Option, Vote, Comment)
│ │ │ ├── exception/ # Custom exceptions & global exception handler
│ │ │ ├── repository/ # Spring Data JPA repositories
│ │ │ ├── security/ # JWT Token provider, filter & UserDetailsService
│ │ │ └── service/ # Business logic implementations
│ │ └── resources/
│ │ ├── application.properties # Production PostgreSQL configuration
│ │ └── application-local.properties # Local in-memory H2 profile
│ └── test/ # Integration and unit tests
├── frontend/ # React + Vite Frontend
│ ├── package.json # Frontend dependencies & scripts
│ ├── vite.config.js # Vite configuration
│ ├── .env.example # Frontend environment template
│ ├── index.html # HTML entry point
│ └── src/
│ ├── components/ # UI components (Navbar, PollCard, ProtectedRoute)
│ ├── pages/ # Pages (Dashboard, CreatePoll, Login, Register, MyPolls)
│ ├── services/ # API services (authService, pollService)
│ └── utils/ # JWT token & auth helpers
├── Dockerfile # Multi-stage Docker build (React + Spring Boot combined)
├── API.md # Complete REST API documentation
├── LICENSE # MIT License
├── README.md # Project documentation
└── .gitignore # Git ignore rules
| Variable | Description | Example |
|---|---|---|
SPRING_DATASOURCE_URL |
PostgreSQL JDBC Connection URL | jdbc:postgresql://<host>:5432/<dbname>?sslmode=require |
SPRING_DATASOURCE_USERNAME |
Database username | <neon-username> |
SPRING_DATASOURCE_PASSWORD |
Database password | <neon-password> |
SPRING_DATASOURCE_DRIVER_CLASS_NAME |
PostgreSQL driver | org.postgresql.Driver |
JWT_SECRET |
Secret key for JWT token signing | yourSecretKeyForPollingAppThatIsLongEnough123 |
JWT_EXPIRATION |
Token expiration time (ms) | 86400000 (24 hours) |
- Java JDK 17 or 21: Download Adoptium
- Maven 3.8+: Download Maven
- Node.js 18+ & npm: Download Node.js
- Git: Download Git
git clone https://github.com/prabhakar111ji/PollingApp.git
cd PollingAppcd backend
mvn spring-boot:run -Dspring-boot.run.profiles=local- Backend API:
http://localhost:8080/api - H2 Database Console:
http://localhost:8080/h2-console(JDBC URL:jdbc:h2:mem:poll_db, User:sa, Password: empty)
cd frontend
npm install
npm run dev- Frontend App:
http://localhost:5173
The project uses a monolithic multi-stage Dockerfile that builds both the React frontend and Spring Boot backend into a single container:
-
Database (Neon):
- Create a free PostgreSQL database on Neon.tech.
- Copy the PostgreSQL connection credentials.
-
Web Service (Render):
- Create a new Web Service on Render.com and connect this repository.
- Choose runtime Docker and branch main.
- Under Environment Variables, set:
SPRING_DATASOURCE_URL=jdbc:postgresql://<neon-host>:5432/<dbname>?sslmode=requireSPRING_DATASOURCE_USERNAME=<your-neon-username>SPRING_DATASOURCE_PASSWORD=<your-neon-password>SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.DriverJWT_SECRET=yourRandomSecretKey
- Click Deploy Web Service.
Complete REST API specifications and request/response payloads: 👉 View Complete API Documentation (API.md)
POST /api/auth/signup— Register a new accountPOST /api/auth/login— Login and receive JWT tokenGET /api/user/poll— Fetch all pollsPOST /api/user/poll— Create a new poll (Authenticated)GET /api/user/poll/{id}— Get single poll details with commentsGET /api/user/poll/my— Get user's created polls (Authenticated)DELETE /api/user/poll/{id}— Delete a poll by ID (Owner only)POST /api/user/poll/vote— Cast a vote (Authenticated)POST /api/user/poll/{id}/like— Toggle like/unlike (Authenticated)POST /api/user/poll/comment— Add comment (Authenticated)GET /api/health— Backend health check
This project is open-source and available under the MIT License.