Skip to content

ZaraSdt7/MicroService

Repository files navigation

πŸš€ Microservices with Deno & Hexagonal Architecture

πŸ“Œ Introduction

This project implements a modular, independent, and scalable microservices architecture based on Hexagonal Architecture (Ports & Adapters). The goal is to separate business logic from infrastructure dependencies, making the system more flexible, testable, and maintainable.

πŸ› οΈ Technologies Used

βœ… Deno – A fast, secure runtime for JavaScript and TypeScript
βœ… Oak – A web framework for Deno, similar to Express.js
βœ… Deno KV or MySQL – For data storage
βœ… RabbitMQ or NATS – For inter-service communication
βœ… Deno Deploy or Docker – For deployment

πŸ—οΈ Project Architecture

This project follows Hexagonal Architecture, which includes:

  1. Core (Business Logic) – Contains the core domain logic without dependencies on frameworks or databases
  2. Ports – Interfaces for interacting with external services
  3. Adapters – Implementations of ports that connect to databases and messaging systems

πŸ“‚ Folder Structure

πŸ“¦ src  
 ┣ πŸ“‚ core         # Business logic and domain models  
 ┣ πŸ“‚ ports        # Input and output interfaces  
 ┣ πŸ“‚ adapters     # Adapters for database and external services  
 ┣ πŸ“‚ services     # Independent microservices  
 ┣ πŸ“‚ infra        # Infrastructure settings like messaging and database  
 ┣ πŸ“‚ api          # API controllers for service communication  
 β”— πŸ“œ main.ts      # Application entry point  

βš™οΈ Installation & Running

1️⃣ Install Deno

Install Deno and verify the installation:

deno --version

2️⃣ Run the Project

deno run -A src/main.ts

3️⃣ Run with Docker

docker build -t my-microservice .
docker run -p 3000:3000 my-microservice

πŸ“‘ Inter-Service Communication

Microservices communicate via RabbitMQ or NATS. To run RabbitMQ with Docker:

docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:management

πŸš€ Deployment

To deploy on Deno Deploy:

deno deploy

Or using Docker Compose:

version: '3'
services:
  app:
    build: .
    ports:
      - "3000:3000"
    depends_on:
      - database
  database:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: mydb

Run with:

docker-compose up -d

πŸ“– Conclusion

This project demonstrates a modern and scalable microservices architecture using Deno and Hexagonal Architecture. The design ensures independent services, high testability, easy scalability, and flexible deployment. πŸš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published