https://github.com/sd-project-2025/ireserve-backend
API Docs
https://github.com/sd-project-2025/ireserve-backend
express-js nodejs seqelize swagger-ui swagger3
Last synced: 27 days ago
JSON representation
API Docs
- Host: GitHub
- URL: https://github.com/sd-project-2025/ireserve-backend
- Owner: SD-Project-2025
- Created: 2025-04-09T20:09:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-23T13:33:44.000Z (about 1 year ago)
- Last Synced: 2025-05-23T15:06:13.984Z (about 1 year ago)
- Topics: express-js, nodejs, seqelize, swagger-ui, swagger3
- Language: JavaScript
- Homepage: https://isereserve-backend.azurewebsites.net/api-docs
- Size: 172 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://codecov.io/gh/SD-Project-2025/iReserve-backend)
# iReserve-backend
**iReserve API**
A RESTful API for managing community sports facilities, bookings, maintenance reports, events, and notifications.
---
## ๐ Features
- ๐ง๐ผ **User Authentication**: Google OAuth integration with JWT token management
- ๐๏ธ **Facility Management**: CRUD operations for sports facilities (Admin/Staff only)
- ๐
**Booking System**: Residents can book facilities with availability validation
- ๐ ๏ธ **Maintenance Reporting**: Submit and track maintenance requests (Residents) with status updates (Staff/Admin)
- ๐ **Event Management**: Create and manage community events with resident registration
- ๐ **Notifications**: Real-time updates for bookings, maintenance, and events
- ๐ **Role-Based Access Control**:
- Admin: Full system control
- Staff: Facility/event management and report handling
- Resident: Booking, reporting, and event registration
---
## ๐ ๏ธ Tech Stack
- **Backend**: Node.js, Express.js
- **Database**: PostgreSQL (with Sequelize ORM)
- **Authentication**: Google OAuth 2.0, JWT
- **API Documentation**: Swagger/OpenAPI 3.0
- **Testing**: Jest (Unit & Integration), Supertest
- **CI/CD**: GitHub Actions (Add status badge if implemented)
- **Hosting**: [Specify if deployed e.g., AWS EC2, Heroku]
---
## ๐ฆ Getting Started
### โ
Prerequisites
- Node.js v16+
- PostgreSQL 14+ (or Neon Tech PostgreSQL)
- Google OAuth credentials
### โ๏ธ Environment Variables
Create `.env` file using `.env.example` with these required variables:
```ini
PORT=5000
DATABASE_URL=postgres://user:pass@host:port/dbname
JWT_SECRET=your_jwt_secret
GOOGLE_CLIENT_ID=your_google_id
GOOGLE_CLIENT_SECRET=your_google_secret
```
### ๐ฅ Installation
```bash
# Clone repository
git clone https://github.com/SD-Project-2025/iReserve-backend.git
cd iReserve-backend
# Install dependencies
npm install
# Initialize database (ensure PostgreSQL is running)
npm run migrate
# Start development server
npm run dev
```
---
## ๐ API Documentation
Interactive API documentation available via Swagger UI:
http://localhost:5000/api-docs
---
## ๐ Authentication Endpoints
| Endpoint | Method | Description | Roles |
|----------|--------|-------------|-------|
| `/api/v1/auth/google` | POST | Google OAuth login/registration | All |
| `/api/v1/auth/me` | GET | Get current user profile | All |
| `/api/v1/auth/address` | PUT | Update resident address | Resident |
| `/api/v1/auth/logout` | POST | Invalidate JWT token | All |
---
## ๐๏ธ Facility Endpoints (Admin/Staff Restricted)
| Endpoint | Method | Description | Roles |
|----------|--------|-------------|-------|
| `/api/v1/facilities` | POST | Create new facility | Admin/Staff |
| `/api/v1/facilities/:id` | PUT | Update facility details | Admin/Staff |
| `/api/v1/facilities/:id` | DELETE | Delete facility | Admin |
| `/api/v1/facilities/:id/staff` | POST | Assign staff to facility | Admin |
| `/api/v1/facilities/:id/staff` | GET | View assigned staff | Admin/Staff |
---
## ๐
Booking Endpoints
| Endpoint | Method | Description | Roles |
|----------|--------|-------------|-------|
| `/bookings` | GET | List all bookings | Admin/Staff |
| `/bookings/my-bookings` | GET | Get user's bookings | Resident |
| `/bookings` | POST | Create new booking | Resident |
| `/bookings/:id/status` | PUT | Update booking status | Admin/Staff |
| `/bookings/:id/cancel` | PUT | Cancel booking | Resident |
---
## ๐ ๏ธ Maintenance Endpoints
| Endpoint | Method | Description | Roles |
|----------|--------|-------------|-------|
| `/maintenance` | GET | List all reports | Admin/Staff |
| `/maintenance/my-reports` | GET | Get user's reports | Resident |
| `/maintenance` | POST | Submit new report | Resident |
| `/maintenance/:id/status` | PUT | Update report status | Admin/Staff |
---
## ๐ Event Endpoints
| Endpoint | Method | Description | Roles |
|----------|--------|-------------|-------|
| `/api/v1/events` | POST | Create new event | Admin/Staff |
| `/api/v1/events/:id` | PUT | Update event details | Admin/Staff |
| `/api/v1/events/:id` | DELETE | Delete event | Admin/Staff |
| `/api/v1/events/:id/register` | POST | Register for event | Resident |
| `/api/v1/events/:id/cancel-registration` | PUT | Cancel registration | Resident |
---
## ๐ Notification Endpoints
| Endpoint | Method | Description | Roles |
|----------|--------|-------------|-------|
| `/api/v1/notifications` | GET | Get user notifications | All |
| `/api/v1/notifications/:id/read` | PUT | Mark notification as read | All |
| `/api/v1/notifications/read-all` | PUT | Mark all as read | All |
| `/api/v1/notifications/:id` | DELETE | Delete notification | All |
---
## ๐งช Testing
```bash
# Run full test suite
npm test
# Generate coverage report (outputs to /coverage)
npm run test:coverage
# Test specific module
npm test -- facilities.test.js
```
---
**Requirements**:
- Write tests for new features
- Integrate better code coverage (80%+)
- Update Swagger documentation
- Follow ESLint coding standards
---