# jonathangunawan30/microgreens architecture

> Architecture diagram of the GitHub repository jonathangunawan30/microgreens, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jonathangunawan30/microgreens
- Repository: https://github.com/jonathangunawan30/microgreens

## Overview

MicroGreens is a Go grocery marketplace split into five independently running services. The main customer path is account access, browsing products and managing a cart, placing an order, completing payment, then receiving status notifications; administrators also manage catalog, roles, and order status. The README documents REST traffic through an Nginx gateway, RabbitMQ event processing, search, caching, and image storage. App wiring and selected handlers support the shown internal links; some cross-service event details are documented only at a high level, so those links are deliberately broad.

Main entry points: [`product-service/internal/adapter/handler/product_handler.go`](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/handler/product_handler.go) (Product API), [`notification-service/internal/core/service/notification_service.go`](https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/core/service/notification_service.go) (Notification logic), [`product-service/internal/adapter/repository/product_repository.go`](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/repository/product_repository.go) (Product data), [`user-service/internal/core/service/user_service.go`](https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/core/service/user_service.go) (Accounts and roles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_user_http["User API<br/>[user_handler.go]"]
  node_user_service["Accounts and roles<br/>[user_service.go]"]
  node_user_store[("User data<br/>[user_repository.go]")]
  node_user_images["Profile images<br/>[supabase.go]"]
end

subgraph group_commerce["Catalog and cart"]
  node_product_http["Product API<br/>[product_handler.go]"]
  node_product_service["Catalog and search<br/>[product_service.go]"]
  node_category_service["Categories"]
  node_cart_http["Cart API<br/>[cart_handler.go]"]
  node_cart_service["Cart logic<br/>[cart_service.go]"]
  node_product_store[("Product data")]
  node_cart_cache[("Cart cache<br/>[cart_repository.go]")]
  node_product_images["Product images"]
end

subgraph group_orders["Orders and payment"]
  node_order_http["Order API<br/>[order_handler.go]"]
  node_order_service["Checkout and lifecycle<br/>[order_service.go]"]
  node_order_store[("Order data")]
  node_order_search[("Order search")]
  node_payment_http["Payment API<br/>[payment_handler.go]"]
  node_payment_service["Payment processing<br/>[payment_service.go]"]
  node_payment_store[("Payment records")]
end

subgraph group_messaging["Events and alerts"]
  node_rabbit["RabbitMQ"]
  node_notification_http["Notification API"]
  node_notification_ws["WebSocket alerts"]
  node_notification_service["Notification logic"]
  node_notification_store[("Alert records")]
end

subgraph group_infrastructure["Shared infrastructure"]
  node_redis[("Redis caches")]
  node_supabase["Supabase storage"]
  node_postgres[("PostgreSQL")]
  node_elasticsearch[("Elasticsearch")]
end

node_client(("Client app"))
node_gateway["Nginx gateway"]
node_midtrans["Midtrans gateway"]
node_smtp["SMTP email"]

node_client -->|"HTTPS"| node_gateway
node_gateway -->|"REST"| node_user_http
node_gateway -->|"REST"| node_product_http
node_gateway -->|"REST"| node_cart_http
node_gateway -->|"REST"| node_order_http
node_gateway -->|"REST"| node_payment_http
node_gateway -->|"REST"| node_notification_http
node_gateway -->|"WebSocket"| node_notification_ws
node_user_http -->|"calls"| node_user_service
node_user_service -->|"reads/writes"| node_user_store
node_user_service -.->|"publishes events"| node_rabbit
node_user_http -->|"uploads"| node_user_images
node_user_images -->|"stores files"| node_supabase
node_product_http -->|"calls"| node_product_service
node_product_http -->|"calls"| node_category_service
node_product_http -->|"uploads"| node_product_images
node_product_service -->|"reads/writes"| node_product_store
node_product_service -.->|"publishes events"| node_rabbit
node_category_service -->|"reads/writes"| node_product_store
node_product_images -->|"stores files"| node_supabase
node_cart_http -->|"calls"| node_cart_service
node_cart_service -->|"reads/writes"| node_cart_cache
node_cart_service -->|"checks products"| node_product_store
node_order_http -->|"calls"| node_order_service
node_order_service -->|"reads/writes"| node_order_store
node_order_service -.->|"publishes events"| node_rabbit
node_order_search -->|"searches"| node_elasticsearch
node_payment_http -->|"calls"| node_payment_service
node_payment_service -->|"reads/writes"| node_payment_store
node_payment_service -->|"requests payment"| node_midtrans
node_payment_service -.->|"publishes events"| node_rabbit
node_notification_http -->|"calls"| node_notification_service
node_notification_ws -->|"serves alerts"| node_notification_service
node_notification_service -->|"reads/writes"| node_notification_store
node_notification_service -->|"sends email"| node_smtp
node_notification_service -.->|"consumes events"| node_rabbit
node_user_service -->|"uses cache"| node_redis
node_product_http -->|"uses cache"| node_redis
node_order_http -->|"uses cache"| node_redis
node_payment_http -->|"uses cache"| node_redis
node_notification_http -->|"uses cache"| node_redis
node_product_store -->|"reads/writes"| node_postgres
node_user_store -->|"reads/writes"| node_postgres
node_order_store -->|"reads/writes"| node_postgres
node_payment_store -->|"reads/writes"| node_postgres
node_notification_store -->|"reads/writes"| node_postgres
node_product_store -.->|"search/index"| node_elasticsearch

click node_user_http "https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/adapter/handler/user_handler.go"
click node_user_service "https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/core/service/user_service.go"
click node_user_store "https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/adapter/repository/user_repository.go"
click node_user_images "https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/adapter/storage/supabase.go"
click node_product_http "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/handler/product_handler.go"
click node_product_service "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/core/service/product_service.go"
click node_category_service "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/core/service/category_service.go"
click node_cart_http "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/handler/cart_handler.go"
click node_cart_service "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/core/service/cart_service.go"
click node_product_store "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/repository/product_repository.go"
click node_cart_cache "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/repository/cart_repository.go"
click node_product_images "https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/storage/supabase_storage.go"
click node_order_http "https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/adapter/handler/order_handler.go"
click node_order_service "https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/core/service/order_service.go"
click node_order_store "https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/adapter/repository/order_repository.go"
click node_order_search "https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/adapter/repository/elasticsearch_repository.go"
click node_payment_http "https://github.com/jonathangunawan30/microgreens/blob/main/payment-service/internal/adapter/handler/payment_handler.go"
click node_payment_service "https://github.com/jonathangunawan30/microgreens/blob/main/payment-service/internal/core/service/payment_service.go"
click node_payment_store "https://github.com/jonathangunawan30/microgreens/blob/main/payment-service/internal/adapter/repository/payment_repository.go"
click node_notification_http "https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/adapter/router/notification_router.go"
click node_notification_ws "https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/adapter/handler/websocket_handler.go"
click node_notification_service "https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/core/service/notification_service.go"
click node_notification_store "https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/adapter/repository/notif_repository.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_user_http,node_user_service,node_user_store,node_user_images,node_client toneBlue
class node_product_http,node_product_service,node_category_service,node_cart_http,node_cart_service,node_product_store,node_cart_cache,node_product_images toneAmber
class node_order_http,node_order_service,node_order_store,node_order_search,node_payment_http,node_payment_service,node_payment_store toneMint
class node_rabbit,node_notification_http,node_notification_ws,node_notification_service,node_notification_store toneRose
class node_redis,node_supabase,node_postgres,node_elasticsearch,node_gateway,node_midtrans,node_smtp toneIndigo
```

## Components

### Identity and access

- [User API](https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/adapter/handler/user_handler.go): `user-service/internal/adapter/handler/user_handler.go`
- [Accounts and roles](https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/core/service/user_service.go): `user-service/internal/core/service/user_service.go`
- [User data](https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/adapter/repository/user_repository.go): `user-service/internal/adapter/repository/user_repository.go`
- [Profile images](https://github.com/jonathangunawan30/microgreens/blob/main/user-service/internal/adapter/storage/supabase.go): `user-service/internal/adapter/storage/supabase.go`

### Catalog and cart

- [Product API](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/handler/product_handler.go): `product-service/internal/adapter/handler/product_handler.go`
- [Catalog and search](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/core/service/product_service.go): `product-service/internal/core/service/product_service.go`
- [Categories](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/core/service/category_service.go): `product-service/internal/core/service/category_service.go`
- [Cart API](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/handler/cart_handler.go): `product-service/internal/adapter/handler/cart_handler.go`
- [Cart logic](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/core/service/cart_service.go): `product-service/internal/core/service/cart_service.go`
- [Product data](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/repository/product_repository.go): `product-service/internal/adapter/repository/product_repository.go`
- [Cart cache](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/repository/cart_repository.go): `product-service/internal/adapter/repository/cart_repository.go`
- [Product images](https://github.com/jonathangunawan30/microgreens/blob/main/product-service/internal/adapter/storage/supabase_storage.go): `product-service/internal/adapter/storage/supabase_storage.go`

### Orders and payment

- [Order API](https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/adapter/handler/order_handler.go): `order-service/internal/adapter/handler/order_handler.go`
- [Checkout and lifecycle](https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/core/service/order_service.go): `order-service/internal/core/service/order_service.go`
- [Order data](https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/adapter/repository/order_repository.go): `order-service/internal/adapter/repository/order_repository.go`
- [Order search](https://github.com/jonathangunawan30/microgreens/blob/main/order-service/internal/adapter/repository/elasticsearch_repository.go): `order-service/internal/adapter/repository/elasticsearch_repository.go`
- [Payment API](https://github.com/jonathangunawan30/microgreens/blob/main/payment-service/internal/adapter/handler/payment_handler.go): `payment-service/internal/adapter/handler/payment_handler.go`
- [Payment processing](https://github.com/jonathangunawan30/microgreens/blob/main/payment-service/internal/core/service/payment_service.go): `payment-service/internal/core/service/payment_service.go`
- [Payment records](https://github.com/jonathangunawan30/microgreens/blob/main/payment-service/internal/adapter/repository/payment_repository.go): `payment-service/internal/adapter/repository/payment_repository.go`

### Events and alerts

- **RabbitMQ**
- [Notification API](https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/adapter/router/notification_router.go): `notification-service/internal/adapter/router/notification_router.go`
- [WebSocket alerts](https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/adapter/handler/websocket_handler.go): `notification-service/internal/adapter/handler/websocket_handler.go`
- [Notification logic](https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/core/service/notification_service.go): `notification-service/internal/core/service/notification_service.go`
- [Alert records](https://github.com/jonathangunawan30/microgreens/blob/main/notification-service/internal/adapter/repository/notif_repository.go): `notification-service/internal/adapter/repository/notif_repository.go`

### Shared infrastructure

- **Redis caches**
- **Supabase storage**
- **PostgreSQL**
- **Elasticsearch**

### Other components

- **Client app**
- **Nginx gateway**
- **Midtrans gateway**
- **SMTP email**

## Connections

- Client app → Nginx gateway: HTTPS
- Nginx gateway → User API: REST
- Nginx gateway → Product API: REST
- Nginx gateway → Cart API: REST
- Nginx gateway → Order API: REST
- Nginx gateway → Payment API: REST
- Nginx gateway → Notification API: REST
- Nginx gateway → WebSocket alerts: WebSocket
- User API → Accounts and roles: calls
- Accounts and roles → User data: reads/writes
- Accounts and roles → RabbitMQ: publishes events
- User API → Profile images: uploads
- Profile images → Supabase storage: stores files
- Product API → Catalog and search: calls
- Product API → Categories: calls
- Product API → Product images: uploads
- Catalog and search → Product data: reads/writes
- Catalog and search → RabbitMQ: publishes events
- Categories → Product data: reads/writes
- Product images → Supabase storage: stores files
- Cart API → Cart logic: calls
- Cart logic → Cart cache: reads/writes
- Cart logic → Product data: checks products
- Order API → Checkout and lifecycle: calls
- Checkout and lifecycle → Order data: reads/writes
- Checkout and lifecycle → RabbitMQ: publishes events
- Order search → Elasticsearch: searches
- Payment API → Payment processing: calls
- Payment processing → Payment records: reads/writes
- Payment processing → Midtrans gateway: requests payment
- Payment processing → RabbitMQ: publishes events
- Notification API → Notification logic: calls
- WebSocket alerts → Notification logic: serves alerts
- Notification logic → Alert records: reads/writes
- Notification logic → SMTP email: sends email
- Notification logic → RabbitMQ: consumes events
- Accounts and roles → Redis caches: uses cache
- Product API → Redis caches: uses cache
- Order API → Redis caches: uses cache
- Payment API → Redis caches: uses cache
- Notification API → Redis caches: uses cache
- Product data → PostgreSQL: reads/writes
- User data → PostgreSQL: reads/writes
- Order data → PostgreSQL: reads/writes
- Payment records → PostgreSQL: reads/writes
- Alert records → PostgreSQL: reads/writes
- Product data → Elasticsearch: search/index
