# floriaaan/goodfood architecture

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

- Interactive diagram: https://gitdiagram.com/floriaaan/goodfood
- Repository: https://github.com/floriaaan/goodfood

## Overview

##### Project type and purpose
- This is a full-stack, microservices-based food-ordering platform (“GoodFood 2.0”) with:
- Mobile client (Expo React Native, TypeScript)
- Web client (Next.js, TypeScript)
- API Gateway (Go) exposing HTTP/REST to clients
- ~12 domain services (Node.js/TypeScript, Go, C#/.NET) communicating via gRPC and an event broker
- Each service owns its own datastore (PostgreSQL or Redis)
- Infrastructure as code (Terraform), container orchestration (Docker Compose, Kubernetes), CI/CD (GitHub Actions)

##### File structure
- Top-level “apps/” folders contain frontends:
- apps/web: Next.js app with pages, components, hooks
- apps/mobile: Expo app with screens, components, native hooks
- “services/” contains one folder per microservice: gateway, user, basket, payment, product, restaurant, promotion, order, delivery, stock, notification, log, reporting
- Each service has src/handlers, lib (AMQP, proxy, ORM), middleware, server entrypoint, proto/.
- Prisma ORM for Node.js services, native Go or C# clients for others.
- Dockerfile, local Docker Compose, Kubernetes manifests under services/…/k8s, Terraform under services/…/terraform.
- “services/proto” defines the shared gRPC interfaces.
- CI/CD: .github/workflows/* for each service pipeline.
- Infrastructure provisioning in top-level terraform/ and kubernetes/ folder.

##### Read the README for insights
- A table lists each microservice’s port, language, and database.
- Instructions cover Terraform backend setup, Docker Compose, Kubernetes on Kind, and per-service README references.
- Microservices expose gRPC and some expose HTTP (gateway, webhook endpoints).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Layer"
        Mobile["Mobile App\n(Expo React Native)"]:::client
        Web["Web App\n(Next.js)"]:::client
    end

    subgraph "API Gateway Layer"
        Gateway["API Gateway\n(Go)"]:::gateway
    end

    subgraph "Backend Services"
        direction TB
        Protos["gRPC Protos"]:::infra
        UserSvc["User Service"]:::service
        BasketSvc["Basket Service"]:::service
        PaymentSvc["Payment Service"]:::service
        ProductSvc["Product Service"]:::service
        RestaurantSvc["Restaurant Service"]:::service
        PromotionSvc["Promotion Service"]:::service
        OrderSvc["Order Service"]:::service
        DeliverySvc["Delivery Service"]:::service
        StockSvc["Stock Service"]:::service
        NotificationSvc["Notification Service"]:::service
        LogSvc["Log Service"]:::service
        ReportingSvc["Reporting Service"]:::service
    end

    subgraph "Messaging & Events"
        RabbitMQ["RabbitMQ\n(Event Broker)"]:::broker
    end

    subgraph "Data Persistence"
        UserDB[(PostgreSQL)]:::db
        BasketDB[(Redis)]:::db
        PaymentDB[(PostgreSQL)]:::db
        ProductDB[(PostgreSQL)]:::db
        RestaurantDB[(PostgreSQL)]:::db
        PromotionDB[(PostgreSQL)]:::db
        OrderDB[(PostgreSQL)]:::db
        DeliveryDB[(PostgreSQL)]:::db
        StockDB[(PostgreSQL)]:::db
        NotificationDB[(PostgreSQL)]:::db
        LogDB[(PostgreSQL)]:::db
        ReportingDB[(PostgreSQL)]:::db
    end

    subgraph "Infrastructure & CI/CD"
        TerraformInfra["Terraform"]:::infra
        KubernetesInfra["Kubernetes Manifests"]:::infra
        CI["GitHub Actions"]:::infra
    end

    %% Connections
    Mobile -->|HTTP/REST| Gateway
    Web -->|HTTP/REST| Gateway

    Gateway -->|gRPC| Protos
    Protos -->|gRPC| UserSvc
    Protos -->|gRPC| BasketSvc
    Protos -->|gRPC| PaymentSvc
    Protos -->|gRPC| ProductSvc
    Protos -->|gRPC| RestaurantSvc
    Protos -->|gRPC| PromotionSvc
    Protos -->|gRPC| OrderSvc
    Protos -->|gRPC| DeliverySvc
    Protos -->|gRPC| StockSvc
    Protos -->|gRPC| NotificationSvc
    Protos -->|gRPC| LogSvc
    Protos -->|gRPC| ReportingSvc

    %% Service to DB
    UserSvc -->|read/write| UserDB
    BasketSvc -->|read/write| BasketDB
    PaymentSvc -->|read/write| PaymentDB
    ProductSvc -->|read/write| ProductDB
    RestaurantSvc -->|read/write| RestaurantDB
    PromotionSvc -->|read/write| PromotionDB
    OrderSvc -->|read/write| OrderDB
    DeliverySvc -->|read/write| DeliveryDB
    StockSvc -->|read/write| StockDB
    NotificationSvc -->|read/write| NotificationDB
    LogSvc -->|read/write| LogDB
    ReportingSvc -->|read/write| ReportingDB

    %% Events
    UserSvc -.->|publish AMQP| RabbitMQ
    BasketSvc -.->|publish AMQP| RabbitMQ
    PaymentSvc -.->|publish AMQP| RabbitMQ
    ProductSvc -.->|publish AMQP| RabbitMQ
    RestaurantSvc -.->|publish AMQP| RabbitMQ
    PromotionSvc -.->|publish AMQP| RabbitMQ
    OrderSvc -.->|publish AMQP| RabbitMQ
    DeliverySvc -.->|publish AMQP| RabbitMQ
    StockSvc -.->|publish AMQP| RabbitMQ

    RabbitMQ -.->|consume| NotificationSvc
    RabbitMQ -.->|consume| LogSvc
    RabbitMQ -.->|consume| ReportingSvc

    %% Infra connections
    TerraformInfra -.-> KubernetesInfra
    KubernetesInfra -.->|deploy| UserSvc

    %% Click events
    click Mobile "https://github.com/floriaaan/goodfood/tree/main/apps/mobile"
    click Web "https://github.com/floriaaan/goodfood/tree/main/apps/web"
    click Gateway "https://github.com/floriaaan/goodfood/tree/main/services/gateway"
    click Protos "https://github.com/floriaaan/goodfood/tree/main/services/proto"
    click UserSvc "https://github.com/floriaaan/goodfood/tree/main/services/user"
    click BasketSvc "https://github.com/floriaaan/goodfood/tree/main/services/basket"
    click PaymentSvc "https://github.com/floriaaan/goodfood/tree/main/services/payment"
    click ProductSvc "https://github.com/floriaaan/goodfood/tree/main/services/product"
    click RestaurantSvc "https://github.com/floriaaan/goodfood/tree/main/services/restaurant"
    click PromotionSvc "https://github.com/floriaaan/goodfood/tree/main/services/promotions"
    click OrderSvc "https://github.com/floriaaan/goodfood/tree/main/services/order"
    click DeliverySvc "https://github.com/floriaaan/goodfood/tree/main/services/delivery"
    click StockSvc "https://github.com/floriaaan/goodfood/tree/main/services/stock"
    click NotificationSvc "https://github.com/floriaaan/goodfood/tree/main/services/notification"
    click LogSvc "https://github.com/floriaaan/goodfood/tree/main/services/log"
    click ReportingSvc "https://github.com/floriaaan/goodfood/tree/main/services/reporting"
    click TerraformInfra "https://github.com/floriaaan/goodfood/tree/main/terraform/"
    click KubernetesInfra "https://github.com/floriaaan/goodfood/tree/main/kubernetes/"
    click CI "https://github.com/floriaaan/goodfood/tree/main/.github/workflows"

    classDef client fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1;
    classDef gateway fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20;
    classDef service fill:#FFE0B2,stroke:#E65100,color:#E65100;
    classDef broker fill:#E1BEE7,stroke:#6A1B9A,color:#6A1B9A;
    classDef db fill:#FFCDD2,stroke:#B71C1C,color:#B71C1C;
    classDef infra fill:#CFD8DC,stroke:#37474F,color:#37474F;
```
