A full-stack polling application similar to Twitter polls, built with React, Spring Boot, Spring Security, JWT authentication, and PostgreSQL.
Production URL: https://polling-app-z854.onrender.com
The app is hosted on Render's free tier. The first request may take about 30 seconds if the service has spun down due to inactivity.
| Login Page | Create Poll |
|---|---|
![]() |
![]() |
| Voting Page | Dashboard |
|---|---|
![]() |
![]() |
Browser
|
| REST API (JSON)
v
React single-page app served by Spring Boot
|
v
Spring MVC controllers
|
v
Spring Security + JWT authentication
|
v
Spring Data JPA repositories
|
v
PostgreSQL
| Layer | Technology |
|---|---|
| Frontend | React 16, Ant Design 3, React Router 4 |
| Backend | Spring Boot 2.7.18, Spring MVC, Spring Data JPA |
| Security | Spring Security, JWT |
| Database | PostgreSQL |
| Build Tools | Maven, npm |
| Deployment | Render Blueprint, Docker multi-stage build |
- User signup and login with JWT-based authentication
- Poll creation with up to 6 choices and configurable expiration
- Voting on active polls, limited to one vote per user per poll
- Poll result percentages with visual progress bars
- User profiles with created polls and voting history
- Paginated poll lists with "Load More"
- USER and ADMIN roles initialized automatically on startup
- Responsive layout for desktop and mobile browsers
Polling-App/
|-- polling-app-client/ React frontend
| |-- public/ Static template assets
| `-- src/
| |-- app/ App component and routing
| |-- common/ Shared components
| |-- constants/ App constants and API config
| |-- poll/ Poll UI components
| |-- user/ Login, signup, and profile views
| `-- util/ API utilities and helpers
|
|-- polling-app-server/ Spring Boot backend
| `-- src/main/java/com/example/polls/
| |-- config/ Security and MVC configuration
| |-- controller/ REST API controllers
| |-- exception/ Application exceptions
| |-- model/ JPA entities
| |-- payload/ Request and response DTOs
| |-- repository/ Spring Data repositories
| |-- security/ JWT and authentication components
| |-- service/ Business logic
| `-- util/ Utility classes
|
|-- Dockerfile Multi-stage production image
|-- render.yaml Render Blueprint
`-- Readme.md
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/auth/signin |
Login | No |
| POST | /api/auth/signup |
Register | No |
| GET | /api/polls |
Get all polls | No |
| POST | /api/polls |
Create a poll | Yes |
| POST | /api/polls/{pollId}/votes |
Cast a vote | Yes |
| GET | /api/user/me |
Get current user | Yes |
| GET | /api/users/{username} |
Get user profile | No |
| GET | /api/users/{username}/polls |
Get a user's polls | No |
| GET | /api/users/{username}/votes |
Get a user's votes | No |
| GET | /api/user/checkUsernameAvailability |
Check username availability | No |
| GET | /api/user/checkEmailAvailability |
Check email availability | No |
- Java 11 or newer
- Maven 3.6 or newer
- Node.js 14
- PostgreSQL 12 or newer
git clone https://github.com/Vishnusige/Polling-App.git
cd Polling-AppCREATE DATABASE polling_app;Set these values before starting the backend:
export DB_HOST=localhost
export DB_PORT=5432
export DB_NAME=polling_app
export DB_USERNAME=postgres
export DB_PASSWORD=postgres
export JWT_SECRET=replace-with-a-long-random-secretFor Windows PowerShell:
$env:DB_HOST="localhost"
$env:DB_PORT="5432"
$env:DB_NAME="polling_app"
$env:DB_USERNAME="postgres"
$env:DB_PASSWORD="postgres"
$env:JWT_SECRET="replace-with-a-long-random-secret"cd polling-app-server
mvn spring-boot:runThe backend starts on http://localhost:5000. Default roles (ROLE_USER and ROLE_ADMIN) are inserted automatically on startup.
cd polling-app-client
npm install
npm startThe development client starts on http://localhost:3000.
Build and run the production image:
docker build -t polling-app .
docker run -p 5000:5000 \
-e DB_HOST=your-db-host \
-e DB_PORT=5432 \
-e DB_NAME=polling_app \
-e DB_USERNAME=postgres \
-e DB_PASSWORD=replace-with-db-password \
-e JWT_SECRET=replace-with-a-long-random-secret \
polling-appThis app is configured for Render Blueprint deployment using render.yaml.
- Fork or connect this repository in Render.
- Create a new Blueprint from the repository and select the deployment branch.
- Render provisions a Docker web service and a PostgreSQL database.
- Database environment variables are wired from the managed PostgreSQL service.
JWT_SECRETis generated by Render.- The deployed app is available at https://polling-app-z854.onrender.com.
- The frontend is built into Spring Boot static resources during the Docker build.
- The backend serves the React app and API from the same origin.
- PostgreSQL schema management uses Hibernate
ddl-auto=update. - Role initialization is handled by
polling-app-server/src/main/resources/data.sql. - Sensitive values are supplied through environment variables.
This project is open source and available under the MIT License.



