A real-time leaderboard application built with Express.js backend and vanilla JavaScript frontend, using Redis for data storage.
- Add players with their timing scores
- Real-time leaderboard display (auto-refreshes every 3 seconds)
- Persistent data storage with Redis
- REST API backend
- Simple HTML/CSS frontend
- Node.js (v14+)
- Redis running locally or in Docker
- npm
npm installIn your terminal type in the following
docker run -d --name redis-stack -p 6379:6379 redis/redis-stack:latestIn the container section, you should see a container running in the background
npx nodemon app.jsThe backend will run on http://localhost:3000
Open frontend/index.html in your browser
You can try the following PUT and GET requests in postman
PUT /leaderboard/update
{
"player": "John",
"timing": 45.2
}GET /leaderboard/rank
Response:
{
"success": true,
"data": [
{"player": "John", "timing": "45.2"},
{"player": "Jane", "timing": "48.5"}
]
}Access the Redis database visually:
http://localhost:8001
You can see all stored data, including the leaderboard:yeetcode key with player data.
leaderboard/
├── app.js # Express backend
├── package.json
├── .env # Environment variables
├── frontend/
│ ├── index.html # Main HTML file
│ ├── script.js # JavaScript logic
│ └── style.css # Styling
└── README.md
- Backend: Express.js, Node.js
- Database: Redis (ioredis)
- Frontend: HTML, CSS, JavaScript (Vanilla)
- CORS: Enabled for frontend-backend communication
ISC