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

https://github.com/keshavabanda/micro-services

Exploring microservices in the real world - This is a sample project I was exploring recently with dockering..
https://github.com/keshavabanda/micro-services

api-security authentication express javascript jwt mongodb mongoose nodejs rest-api

Last synced: 27 days ago
JSON representation

Exploring microservices in the real world - This is a sample project I was exploring recently with dockering..

Awesome Lists containing this project

README

          

# ๐Ÿงฉ Microservices-Based TODO Application (MEAN Stack)

This project demonstrates how to build a scalable and secure TODO application using **Microservices architecture** with the **MEAN stack** (MongoDB, Express, Angular, Node.js).

---

## ๐Ÿ“ฆ Project Structure

microservices-todo-app/

โ”œโ”€โ”€ todo-services # Handles todo CRUD operations with authorization

โ”œโ”€โ”€ user-services # Handles user registration, login, and JWT auth

โ””โ”€โ”€ frontend/ # Angular app (planned for micro frontend integration)

---

## ๐Ÿš€ Features

- โœ… **Two Independent Services**: `user-service` and `todo-service`
- ๐Ÿ” **JWT-based Authentication** (via login API)
- ๐Ÿ”’ **Route-Level Authorization** using Express middleware
- ๐Ÿ‘ค Only the **creator** of a TODO can update or delete it
- ๐Ÿ” **Service-to-Service Communication** using Axios
- ๐ŸŒฑ **MongoDB Integration** with Mongoose models
- ๐Ÿ“… Created using real-world REST API design principles

---

## ๐Ÿ›  Tech Stack

- **Backend**: Node.js, Express.js
- **Database**: MongoDB (Mongoose ODM)
- **Authentication**: JWT (JSON Web Token)
- **Frontend**: Angular (To be integrated as Micro Frontend)
- **Communication**: Axios for internal service HTTP calls

---

## ๐Ÿงช How to Run Locally

### โš™๏ธ 1. Clone the repository

```bash
git clone https://github.com/keshavaBanda/micro-services.git
cd microservices-todo-app
```

## ๐Ÿš€ 2. Start MongoDB
Make sure MongoDB is running on your system (default port 27017).

๐Ÿง  Recommended: Use MongoDB Compass for UI access.

## ๐Ÿงโ€โ™‚๏ธ 3. Run user-service

cd user-service
npm install
cp .env.example .env # Or manually create .env
npm start

```bash
PORT=3001
JWT_SECRET=your_jwt_secret_key
MONGO_URI=mongodb://localhost:27017/user-service
```

## โœ… 4. Run todo-service

cd ../todo-service
npm install
cp .env.example .env # Or manually create .env
npm start

Sample .env file:
PORT=3000
MONGO_URI=mongodb://localhost:27017/todo-service
JWT_SECRET=your_jwt_secret_key # Must match user-service

## ๐Ÿงช 5. Test with Postman
Use Postman or any REST client to:

Register/Login via user-service to get a token

Use the token as Bearer in the Authorization header for all todo-service API calls

## โœจ Upcoming Enhancements
๐Ÿ”— Connect to Micro Frontend (Angular)\
๐Ÿณ Dockerize both services\
๐ŸŒ Add API Gateway for unified routing\
๐Ÿ”„ Refresh Token Mechanism\
๐Ÿ“Š Logging and Monitoring