A scalable RSVP service that allows multiple users to RSVP for events with limited or unlimited seating. This service is built using modern web technologies and follows best practices for scalability, maintainability, and performance.
- RSVP.now
RSVP.now is a backend service designed to manage RSVPs for events. It supports features like creating, updating, and canceling RSVPs, as well as managing event capacities. The service is built with scalability and flexibility in mind, allowing for both limited and unlimited seating events.
- Create or Update RSVPs: Users can RSVP for events or update their RSVP status (
Yes
,No
,Maybe
). - Cancel RSVPs: Users can cancel their RSVPs.
- Event Management: Admins can create events with optional capacity limits.
- RSVP Counts: Retrieve counts of RSVP statuses (
Yes
,No
,Maybe
) for an event. - Dynamic Capacity Management: Supports events with limited or unlimited seating.
- Error Handling: Comprehensive error handling for invalid inputs and server errors.
- Node.js: JavaScript runtime for building scalable server-side applications.
- Express.js: Web framework for building RESTful APIs.
- PostgreSQL: Relational database for storing event and RSVP data.
- TypeScript: Strongly typed JavaScript for better code quality and maintainability.
- dotenv: For managing environment variables.
- pg: PostgreSQL client for Node.js.
- ts-node: For running TypeScript directly in development.
- nodemon: For automatic server restarts during development.
- ESLint: For linting and enforcing code quality.
- Postman: For API testing and documentation.
- Events can have a fixed capacity or unlimited seating (
capacity = null
). - This flexibility allows the service to handle a wide range of use cases, from small private events to large public gatherings.
- Database operations for creating or updating RSVPs are wrapped in transactions to ensure data consistency, especially when dealing with capacity constraints.
- The service is designed to scale horizontally by using stateless RESTful APIs and a relational database.
- Comprehensive error handling ensures that invalid inputs and server errors are gracefully managed, providing meaningful feedback to the client.
- TypeScript is used throughout the project to enforce type safety, reducing runtime errors and improving developer productivity.
- Endpoint:
POST /api/rsvp
- Description: Create a new RSVP or update an existing RSVP for a user.
- Request Body:
{ "eventId": 1, "userId": 101, "status": "No" }
- Response:
{ "message": "RSVP created or updated successfully" }
- Endpoint:
DELETE /api/rsvp
- Description: Cancel an existing RSVP for a user.
- Request Body:
{ "eventId": 1, "userId": 101 }
- Response:
{ "message": "RSVP canceled successfully" }
- Endpoint:
POST /api/event
- Description: Create a new event.
- Request Body:
{ "name": "Tech Conference", "capacity": 100 }
- Response:
{ "message": "Event created successfully" }
- Endpoint:
GET /api/event/:eventId/rsvp-counts
- Description: Retrieve counts of RSVP statuses (
Yes
,No
,Maybe
) for an event. - Response:
{ "yes": 10, "no": 5, "maybe": 3 }
- Endpoint:
GET /api/rsvps
- Description: Retrieve a list of all RSVPs.
- Response:
[ { "id": 1, "eventId": 1, "userId": 101, "status": "Yes" }, { "id": 2, "eventId": 1, "userId": 102, "status": "No" } ]
- Node.js (version 14 or higher)
- PostgreSQL database
To get started with the project:
- Clone the repository
git clone <repository-url>
- Navigate to the project directory:
cd RSVP.now/rsvp-service
- Install dependencies:
npm install
- Set up the .env file:
DATABASE_URL=postgresql://<username>:<password>@localhost:5432/rsvp_service
PORT=3000
-
Run database migrations to set up the schema.
-
Start the server:
npm run dev
Column | Type | Description |
---|---|---|
id |
Integer | Primary key |
name |
String | Name of the event |
capacity |
Integer | Maximum capacity (nullable) |
Column | Type | Description |
---|---|---|
id |
Integer | Primary key |
event_id |
Integer | Foreign key referencing events.id |
user_id |
Integer | ID of the user |
status |
String | RSVP status (Yes , No , Maybe ) |
Use Postman or the provided Postman collection (rsvp-service_collection.json
) to test the APIs.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.