Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛠️ StudyNook Server

A clean and lightweight Node.js + Express API for StudyNook — a modern study-room booking platform.

Live API Server Source Client Source Live Demo


✨ What is StudyNook Server?

StudyNook Server is the backend API powering the StudyNook platform. It handles room listings, booking management, conflict detection, and JWT-based authentication — all deployed serverlessly on Vercel with MongoDB as the database.


🔗 Project Links

Type Link
🚀 Live API Server study-nook-server-nine.vercel.app
🌐 Live Client studynook-zeta.vercel.app
🛠️ Server Repository github.com/Saharier36/studynook-server
💻 Client Repository github.com/Saharier36/studynook-client

🚀 Highlights

Feature Description
🏠 Room Management Browse, search, filter, create, update, and delete rooms
📅 Booking System Create bookings with automatic conflict detection
🔐 Authentication JWT verification using remote JWKS
👤 Owner Listings Fetch and manage listings by authenticated users
🛡️ Security Protected routes with CORS configured for secure cross-origin requests
☁️ Serverless Production-grade deployment on Vercel with MongoDB integration

🛠️ Tech Stack

Category Technology
Runtime Node.js 18+
Framework Express.js
Database MongoDB
Authentication JWT + JWKS
Middleware CORS, dotenv
Deployment Vercel (Serverless)

📚 API Endpoints

🏠 Rooms

Method Route Description Auth
GET /rooms Get all rooms (supports search & amenities query params) Public
GET /rooms/:id Get single room with booking count Public
GET /featured-rooms Get up to 6 featured rooms Public
POST /rooms Create a new room 🔒 Protected
PATCH /rooms/:id Update a room 🔒 Protected
DELETE /rooms/:id Delete a room 🔒 Protected

📅 Bookings

Method Route Description Auth
POST /booking Create a booking (with conflict detection) 🔒 Protected
GET /bookings Get bookings (supports userId query param) Public
PATCH /booking/:id/cancel Cancel a booking 🔒 Protected

👤 Owner

Method Route Description Auth
GET /my-listings Get listings by the authenticated user 🔒 Protected

❤️ Health Check

Method Route Description
GET / Server status check

🔒 Protected Routes

All protected routes require a Bearer token in the Authorization header:

Authorization: Bearer YOUR_TOKEN_HERE

Protected routes: POST /rooms, PATCH /rooms/:id, DELETE /rooms/:id, POST /booking, PATCH /booking/:id/cancel, GET /my-listings


⚙️ Environment Variables

Create a .env file in the root directory:

PORT=5000
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<database>
CLIENT_URL=http://localhost:3000
Variable Type Description Example
PORT Number Server listening port 5000
MONGODB_URI String MongoDB connection string mongodb+srv://...
CLIENT_URL String Frontend URL for JWKS verification http://localhost:3000

🏁 Getting Started

1. Clone the repository

git clone https://github.com/Saharier36/studynook-server
cd studynook-server

2. Install dependencies

npm install

3. Run locally

npm run dev

Then open: http://localhost:5000


📦 Available Scripts

Script Description
npm run dev Start development server
npm start Run production server

📁 Project Structure

study-nook-server/
├── index.js           # Main Express server & all API routes
├── package.json       # Dependencies & scripts
├── vercel.json        # Vercel deployment configuration
└── README.md          # Project documentation

📦 Dependencies

Package Version
express ^5.2.1
mongodb ^7.2.0
cors ^2.8.6
dotenv ^17.4.2
jose-cjs ^6.2.3

🌍 Deployment

The project is ready for Vercel deployment with the included vercel.json.

  • Entry file: index.js
  • Serverless handler: @vercel/node
  • Collections used: rooms, bookings, user

StudyNook Server is built for reliability — with conflict-safe bookings, secure JWT auth, and a clean REST API design.

About

Backend of StudyNook - Library Study Room Booking System.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages