CTH Hub API is the backend service powering the CTH Hub Frontend .
It provides RESTful APIs to manage hotel rates, contacts (travel agents & customers), staff, users, user roles, inventory, and real-time analytics.
Hotel & Rates Management
CRUD operations for hotels and hotel rates
PDF uploads for rate files, automatically parsed into structured entries
Contacts Management
CRUD operations for travel agents and customer details
Bulk upload via CSV/Excel for faster data entry
Staff & User Management
CRUD operations for staff, users and user roles
Role-based access control (admin/staff/users)
Authentication & authorization
Inventory Management
Track and manage (CRUD) hotel inventory items and categories
Supports bulk uploads and real-time inventory updates
Analytics and Reporting
Real-time aggregated insights for bookings, rates, and stock levels
Logs all operations for error tracking and debugging using Winston
API & Integration
Fully RESTful JSON-based API endpoints for seamless frontend integration.JSON-based endpoints for seamless frontend integration
Environment-based configuration for database connection and API URLs ensures a secure and flexible deployment
Backend Framework : Node.js + Express (JavaScript)
Database : MongoDB (Mongoose ODM)
Auth : JWT-based authentication & role-based permissions
File Handling : Multer for uploads (PDF/CSV/Excel)
Validation : Joi (schema validation)
Logging : Winston
Code Quality & Formatting : ESLint + Prettier
Development Tools : Nodemon (auto-reload during development)
Deployment : Render
controllers/ # Route handlers containing business logics
models/ # MongoDB schemas
routes/ # API route definitions
middlewares/ # Authentication, validation, error handlers
services/ # Business logic services
config/ # Environment and app configuration (DB connection, logger)
.eslintrc.json # ESLint configuration
.prettierrc # Prettier configuration
.env # Environmennt variables
index.js # Application entry point
Node.js v18+
npm v9+
MongoDB (Atlas or local instance)
git clone https://github.com/< your-username> /cth-hub-api.git
cd cth-hub-api
3. Create a .env file at the root:
API_URL=api/v1
MONGODB_URI=< Your MongoDB Connection URI>
PORT=5000
4. Start the development server:
http://localhost:5000/api/v1/
Linting : npm run lint
Code formatting : npm run format
Logging via Winston : console logs and file logs at logs/
Make sure MongoDB Atlas allows your IP or use a local MongoDB connection
Server port can be configured via .env (PORT)
API routes are prefixed with the API_URL environment variable (api/v1)