Welcome to the Tour Connect backend! This is a robust Express.js & MongoDB-powered REST API designed for managing and organizing guided tours. It features full CRUD operations, detailed Swagger API documentation, and advanced logging capabilities. The backend is built with Node.js, Express.js, and MongoDB, and comes with a beautiful vanilla front-end to interact directly with the API.
- 🚀 RESTful Architecture:
- 📖 Swagger UI Documentation:
- 💾 MongoDB Integration:
- 📝 Advanced Logging:
- 🎨 Built-in Dashboard:
- Runtime Environment: Node.js
- Framework: Express.js
- Database: MongoDB & Mongoose
- API Documentation: Swagger UI Express & swagger-jsdoc
- Logging: Morgan
- Testing: Jest & Supertest
- Environment Variables: dotenv
- Frontend: Vanilla HTML, CSS, and JavaScript
- Schema Validation: Joi
📦 tour-connect-backend
┣ 📂 config # Logging and configuration files (e.g., logger.js)
┣ 📂 controllers # Core business logic methods for different routes
┣ 📂 middlewares # Express middleware functions
┣ 📂 models # Mongoose schemas representing database collections
┣ 📂 postman # Postman collection for testing
┣ 📂 public # Frontend assets (HTML, CSS, JS dashboard)
┣ 📂 routes # Express router setups mapping URLs to controllers
┣ 📂 swagger # Swagger configuration and implementation definitions
┣ 📂 tests # Unit tests
┣ 📂 utils # Utilities, e.g., dummy tour generation script
┣ 📂 validators # Validation logic for request data
┣ 📜 app.js # Express application setup, middlewares, and mounting
┣ 📜 index.js # Entry point that connects to DB and starts the server
┗ 📜 package.json # Dependencies and project scripts
Make sure you have the following installed on your machine:
- Node.js: v20.0.0 or higher
- MongoDB: Locally installed or access to a MongoDB Atlas cluster URI
1. Clone the repository
git clone https://github.com/your-username/tour-connect-backend.git
cd tour-connect-backend2. Install dependencies
npm install3. Configure Environment Variables
Create a .env file in the root directory and add:
PORT=3000
MONGO_URI=your_mongodb_connection_string
BASE_URL=http://localhost:30004. Run the application For development (uses nodemon to auto-restart):
npm run devFor production:
npm startThe server will be running normally on http://localhost:3000.
The base API route path is /tour.
| Method | Endpoint | Description |
|---|---|---|
| GET | /tour |
Fetch all available tours |
| POST | /tour |
Create a new tour |
| GET | /tour/:id |
Fetch a specific tour by its ID |
| PUT | /tour/:id |
Update a specific tour fully |
| DELETE | /tour/:id |
Delete a specific tour from the DB |
This project makes API testing and implementation simple using a built-in Swagger interface. Once the server is running, navigate to:
👉 http://localhost:3000/api-docs
Here, you can learn about expected request bodies and schema requirements, and natively execute requests to test response states.
This project features a neatly-styled built-in Vanilla frontend to easily test API endpoints visually. Start the server and immediately open your browser, navigating to:
You'll see a dashboard interface featuring:
- All Tours fetcher
- Fetch Tour for a specific tour
- Create Tour with all details
- Update Tour information
- Delete Tour for a specific tour
All HTTP requests hitting the server endpoints are logged using morgan library.
Crafted with ❤️ by Durga Prasad Kar