# adamhingoro/micro-restaurants architecture

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

- Interactive diagram: https://gitdiagram.com/adamhingoro/micro-restaurants
- Repository: https://github.com/adamhingoro/micro-restaurants

## Overview

##### Main Components
- API Gateway / Reverse Proxy
- Nginx container (deployment/docker/nginx.conf)
- Frontends
- Admin Panel (microservice-frontend, Svelte + Nginx)
- Restaurant Ordering Front (microservice-restaurant-front, Svelte + Nginx)
- Microservices (each as its own container & K8s Deployment + Service)
1. Users API (authentication, JWT)
2. Customers API (customer data, inter-service validation)
3. Restaurants API (catalog: restaurants, menus, menu items)
4. Orders API (orders & order items, pricing via Restaurants API)
- Databases
- One per service (configurable in deployment/docker-compose-build.yaml or K8s env)
- External Services
- AWS S3 (for image uploads)
- CI/CD & Orchestration
- Travis CI (.travis.yml)
- Docker Build/Run scripts
- Kubernetes (deployment/k8s/*.yaml)
- Okteto CD pipeline (okteto-kubernetes-cd)

##### Relationships & Data Flows
- Clients (Browser) → HTTP → API Gateway
- Routes “/admin” to Admin Panel
- Routes “/front” to Restaurant Front
- Routes “/api/users/**” to Users API
- Routes “/api/customers/**” to Customers API
- … similarly for /orders, /restaurants
- Frontends → API Gateway → Microservices
- Microservices ↔ Databases (own RDBMS via Sequelize)
- Inter-Service Calls
- Orders API uses Restaurants API (via Axios/objectRequester) for prices
- Customers API verifies with Orders API
- Restaurants API may fetch user info from Users API
- Authentication
- User logs in via Users API → receives JWT
- JWT passed in Authorization headers to all services
- AWS S3
- Any service that needs to upload/fetch images calls AWS SDK

##### Architectural Patterns & Tech
- Microservices pattern: independent deployable services
- API Gateway pattern: single entry point & routing
- Shared JWT secret for stateless auth across services
- Containerized with Docker, orchestrated by Kubernetes
- Each service uses Express.js + Hapi/Joi for validation + Sequelize for ORM
- Svelte for highly reactive frontends, served via Nginx

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Browser["Browser"]:::external

    %% API Gateway
    APIGateway["API Gateway\n(Nginx)"]:::gateway

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        direction TB

        subgraph "Frontends"
            direction TB
            AdminPanel["Admin Panel\n(Svelte + Nginx)"]:::frontend
            RestaurantFront["Restaurant Front\n(Svelte + Nginx)"]:::frontend
        end

        subgraph "Microservices"
            direction TB
            UsersAPI["Users API\n(Express, TS)"]:::service
            CustomersAPI["Customers API\n(Express, TS)"]:::service
            RestaurantsAPI["Restaurants API\n(Express, TS)"]:::service
            OrdersAPI["Orders API\n(Express, TS)"]:::service
        end

        subgraph "Databases"
            direction TB
            DBUsers["Users DB\n(Postgres)"]:::db
            DBCustomers["Customers DB\n(Postgres)"]:::db
            DBRestaurants["Restaurants DB\n(Postgres)"]:::db
            DBOrders["Orders DB\n(Postgres)"]:::db
        end
    end

    %% External
    AWS["AWS S3"]:::external

    %% CI/CD
    subgraph "CI/CD & Orchestration"
        direction TB
        TravisCI["Travis CI"]:::ci
        DockerBuild["Docker Build"]:::ci
        OktetoCD["Okteto CD"]:::ci
        Kubernetes["Kubernetes Manifests"]:::ci
    end

    %% Flows
    Browser -->|HTTP| APIGateway
    APIGateway -->|/admin| AdminPanel
    APIGateway -->|/front| RestaurantFront
    APIGateway -->|/api/users/**| UsersAPI
    APIGateway -->|/api/customers/**| CustomersAPI
    APIGateway -->|/api/restaurants/**| RestaurantsAPI
    APIGateway -->|/api/orders/**| OrdersAPI

    AdminPanel -->|HTTP| APIGateway
    RestaurantFront -->|HTTP| APIGateway

    UsersAPI -->|reads/writes| DBUsers
    CustomersAPI -->|reads/writes| DBCustomers
    RestaurantsAPI -->|reads/writes| DBRestaurants
    OrdersAPI -->|reads/writes| DBOrders

    OrdersAPI -->|HTTP/JWT| RestaurantsAPI
    CustomersAPI -->|HTTP/JWT| OrdersAPI
    RestaurantsAPI -->|HTTP/JWT| UsersAPI

    UsersAPI -->|AWS SDK| AWS
    CustomersAPI -->|AWS SDK| AWS
    RestaurantsAPI -->|AWS SDK| AWS
    OrdersAPI -->|AWS SDK| AWS

    TravisCI -->|build/trust| DockerBuild
    DockerBuild -->|deploy| OktetoCD
    OktetoCD -->|apply manifests| Kubernetes

    %% Click Events - API Gateway
    click APIGateway "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/docker/nginx.conf"
    click APIGateway "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/restaurant-reverseproxy-deployment.yaml"
    click APIGateway "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/restaurant-reverseproxy-service.yaml"
    click APIGateway "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/restaurant-reverseproxy-endpoint.yaml"

    %% Click Events - Frontends
    click AdminPanel "https://github.com/adamhingoro/micro-restaurants/tree/master/microservice-frontend/"
    click AdminPanel "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/admin-panel-deployment.yaml"
    click AdminPanel "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/admin-panel-service.yaml"

    click RestaurantFront "https://github.com/adamhingoro/micro-restaurants/tree/master/microservice-restaurant-front/"
    click RestaurantFront "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/frontend-deployment.yaml"
    click RestaurantFront "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/frontend-service.yaml"

    %% Click Events - Users API
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-users-api/src/index.ts"
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/tree/master/microservice-users-api/src/controllers/v0/"
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-users-api/src/models/User.ts"
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-users-api/src/util/objectRequester.ts"
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-users-api/src/util/AWS.ts"
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-users-api-deployment.yaml"
    click UsersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-users-api-service.yaml"

    %% Click Events - Customers API
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-customers-api/src/index.ts"
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/tree/master/microservice-customers-api/src/controllers/v0/"
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-customers-api/src/models/Customer.ts"
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-customers-api/src/util/objectRequester.ts"
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-customers-api/src/util/AWS.ts"
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-customers-api-deployment.yaml"
    click CustomersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-customers-api-service.yaml"

    %% Click Events - Restaurants API
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-restaurants-api/src/index.ts"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/tree/master/microservice-restaurants-api/src/controllers/v0/"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-restaurants-api/src/models/Restaurant.ts"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-restaurants-api/src/models/Menu.ts"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-restaurants-api/src/models/MenuItem.ts"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-restaurants-api/src/util/objectRequester.ts"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-restaurants-api/src/util/AWS.ts"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-restaurants-api-deployment.yaml"
    click RestaurantsAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-restaurants-api-service.yaml"

    %% Click Events - Orders API
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-orders-api/src/index.ts"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/tree/master/microservice-orders-api/src/controllers/v0/"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-orders-api/src/models/Order.ts"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-orders-api/src/models/OrderItem.ts"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-orders-api/src/util/objectRequester.ts"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/microservice-orders-api/src/util/AWS.ts"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-orders-api-deployment.yaml"
    click OrdersAPI "https://github.com/adamhingoro/micro-restaurants/blob/master/deployment/k8s/microservice-orders-api-service.yaml"

    %% Click Events - CI/CD
    click TravisCI "https://github.com/adamhingoro/micro-restaurants/blob/master/.travis.yml"
    click Kubernetes "https://github.com/adamhingoro/micro-restaurants/tree/master/deployment/k8s/"

    %% Styles
    classDef frontend fill:#87CEFA,stroke:#4682B4,color:#000
    classDef service fill:#90EE90,stroke:#228B22,color:#000
    classDef db fill:#FFE4B5,stroke:#DAA520,color:#000
    classDef gateway fill:#FFA500,stroke:#FF8C00,color:#000
    classDef external fill:#D3D3D3,stroke:#A9A9A9,color:#000
    classDef ci fill:#E6E6FA,stroke:#9370DB,color:#000
```
