Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Polling App

Project Overview

This is a modern polling application built with React, TypeScript, Redux Toolkit, React Router DOM, and Firebase. It supports authentication, protected routing, poll creation, voting, and a polished dashboard experience.

The app uses a visually rich glassmorphism theme with responsive layouts and animated UI accents.


Tech Stack

  • React.js
  • TypeScript
  • Redux Toolkit
  • React Router DOM
  • Firebase Authentication
  • Firebase Firestore
  • Vite
  • Tailwind CSS

Features

  • Email/password Login
  • User Signup and registration
  • Secure Logout
  • Protected routing for authenticated pages
  • Redux state management for auth and polls
  • Dashboard showing active polls and summary metrics
  • Create Poll page for new poll creation
  • Poll Details page with voting
  • Delete poll only for creator
  • Real-time Firestore updates for polls
  • Responsive design across mobile and desktop

Requirements Covered

  1. Login
  2. Signup
  3. Logout
  4. Routing
  5. Redux
  6. Ant Design (intended UI library; current styling uses Tailwind CSS and custom theme)
  7. TypeScript
  8. React.js
  9. Firebase

Installation

1. Install dependencies

cd polling-app
npm install

2. Configure Firebase

Create a Firebase project and enable Email/Password authentication.

Create a Firestore database and set up your config values.

3. Add Firebase config

Open src/firebase/config.ts and update the configuration:

const firebaseConfig = {
  apiKey: 'YOUR_API_KEY',
  authDomain: 'YOUR_PROJECT_ID.firebaseapp.com',
  projectId: 'YOUR_PROJECT_ID',
  storageBucket: 'YOUR_PROJECT_ID.appspot.com',
  messagingSenderId: 'YOUR_MESSAGING_SENDER_ID',
  appId: 'YOUR_APP_ID',
};

4. Run the app

npm run dev

Open the local URL shown by Vite.


Firebase Setup

Enable these Firebase features:

  • Firebase Authentication: Email/Password
  • Firestore Database

Recommended Firestore rules:

  • authenticated users can read/write their own profile
  • authenticated users can create polls
  • poll deletion only by creator
  • one vote per user per poll

App Routes

  • / - Login page
  • /signup - Signup page
  • /polls - Dashboard (protected)
  • /create - Create Poll (protected)
  • /poll/:id - Poll Details (protected)

Redux Slices

authSlice

Manages:

  • current user state
  • authentication loading state
  • login/signup/logout actions

pollsSlice

Manages:

  • polls list
  • poll loading state
  • poll error state

Poll Data Structure

Each poll includes:

  • question
  • options
  • creator ID
  • creator name
  • created timestamp

Example Firestore document:

{
  id: string,
  question: string,
  options: string[],
  createdBy: string,
  createdByName: string,
  createdAt: Timestamp,
}

Voting Behavior

  • Users can vote once per poll
  • Votes are stored in Firestore
  • Vote totals and percentages update live
  • Poll creator can delete their poll

Build

npm run build

The app should compile successfully and produce a production build.


Notes

This README captures the project requirements and main implementation details. If you want, I can also add a dedicated section for deployment and Firebase security rules.

  • Create Poll
  • Delete Poll

votesSlice

Manage:

  • Votes
  • Percentages
  • User Vote

Routing

/
Login

/signup
Signup

/polls
Poll Dashboard

/create
Create Poll

/poll/:id
Poll Details

Protect authenticated routes.

Unauthenticated users should be redirected to Login.


UI Requirements

Login Page

  • Email
  • Password
  • Login Button
  • Link to Signup

Signup Page

  • Name
  • Email
  • Password
  • Signup Button

Dashboard

Display:

  • Create Poll Button
  • List of Polls

Create Poll Page

Inputs:

  • Question
  • Option 1
  • Option 2
  • Option 3
  • Option 4
  • Correct Answer (Dropdown)

Create Button


Poll Details

Display:

  • Question
  • Four options

After voting:

  • Green correct answer
  • Red incorrect answers
  • Vote percentages

Firebase Collections

users
polls
votes

Security Rules

Users:

  • Can read all users.
  • Can only edit their own profile.

Polls:

  • Any authenticated user can create.
  • Only creator can delete.

Votes:

  • One vote per user per poll.
  • Users cannot modify another user's vote.

Folder Structure

src/
│
├── app/
│   └── store.ts
│
├── components/
│
├── pages/
│   ├── Login
│   ├── Signup
│   ├── Dashboard
│   ├── CreatePoll
│   └── PollDetails
│
├── redux/
│   ├── authSlice.ts
│   ├── pollsSlice.ts
│   └── votesSlice.ts
│
├── firebase/
│   └── config.ts
│
├── hooks/
│
├── services/
│
├── types/
│
├── utils/
│
└── App.tsx

Additional Requirements

  • Use TypeScript throughout the project.
  • Follow clean code principles.
  • Build reusable React components.
  • Use Redux Toolkit for global state management.
  • Handle loading and error states gracefully.
  • Ensure the application is responsive across desktop, tablet, and mobile devices.
  • Use Firestore real-time listeners instead of manual polling.
  • Maintain consistent code formatting and project structure.

Deliverables

The generated project should include:

  • Complete React application
  • TypeScript support
  • Firebase Authentication
  • Firestore integration
  • Redux Toolkit implementation
  • Protected routes
  • Responsive UI
  • Real-time poll updates
  • Clean folder structure
  • Reusable components
  • Well-commented, maintainable code
  • Ready-to-run project with clear setup instructions

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages