# Natours – Tour Booking API & Backend
Natours is a Node.js and Express backend application that provides a complete RESTful API for managing tours, users, reviews, and bookings.
It is designed as a learning / portfolio project to practice building production-ready backends with authentication, authorization, advanced data querying, and secure deployment techniques.
---
## ? Features
- **Authentication & Authorization**
- User sign-up, login, logout
- JWT-based authentication
- Role-based access control (e.g. `user`, `guide`, `lead-guide`, `admin`)
- Password reset via email token (if configured)
- **Users Management**
- Create / read / update user profile
- Change password
- Upload and update user photos (if configured)
- Deactivate account (soft delete)
- **Tours Management**
- CRUD operations on tours (admin / lead-guide only)
- Tour filtering, sorting, field limiting, and pagination
- Aggregation pipelines (stats, monthly plan, etc.)
- Geospatial queries (tours within distance, distances to tours) – if implemented
- **Reviews & Ratings**
- Users can create reviews for tours they have booked
- Ratings, average ratings per tour, and review count
- CRUD operations on reviews (with proper permission checks)
- **Security & Best Practices**
- Data sanitization (NoSQL injection, XSS protection)
- Rate limiting on API
- Helmet for setting secure HTTP headers
- Prevent parameter pollution
- Robust global error handling
- **Environment-Based Configuration**
- Development vs production configs
- Logging for development
- Configurable environment variables for DB, JWT, email, etc.
> ? Note: Some of the above features depend on how you configured the project. Feel free to remove or add any bullets that don’t match your implementation.
---
## ? Tech Stack
- **Runtime:** Node.js
- **Framework:** Express.js
- **Database:** MongoDB (+ Mongoose ODM)
- **Authentication:** JSON Web Tokens (JWT)
- **Other:** Nodemailer (if email used), multer/sharp (if image upload used), etc.
---
## ? Project Structure
A typical structure for this project looks like:
```bash
natours/
├─ dev-data/ # Sample data (JSON) for import
├─ public/ # Static assets (if any)
├─ src or root files
│ ├─ app.js # Express app configuration
│ ├─ server.js # Server start file
│ ├─ controllers/ # Route handlers (tours, users, auth, reviews, bookings)
│ ├─ models/ # Mongoose models (Tour, User, Review, Booking, etc.)
│ ├─ routes/ # Express route definitions
│ ├─ utils/ # Helpers (APIFeatures, email, error classes, etc.)
│ └─ config/ # Config files (optional)
└─ package.json