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

https://github.com/mubashir15700/microsphere

Node.js microservices with TypeScript, Docker, MongoDB, MySQL, Redis, RabbitMQ, and a Next.js frontend β€” featuring API Gateway, auth, task, user, and notification services.
https://github.com/mubashir15700/microsphere

api-gateway backend docker frontend husky jest microservices mongodb nextjs nodejs rabbitmq redis swagger typescript

Last synced: 3 months ago
JSON representation

Node.js microservices with TypeScript, Docker, MongoDB, MySQL, Redis, RabbitMQ, and a Next.js frontend β€” featuring API Gateway, auth, task, user, and notification services.

Awesome Lists containing this project

README

          

# 🧩 MicroSphere – Node.js Microservices Architecture (TypeScript + Docker)

This project demonstrates a complete Node.js microservices architecture using TypeScript, Docker, MongoDB, MySQL, Prisma ORM, Redis, RabbitMQ, and Socket.IO, along with a Next.js frontend. It follows clean service boundaries with Auth, User, Task, Notification, and an API Gateway.

Services communicate through REST APIs, asynchronous messaging (RabbitMQ), and real-time WebSocket events (Socket.IO).

The frontend, built with Next.js + TypeScript and Zustand for state management, is located in the /client folder and is currently under active development.

---

## 🧠 Architecture Overview

- **API Gateway** – Entry point for all requests, handles routing and JWT authentication.
- **Auth Service** – Manages user registration and login, returns signed JWT tokens.
- **User Service** – Manages user data in MongoDB, with Redis caching implemented in the "Get All Users" API.
- **Task Service** – Manages tasks in MongoDB, and sends messages to RabbitMQ. Redis caching is used in the "Get All Tasks" API.
- **Notification Service** – Subscribes to RabbitMQ, stores notifications via Prisma (MySQL), and sends real-time notifications to the client using Socket.IO. Redis caching is used in the β€œGet All Notifications” API.
- **Client (Next.js)** – React-based frontend using Zustand for global state management and Socket.IO client for real-time notifications.
- **MongoDB** – Stores persistent data for users and tasks.
- **Prisma ORM with MySQL** – For notifications persistence.
- **Redis** – Caching layer for User, Task and Notification services to improve read performance.
- **RabbitMQ** – Message broker for asynchronous, event-driven communication between services.
- **Swagger** – API documentation available for backend services.
- **Husky** – Git hooks for enforcing code quality and pre-commit checks.

---

## πŸ“¦ Tech Stack

### 🧰 Backend

- **Node.js** with **Express**
- **TypeScript**
- **MongoDB**
- **MySQL** (for Prisma ORM)
- **Redis** (used in User, Task and Notification services)
- **RabbitMQ**
- **Socket.IO** (real-time communication between Notification Service and client)
- **JWT Authentication**
- **Docker & Docker Compose**
- **http-proxy-middleware** for API Gateway
- **Swagger** for REST API documentation
- **ts-node-dev** for dev mode hot-reload

### πŸ–₯️ Frontend

- **Next.js** (React + TypeScript)
- **Zustand** – Lightweight state management
- **Axios** – For API requests
- **Socket.IO Client** – For receiving real-time notifications
- **Tailwind CSS**
- **shadcn/ui** – Accessible, customizable UI components (built on Radix UI & Tailwind)
- **Swagger UI** – For API documentation

### πŸ§ͺ Dev Tooling

- **Husky** – Git hooks for code linting, pre-commit checks, etc.
- **ESLint + Prettier** – Code quality and formatting (assumed, can be mentioned if true)

---

## πŸ“ Project Structure

```
β”œβ”€β”€ .github/ # πŸ™ GitHub Actions/CI workflows
β”œβ”€β”€ .husky/ # βš™οΈ Git hooks for pre-commit, pre-push
β”œβ”€β”€ api-gateway/ # πŸšͺ Centralized routing & auth handling
β”œβ”€β”€ auth-service/ # πŸ” Handles registration, login, and JWT
β”œβ”€β”€ client/ # πŸ–₯️ Next.js frontend (Zustand + Socket.IO)
β”œβ”€β”€ notification-service/ # πŸ“£ Notification management (Prisma + RabbitMQ + Socket.IO)
β”œβ”€β”€ task-service/ # βœ… Task management (MongoDB + Redis)
β”œβ”€β”€ user-service/ # πŸ‘€ User data (MongoDB + Redis)
β”œβ”€β”€ .gitignore # 🚫 Git ignore rules
β”œβ”€β”€ docker-compose.yml # 🐳 Docker orchestration
β”œβ”€β”€ package-lock.json # πŸ”’ Lock file for dependency versions
β”œβ”€β”€ package.json # πŸ“¦ Project dependencies & Husky configurations
└── README.md # πŸ“˜ Project overview
```

---

## πŸš€ Getting Started

### πŸ”§ Prerequisites

- [Docker](https://www.docker.com/products/docker-desktop)
- [Docker Compose](https://docs.docker.com/compose/install/)

---

### ▢️ Run the Project

1. **Clone the Repository**

```bash
git clone https://github.com/Mubashir15700/MicroSphere.git
cd MicroSphere
```

2. **Start All Services**

`docker-compose up --build`

This will:

- πŸ”§ Build Docker images for all services
- 🐳 Start MongoDB, MySQL, Redis, and RabbitMQ containers
- πŸš€ Launch all backend services with hot-reload enabled via ts-node-dev
- 🌐 Expose APIs through the API Gateway
- ⚑ Enable real-time notification streaming via Socket.IO

---

## πŸ“„ Swagger API Documentation

Each backend service exposes Swagger UI for exploring and testing APIs.

ℹ️ Swagger docs are available once all services are running via docker-compose up.

Service Swagger URL:

- **Auth Service** - http://localhost:3000/auth/api-docs
- **User Service** - http://localhost:3000/users/api-docs
- **Task Service** - http://localhost:3000/tasks/api-docs
- **Notification Service** - http://localhost:3000/notifications/api-docs