Skip to content

JEWOOLAFAVOUR/Backend-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservices Backend Template

A complete Node.js microservices architecture demonstrating best practices for scalable backend development with User Management and Course Management services.

Architecture Overview

                    ┌─────────────────────────────────────┐
                    │          CLIENTS                    │
                    │   (Web, Mobile, Desktop Apps)      │
                    └─────────────────┬───────────────────┘
                                      │
                              HTTP Requests
                                      │
                    ┌─────────────────▼───────────────────┐
                    │           API GATEWAY               │
                    │            Port 3000                │
                    │  • Authentication & Authorization   │
                    │  • Request Routing & Load Balance   │
                    │  • Rate Limiting & Security         │
                    │  • Request/Response Transformation  │
                    └───────────┬─────────────────────────┘
                                │
                  ┌─────────────┼─────────────┐
                  │                           │
        ┌─────────▼─────────┐       ┌─────────▼─────────┐
        │   USER SERVICE    │       │  COURSE SERVICE   │
        │    Port 3001      │       │    Port 3002      │
        │                   │       │                   │
        │ • User Registration │      │ • Course CRUD     │
        │ • Authentication   │      │ • Enrollments     │
        │ • Profile Mgmt     │      │ • Progress Track  │
        │ • JWT Tokens       │      │ • Instructor Panel │
        │ • User Search      │      │ • Analytics       │
        └─────────┬─────────┘       └─────────┬─────────┘
                  │                           │
        ┌─────────▼─────────┐       ┌─────────▼─────────┐
        │    USER DB        │       │   COURSE DB       │
        │ MongoDB:27017     │       │ MongoDB:27018     │
        │                   │       │                   │
        │ • Users           │       │ • Courses         │
        │ • Profiles        │       │ • Lessons         │
        │ • Auth Tokens     │       │ • Enrollments     │
        └───────────────────┘       └───────────────────┘

Quick Start

Local Development

# Setup all services
cd microservices
./setup.sh        # Mac/Linux
setup.bat         # Windows

# Start all services
npm run dev:all

Docker

cd microservices
docker-compose up --build

Services will run on:

Before running the project, ensure you have the following installed:

  • Node.js (v14+ recommended)
  • npm (comes with Node.js)
  • MongoDB (Ensure it's running locally or use a remote database)

Installation

Follow these steps to set up the project on your local machine:

  1. Clone the repository:

    git clone [https://github.com/JEWOOLAFAVOUR/Backend-Template.git](https://github.com/JEWOOLAFAVOUR/Backend-Template.git)
    cd backend-template
  2. Install dependencies:

    npm install
    npm install nodemon -g
  3. Environment Variables:

    Create a .env file in the root directory and add the following:

    JWT_SECRET=your_random_secret_key
    PASS_SEC=your_random_pass_key
    MONGO_URI=your_mongodb_connection_string
  4. Running the application:

    nodemon app

Submitting Pull Requests

To contribute code:

  1. Fork the Repository: Create a personal copy of the repository.
  2. Create a New Branch: Use a descriptive name for your branch (e.g., feature/add-authentication).
  3. Make Changes: Implement your changes in the new branch.
  4. Test Your Changes: Ensure your changes don't break existing functionality.
  5. Commit and Push: Commit your changes with clear messages and push to your fork.
  6. Open a Pull Request: Submit a pull request to the main repository's main branch.

Code Style and Guidelines

  • Code Quality: Write clean, readable, and maintainable code.
  • Documentation: Update documentation for any changes that affect usage or functionality.
  • Testing: Add tests for new features or bug fixes.

About

This is my Micro-service Template for any backend code, I'll be updating back-to-back on it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors