🗳️ Vortex is a lightning-fast polling API that lets you create, manage, and analyze polls in real-time. Built with Rust for performance, secured with WebAuthn, and powered by MongoDB. Perfect for live events, classroom engagement, or gathering quick feedback! 🚀
- 🔄 Real-time Vote Tracking: Live updates using Server-Sent Events (SSE)
- 🔐 Secure Authentication: Passwordless WebAuthn authentication
- 🗃️ MongoDB Integration: Robust data persistence
- 🌐 CORS Support: Configured for cross-origin requests
- 🔑 JWT Authentication: Secure token-based authentication
⚠️ Error Handling: Comprehensive error handling system- 📊 Logging: Detailed request/response logging
-
🏗️ Clean Architecture
- 📚 Repository Pattern for data access
- 🔄 DTO Pattern for request/response handling
- 🔗 Middleware for cross-cutting concerns
- 🎯 Centralized error handling
-
🔒 Security
- 👆 WebAuthn passwordless authentication
- 🎟️ JWT for session management
- 🛡️ Protected routes
- 🌍 CORS configuration
-
⚡ Performance
- ⏱️ Async/await patterns
- 🔌 Connection pooling
- 📈 Efficient data structures
- GET
/auth/register
- Query Parameters:
{ "username": "string" }
- Response: WebAuthn registration challenge
- POST
/auth/verify-register/{username}
- Body: WebAuthn credential response
- Response:
{ "status": 200, "message": "Registration completed successfully", "token": "jwt-token" }
- GET
/auth/login
- Query Parameters:
{ "username": "string" }
- Response: WebAuthn authentication challenge
- POST
/auth/verify-login/{username}
- Body: WebAuthn authentication response
- Response:
{ "status": 200, "message": "Login successful", "user_id": "string", "token": "jwt-token", "timestamp": "string" }
- POST
/auth/logout
- Response:
{ "status": 200, "message": "Logged out successfully" }
- GET
/polls
- Response: List of all public polls
{
"status": 200,
"message": "All posts fetched successfully",
"data": [
{
"id": "string",
"title": "string",
"description": "string",
"options": [
{
"id": "string",
"text": "string",
"votes": 0
}
],
"createdBy": "string",
"createdAt": "string",
"settings": {
"isPrivate": false,
"multipleChoice": false
},
"status": "active"
}
],
"timestamp": "string",
"error": null
}
- GET
/polls/manage
- Auth: Required (Bearer token)
- Response: List of polls created by the authenticated user
- POST
/polls
- Auth: Required (Bearer token)
- Body:
{
"title": "string",
"description": "string",
"options": [
{ "text": "string" }
],
"settings": {
"isPrivate": false,
"multipleChoice": false
}
}
- GET
/polls/{poll_id}
- Response: Poll details
- PATCH
/polls/{poll_id}
- Auth: Required (Bearer token, poll owner only)
- Body:
{
"title": "string",
"description": "string",
"options": [
{ "text": "string" }
]
}
- GET
/polls/{poll_id}/vote
- Query Parameters:
{ "optionId": "string" }
- Auth: Required (Bearer token)
- GET
/polls/{poll_id}/can-vote
- Auth: Required (Bearer token)
- Response: Boolean indicating if user can vote
- GET
/polls/{poll_id}/results
- Query Parameters:
{ "live": boolean }
- Response:
- If
live=true
: Server-Sent Events stream of real-time results - If
live=false
: Current poll results
- If
- GET
/polls/{poll_id}/close
- Auth: Required (Bearer token, poll owner only)
- Response: Updated poll with status "closed"
- GET
/polls/{poll_id}/reset
- Auth: Required (Bearer token, poll owner only)
- Response: Updated poll with reset votes
-
📋 Prerequisites
- 🦀 Rust (latest stable)
- 🍃 MongoDB
-
⚙️ Environment Setup
cp .env.example .env # Configure your environment variables including JWT_SECRET
-
🏗️ Build & Run
cargo build --release cargo run
MIT License - See LICENSE file for details