Skip to content

A backend API microservice built as a project for freeCodeCamps' Backend Development and API course certification

License

Notifications You must be signed in to change notification settings

mrarvind90/fcc-backend-api-projects

Repository files navigation

freeCodeCamp Social Banner

Javascript NodeJS NPM ExpressJS MongoDB Babel ESLint Prettier

code style: prettier

Microservices with Express Application

This project is an integral component of the 'Backend Development and API' certification program offered by freeCodeCamp. For comprehensive details on each project requirement, please refer to the following links:

Timestamp Microservice
Request Header Parser Microservice
URL Shortener Microservice
Exercise Tracker Microservice
File Metadata Microservice

Design Patterns

In this project, I have chosen to implement the Model-Service-Controller (MSC) design pattern. While the project requirements do not mandate a complex design pattern, I have opted for this approach to familiarize myself with industry-standard practices and to challenge myself to grow as a developer. I acknowledge that there may be opportunities for improvement in this project, and I wholeheartedly welcome any feedback or suggestions you may have. Your input is invaluable not only for the project but also for my personal growth and development as a developer.

Setup

This project relies on MongoDB Atlas cloud instances for managing resources such as /shorturl and /users. If you intend to clone this repository and run it locally, please follow these steps:

  1. Create a MongoDB Atlas Account: To get started, you'll need to create an account on MongoDB Atlas, and the good news is, it's absolutely free! You can follow the step-by-step instructions in the MongoDB Atlas Tutorial – How to Get Started provided by freeCodeCamp to set up your own cluster.
  2. Configure Your Environment Variables: After setting up your MongoDB Atlas cluster, you'll need to configure your environment variables. To do this, rename the .env.sample file in your project directory to .env. Then, open the .env file and insert the MongoDB URI from your Atlas cluster.

Here's what it should look like:

# Database variables
MONGODB_ATLAS_URI=mongodb+srv://<MONGODB_USER>:<MONGODB_PASSWORD>@<MONGODB_CLUSTER_HOST>/<MONGODB_DB_NAME>?retryWrites=true&w=majority

Note: In the example snippet above, you'll notice that the URI includes a database name. While this field is technically optional, it's highly recommended that you create your own database instance on your MongoDB Atlas cluster. This practice helps maintain organization and clarity in your project.

Running the application

To run the express application, do follow the following steps

  1. Clone the repo:
    git clone [email protected]:mrarvind90/fcc-backend-api-projects.git
    
  2. Navigate to the repository:
    cd <repository_directory>
    Change <repository_directory> to the name of the cloned directory.
  3. Install Dependencies:
    npm install
    This command will install all the necessary dependencies for the application.
  4. Configure Environment Variables: Rename the .env.sample file in your project directory to .env and update it with the relevant credentials:
     cp .env.example .env
  5. Choose Your Run Mode:
    • Development Mode (with automatic code reload):
      To run the application in watch mode, enabling seamless source code changes without manual server restarts, use the following command:
     npm run dev
    • Standard Server Mode:
      If you prefer to simply run the server without automatic code reloading, you can use the following command:
     npm run start

Future Improvements

While developing this project, there are several areas I plan to focus on for enhancements and refinements which can be found on GitHub.