An open API service indexing awesome lists of open source software.

https://github.com/getange/node-microservices

This repo contains a small project to test my knowledge in distributed systems
https://github.com/getange/node-microservices

expressjs mongodb mongoose node-js rabbitmq redis-server

Last synced: about 1 year ago
JSON representation

This repo contains a small project to test my knowledge in distributed systems

Awesome Lists containing this project

README

          

# Node Microservices Project ๐Ÿš€

This repository showcases a microservices-based architecture implemented with Node.js, aiming to demonstrate proficiency in building distributed systems.

---

## โš™๏ธ Technologies Used

* **Node.js** โ€“ JavaScript runtime environment ๐ŸŸข
* **Express.js** โ€“ Web framework for Node.js ๐ŸŒ
* **MongoDB** โ€“ NoSQL database for data persistence ๐Ÿƒ
* **Mongoose** โ€“ ODM for MongoDB ๐Ÿ“„
* **Redis** โ€“ In-memory data structure store, used for caching and message brokering ๐Ÿง 
* **RabbitMQ** โ€“ Message broker for asynchronous communication between services ๐Ÿ‡
* **Docker & Docker Compose** โ€“ Containerization and orchestration tools ๐Ÿณ

---

## ๐Ÿงฑ Microservices Overview

The application is divided into the following microservices:

1. **API Gateway**: Serves as the single entry point for client requests ๐Ÿšช
2. **Identity Service**: Handles user authentication and authorization ๐Ÿ”
3. **Media Service**: Manages media uploads and processing ๐Ÿ–ผ๏ธ
4. **Post Service**: Manages creation, retrieval, and manipulation of posts ๐Ÿ“
5. **Search Service**: Provides search functionality across posts and media ๐Ÿ”

---

## ๐Ÿ—‚๏ธ Project Structure

```bash
node-microservices/
โ”œโ”€โ”€ api-gateway/ # Entry point for all client requests
โ”œโ”€โ”€ identity-service/ # User authentication and authorization
โ”œโ”€โ”€ media-service/ # Media upload and processing
โ”œโ”€โ”€ post-service/ # Post management
โ”œโ”€โ”€ search-service/ # Search functionality
โ”œโ”€โ”€ docker-compose.yml # Docker Compose configuration
โ””โ”€โ”€ README.md # Project documentation
```

---

## ๐Ÿš€ Getting Started

### ๐Ÿ“‹ Prerequisites

Ensure you have the following installed:

* [Docker](https://www.docker.com/) ๐Ÿณ
* [Docker Compose](https://docs.docker.com/compose/) ๐Ÿงฉ

### โš™๏ธ Installation

1. **Clone the repository:**

```bash
git clone https://github.com/GETANGE/node-microservices.git
cd node-microservices
```

2. **Start the services using Docker Compose:**

```bash
docker-compose up --build
```

This command will build and start all the microservices along with their dependencies.

---

## ๐Ÿ“ซ API Endpoints

Each microservice exposes specific endpoints. Below is a summary:

### ๐ŸŒ API Gateway

* `POST /api/auth/register` โ€“ Register a new user โœ๏ธ
* `POST /api/auth/login` โ€“ Authenticate a user ๐Ÿ”‘
* `GET /api/posts` โ€“ Retrieve all posts ๐Ÿ“„
* `POST /api/posts` โ€“ Create a new post ๐Ÿ“
* `POST /api/media/upload` โ€“ Upload media content ๐Ÿ“ค
* `GET /api/search?query=...` โ€“ Search posts and media ๐Ÿ”

*Note: All requests should be directed to the API Gateway, which will route them to the appropriate service.*

---

## ๐Ÿงฐ Development

To work on a specific service:

1. **Navigate to the service directory:**

```bash
cd
```

2. **Install dependencies:**

```bash
pnpm install
```

3. **Start the service:**

```bash
pnpm start
```

Ensure that the necessary environment variables are set, either through a `.env` file or your system's environment settings.

---

## ๐Ÿงช Testing

Each service includes its own set of tests. To run tests for a service:

1. **Navigate to the service directory:**

```bash
cd
```

2. **Run the tests:**

```bash
pnpm test
```

---

## ๐Ÿ“ฆ Deployment

For production deployment, it's recommended to:

* Use a process manager like PM2 for managing Node.js processes ๐Ÿ”
* Set up reverse proxies (e.g., Nginx) for handling HTTPS and domain routing ๐ŸŒ
* Implement monitoring and logging solutions for observability ๐Ÿ“Š

---

## ๐Ÿ“„ License

This project is licensed under the [MIT License](LICENSE).

---

## ๐Ÿ™ Acknowledgments

This project was developed to demonstrate knowledge in building distributed systems using Node.js and related technologies.