# maruki00/deligo-saas architecture

> Architecture diagram of the GitHub repository maruki00/deligo-saas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maruki00/deligo-saas
- Repository: https://github.com/maruki00/deligo-saas

## Overview

##### Main Components
- Auth Service (found in cmd/auth and internal/auth)
- Customer Service (cmd not explicitly, but internal/customer indicates its presence)
- Delivery Service (cmd/delivery and related internal implementations)
- Order Service (cmd/order and internal/order)
- Product Service (cmd/product and internal/product)
- Shop/Restaurant Service (cmd/shop and internal/shop; note also modules under internal/menu, roles, permessions, and users which seem related to restaurant/merchant management)
- Courier Service (cmd/courier)
- Proxy Service (cmd/proxy) – likely an API gateway or reverse proxy
- Messaging/Event Bus (RabbitMQ, see pkg/rabbitmq)
- Database Layers (MySQL with tables like orders, users, products, etc.; also PostgreSQL references)
- External Services (Stripe for payment, possibly external notification systems)
- Common Utilities and Libraries (packages under pkg/ such as jwt, redis, s3, security, websocket, etc.)
- Domain and Shared Code: Represent common domain models and shared components (as seen in internal/shared and various domain-specific folders) to emphasize Domain-Driven Design (DDD) usage.

##### Relationships and Interactions
- That each microservice exposes its own API endpoints, often implemented via GRPC endpoints (notice the proto definitions and GRPC generated code in several directories).
- The Proxy Service routes requests to the appropriate service (Auth, Order, Product, etc.).
- Microservices also communicate with each other via asynchronous messaging through RabbitMQ (using the publisher/consumer packages).
- How each microservice connects to the databases (MySQL/Postgres) and possibly use shared caching (Redis, as indicated in pkg/redis).

