DevCamper is a RESTful API that provides a platform for bootcamps, courses, reviews and users. It allows users to create, read, update and delete bootcamps, courses, reviews and users. The API also provides user authentication and authorization, password encryption, image upload, geocoding, pagination, filtering, sorting, querying, custom error handling middleware, rate limiting, cross-origin resource sharing (CORS), security headers, helmet, XSS protection, HPP protection, sanitization and logging. The API is documented using Postman.
- Full CRUD functionality for bootcamps, courses, reviews and users
- User authentication and authorization
- Password encryption
- Image upload
- Geocoding
- Pagination, filtering, sorting and querying
- Custom error handling middleware
- Rate limiting
- Cross-origin resource sharing (CORS)
- Security headers
- Helmet
- XSS protection
- HPP protection
- Sanitization
- Logging
- API documentation
- AWS EC2: for deployment.
- Node.js - JavaScript runtime
- Express - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling tool
- JWT: Secure user authentication.
- bcryptjs: Password encryption.
- express-fileupload: File upload.
- node-geocoder: Geocoding.
- express-mongo-sanitize: Sanitization.
- helmet: Security headers.
- hpp: HTTP parameter pollution protection.
- Clone the repository
git clone https://github.com/SymonMuchemi/DevCamper-API.git
- Install dependencies
npm install
- Create a .env file in the root directory and add the following
PORT=3001
MONGO_URI='your_mongo_uri'
JWT_COOKIE_EXPIRE='30d'
JWT_SECRET='your_jwt_secret'
JWT_EXPIRE='30d'
GEOCODER_PROVIDER='mapquest'
GEOCODER_API_KEY='your_geocoder_api_key'
REDIS_SET_EXPIRE=3600
REDIS_HOST='localhost'
REDIS_PORT='6379'
REDIS_PASSWORD='your_redis_password'
- Populate the database with data
node seeder -i
- Run the server
npm start
- Access the application on
http://localhost:3001/
- Local documentation: http://localhost:3001/
- Live documentation: link
- Postman Published Documentation: https://documenter.getpostman.com/view/33408943/2sAYkBsghW
DevCamper VPC: The entire infrastructure is contained within a Virtual Private Cloud (VPC).
Public Subnet (10.0.0.0/24): Contains resources that need to be accessible from the internet.
Private Subnet (10.0.2.0/24): Contains resources that do not need to be directly accessible from the internet.
Web Server (Public Subnet)
- Handles HTTP requests from users.
- Interacts with the Redis cache for reading cached data and writing cache/stream data.
- Interacts with the NoSQL database for reading uncached data and writing new data, updates, or deletions.
Redis Cache (Private Subnet)
- Acts as a caching layer to store frequently accessed data.
- Also used for writing to the mail stream.
Mail Stream (Private Subnet)
- A stream of email messages that need to be processed.
- Written to by the web server and read by the mail worker.
Mail Worker (Private Subnet)
- Reads from the mail stream.
- Processes email messages and sends them to users.
NoSQL Database (Private Subnet)
- Stores application data that is not cached.
- Interacts with the web server for reading and writing data.
User Interaction
- A user sends an HTTP request to the web server.
Web Server Operations
- The web server processes the request.
- It may read cached data from Redis.
- It writes data to the Redis cache and the mail stream.
- It reads uncached data from the NoSQL database.
- It writes new data, updates, or deletions to the NoSQL database.
Mail Stream Processing
- The mail worker reads from the mail stream.
- Processes the email messages and sends them to the user.
Response to User
- The web server sends an HTTP response back to the user.
Public Subnet: Accessible from the internet, allowing users to interact with the web server.
Private Subnet: Isolated from direct internet access, ensuring that Redis, the mail worker, and the NoSQL database are secure.