Skip to content

SymonMuchemi/DevCamper-API

Repository files navigation

DevCamper API

Table of Contents

Description

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.

Features

  • 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

Technologies

Installation

  1. Clone the repository
git clone https://github.com/SymonMuchemi/DevCamper-API.git
  1. Install dependencies
npm install
  1. 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'
  1. Populate the database with data
node seeder -i
  1. Run the server
npm start
  1. Access the application on http://localhost:3001/

API Documentation

Infrastructure Design

Devcamper Infrastructure Design Diagram

Infrastructure Details

VPC and Subnets

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.

Components

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.

Data Flow

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.

Network Security

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.

Author

About

A secure high performance platform for bootcamps, courses, reviews and users.

Topics

Resources

Stars

Watchers

Forks