##### Architectural Patterns and Design Principles
- Domain-Driven Design (DDD): Each service has clearly defined domains (with separate “domain”, “app”, and “infrastructure” layers).
- Separation of Concerns: Different folders for command-line entry points (cmd/*) versus business logic (internal/*) highlights clear separation between service bootstrapping and domain logic.
- Microservice Communication: Indicate that services interact using gRPC, REST endpoints, or message brokers (RabbitMQ).
- Configurability: Note configuration management indicated by config directories and config files (e.g., config.yaml.example).

##### Technologies, Frameworks, and Libraries
- Go Language (all services are built in Go).
- RabbitMQ for messaging (as seen in pkg/rabbitmq).
- MySQL and PostgreSQL for persistence (files such as mysql.sql and postgres.sql along with pkg/mysql and pkg/postgres).
- Stripe integration for payment processing.
- gRPC and Protocol Buffers, as demonstrated by the proto files under proto/.
- Additional utilities such as JWT for authentication (pkg/jwt), Redis, S3 storage, and WebSocket support (pkg/websocket).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client & Gateway Layer"
        Client["Client"]:::gateway
        Proxy["Proxy Service (API Gateway)"]:::gateway
        Client -->|"HTTPRequest"| Proxy
    end

    subgraph "Microservices Layer"
        Auth["Auth Service"]:::microservices
        Courier["Courier Service"]:::microservices
        Delivery["Delivery Service"]:::microservices
        Order["Order Service"]:::microservices
        Product["Product Service"]:::microservices
        Shop["Shop/Restaurant Service"]:::microservices
        UserMgmt["User Management Service"]:::microservices
        Customer["Customer Service"]:::microservices

        Proxy -->|"RoutesTo"| Auth
        Proxy -->|"RoutesTo"| Courier
        Proxy -->|"RoutesTo"| Delivery
        Proxy -->|"RoutesTo"| Order
        Proxy -->|"RoutesTo"| Product
        Proxy -->|"RoutesTo"| Shop
        Proxy -->|"RoutesTo"| UserMgmt
        Proxy -->|"RoutesTo"| Customer

        Auth -->|"gRPCcall"| Order
        Order -->|"gRPCcall"| Product
        Shop -->|"gRPCcall"| UserMgmt
    end

    subgraph "Shared Infrastructure"
        Messaging["Messaging/Event Bus (RabbitMQ)"]:::infra
        MySQL["Database: MySQL"]:::infra
        Postgres["Database: PostgreSQL"]:::infra
        Stripe["External Payment Gateway (Stripe)"]:::infra
        Utilities["Common Utilities & Libraries"]:::infra
        Shared["Domain and Shared Code"]:::infra

        Auth ---|"RabbitMQ/DB"| Messaging
        Courier ---|"RabbitMQ/DB"| Messaging
        Delivery ---|"RabbitMQ/DB"| Messaging
        Order ---|"RabbitMQ/DB"| Messaging
        Product ---|"RabbitMQ/DB"| Messaging
        Shop ---|"RabbitMQ/DB"| Messaging
        UserMgmt ---|"RabbitMQ/DB"| Messaging
        Customer ---|"RabbitMQ/DB"| Messaging

        Auth ---|"DBquery"| MySQL
        Courier ---|"DBquery"| MySQL
        Delivery ---|"DBquery"| MySQL
        Order ---|"DBquery"| MySQL
        Product ---|"DBquery"| MySQL
        Shop ---|"DBquery"| MySQL
        UserMgmt ---|"DBquery"| MySQL
        Customer ---|"DBquery"| MySQL

        Order ---|"Callspayment"| Stripe

        Auth --- Utilities
        Courier --- Utilities
        Delivery --- Utilities
        Order --- Utilities
        Product --- Utilities
        Shop --- Utilities
        UserMgmt --- Utilities
        Customer --- Utilities

        Auth --- Shared
        Courier --- Shared
        Delivery --- Shared
        Order --- Shared
        Product --- Shared
        Shop --- Shared
        UserMgmt --- Shared
        Customer --- Shared

        Shop ---|"DBquery"| Postgres
        UserMgmt ---|"DBquery"| Postgres
    end

    click Auth "https://github.com/maruki00/deligo-saas/tree/main/cmd/auth"
    click Auth "https://github.com/maruki00/deligo-saas/tree/main/internal/auth"

    click Courier "https://github.com/maruki00/deligo-saas/tree/main/cmd/courier"

    click Delivery "https://github.com/maruki00/deligo-saas/tree/main/cmd/delivery"

    click Order "https://github.com/maruki00/deligo-saas/tree/main/cmd/order"
    click Order "https://github.com/maruki00/deligo-saas/tree/main/internal/order"

    click Product "https://github.com/maruki00/deligo-saas/tree/main/cmd/product"
    click Product "https://github.com/maruki00/deligo-saas/tree/main/internal/product"

    click Shop "https://github.com/maruki00/deligo-saas/tree/main/cmd/shop"
    click Shop "https://github.com/maruki00/deligo-saas/tree/main/internal/shop"
    click Shop "https://github.com/maruki00/deligo-saas/tree/main/internal/menu"
    click Shop "https://github.com/maruki00/deligo-saas/tree/main/internal/roles"
    click Shop "https://github.com/maruki00/deligo-saas/tree/main/internal/permessions"
    click Shop "https://github.com/maruki00/deligo-saas/tree/main/internal/users"

    click UserMgmt "https://github.com/maruki00/deligo-saas/tree/main/cmd/user"
    click UserMgmt "https://github.com/maruki00/deligo-saas/tree/main/internal/user"

    click Customer "https://github.com/maruki00/deligo-saas/tree/main/internal/customer"

    click Messaging "https://github.com/maruki00/deligo-saas/tree/main/pkg/rabbitmq"

    click MySQL "https://github.com/maruki00/deligo-saas/tree/main/pkg/mysql"
    click MySQL "https://github.com/maruki00/deligo-saas/blob/main/mysql.sql"

    click Postgres "https://github.com/maruki00/deligo-saas/tree/main/pkg/postgres"
    click Postgres "https://github.com/maruki00/deligo-saas/blob/main/postgres.sql"

    click Utilities "https://github.com/maruki00/deligo-saas/tree/main/pkg/jwt"
    click Utilities "https://github.com/maruki00/deligo-saas/tree/main/pkg/redis"
    click Utilities "https://github.com/maruki00/deligo-saas/tree/main/pkg/s3"
    click Utilities "https://github.com/maruki00/deligo-saas/tree/main/pkg/security"
    click Utilities "https://github.com/maruki00/deligo-saas/tree/main/pkg/websocket"
    click Utilities "https://github.com/maruki00/deligo-saas/tree/main/pkg/utils"

    click Shared "https://github.com/maruki00/deligo-saas/tree/main/internal/shared"

    classDef microservices fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef infra fill:#A2D9CE,stroke:#16A085,stroke-width:2px;
    classDef gateway fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
