# kaiman30/hakaton-ldt-backend architecture

> Architecture diagram of the GitHub repository kaiman30/hakaton-ldt-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaiman30/hakaton-ldt-backend
- Repository: https://github.com/kaiman30/hakaton-ldt-backend

## Overview

This repository contains three distinct services: an API gateway, an authentication service, and a reusable ML-service core. Their likely user-facing flow begins with an API client calling a service endpoint, but the README is empty and the sampled files do not establish how the gateway routes requests or how the services connect. The ML core provides runtime coordination and connector interfaces for broker, database, LLM, HTTP, and storage operations. Its sampled pipeline and connector code supports a few internal relationships; links beyond that are omitted rather than inferred.

Main entry points: [`ML-Service-Core/core/base_class/base_interface.py`](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/base_class/base_interface.py) (Base Interface), [`ML-Service-Core/ports/protocols.py`](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/protocols.py) (Connector Protocols), [`ML-Service-Core/ports/inbound/broker/queue.py`](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/inbound/broker/queue.py) (Broker Port), [`ML-Service-Core/ports/outbound/db/db.py`](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/db/db.py) (Database Port)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Gateway"]
  node_gateway["Gateway API<br/>[router.go]"]
  node_gatewayauth["Auth Middleware<br/>[auth.go]"]
  node_gatewayhealth["Health Handler<br/>[health.go]"]
end

subgraph group_auth["Authentication"]
  node_authapi["Auth API<br/>[auth.go]"]
  node_authmiddleware["Auth Middleware<br/>[auth.go]"]
  node_jwt["JWT Service<br/>[jwt.go]"]
  node_authrepo["Auth Repository<br/>[repository.go]"]
  node_postgres[("Postgres Pool<br/>[pool.go]")]
  node_authhealth["Health Handler<br/>[health.go]"]
end

subgraph group_mlruntime["ML Runtime"]
  node_pipeline["Runtime Pipeline<br/>[pipeline.py]"]
  node_appstate["Application State<br/>[app_state.py]"]
  node_eventbus["Event Bus<br/>[event_bus.py]"]
  node_container["Service Container"]
  node_registry["Connector Registry<br/>[registry.py]"]
  node_baseinterface["Base Interface<br/>[base_interface.py]"]
  node_logging["Runtime Logging<br/>[logging.py]"]
end

subgraph group_mlports["Connector Ports"]
  node_broker["Broker Port<br/>[queue.py]"]
  node_brokerdto["Broker DTOs<br/>[dto.py]"]
  node_dbport["Database Port<br/>[db.py]"]
  node_dbdto["Database DTOs<br/>[dto.py]"]
  node_llmport["LLM Port<br/>[llm.py]"]
  node_llmdto["LLM DTOs<br/>[dto.py]"]
  node_httpport["HTTP Port<br/>[http.py]"]
  node_httpdto["HTTP DTOs<br/>[dto.py]"]
  node_storageport["Storage Port<br/>[storage.py]"]
  node_storagedto["Storage DTOs<br/>[dto.py]"]
  node_protocols["Connector Protocols<br/>[protocols.py]"]
end

node_client(("API Client"))

node_client -.->|"calls API"| node_gateway
node_client -.->|"requests auth"| node_authapi
node_pipeline -->|"starts runtimes"| node_appstate
node_pipeline -->|"accepts bus"| node_eventbus
node_baseinterface -->|"publishes events"| node_eventbus
node_baseinterface -->|"implements base"| node_protocols
node_storageport -->|"extends interface"| node_baseinterface
node_storageport -->|"uses DTOs"| node_storagedto
node_llmport -->|"extends interface"| node_baseinterface
node_llmport -->|"uses DTOs"| node_llmdto
node_broker -->|"uses DTOs"| node_brokerdto
node_broker -->|"extends interface"| node_baseinterface
node_dbport -->|"uses DTOs"| node_dbdto
node_dbport -->|"extends interface"| node_baseinterface
node_httpport -->|"uses DTOs"| node_httpdto
node_httpport -->|"extends interface"| node_baseinterface
node_storageport -->|"implements protocol"| node_protocols
node_llmport -->|"implements protocol"| node_protocols
node_broker -->|"implements protocol"| node_protocols
node_dbport -->|"implements protocol"| node_protocols
node_httpport -->|"implements protocol"| node_protocols

click node_gateway "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/API-Gateway/internal/api/router.go"
click node_gatewayauth "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/API-Gateway/internal/api/middleware/auth.go"
click node_gatewayhealth "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/API-Gateway/internal/api/handler/health.go"
click node_authapi "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/api/handler/auth.go"
click node_authmiddleware "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/api/middleware/auth.go"
click node_jwt "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/auth/jwt.go"
click node_authrepo "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/auth/repository.go"
click node_postgres "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/platform/postgres/pool.go"
click node_authhealth "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/api/handler/health.go"
click node_pipeline "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/runtime/pipeline.py"
click node_appstate "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/runtime/app_state.py"
click node_eventbus "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/runtime/event_bus.py"
click node_container "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/di/service_container.py"
click node_registry "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/registry/registry.py"
click node_baseinterface "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/base_class/base_interface.py"
click node_logging "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/infrastructure/internal/logging.py"
click node_broker "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/inbound/broker/queue.py"
click node_brokerdto "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/inbound/broker/dto.py"
click node_dbport "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/db/db.py"
click node_dbdto "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/db/dto.py"
click node_llmport "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/ml/llm/llm.py"
click node_llmdto "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/ml/llm/dto.py"
click node_httpport "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/network/http.py"
click node_httpdto "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/network/dto.py"
click node_storageport "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/storage/storage.py"
click node_storagedto "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/storage/dto.py"
click node_protocols "https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/protocols.py"

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_gateway,node_gatewayauth,node_gatewayhealth,node_client toneBlue
class node_authapi,node_authmiddleware,node_jwt,node_authrepo,node_postgres,node_authhealth toneAmber
class node_pipeline,node_appstate,node_eventbus,node_container,node_registry,node_baseinterface,node_logging toneMint
class node_broker,node_brokerdto,node_dbport,node_dbdto,node_llmport,node_llmdto,node_httpport,node_httpdto,node_storageport,node_storagedto,node_protocols toneRose
```

## Components

### API Gateway

- [Gateway API](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/API-Gateway/internal/api/router.go): `API-Gateway/internal/api/router.go`
- [Auth Middleware](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/API-Gateway/internal/api/middleware/auth.go): `API-Gateway/internal/api/middleware/auth.go`
- [Health Handler](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/API-Gateway/internal/api/handler/health.go): `API-Gateway/internal/api/handler/health.go`

### Authentication

- [Auth API](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/api/handler/auth.go): `AuthService/internal/api/handler/auth.go`
- [Auth Middleware](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/api/middleware/auth.go): `AuthService/internal/api/middleware/auth.go`
- [JWT Service](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/auth/jwt.go): `AuthService/internal/auth/jwt.go`
- [Auth Repository](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/auth/repository.go): `AuthService/internal/auth/repository.go`
- [Postgres Pool](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/platform/postgres/pool.go): `AuthService/internal/platform/postgres/pool.go`
- [Health Handler](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/AuthService/internal/api/handler/health.go): `AuthService/internal/api/handler/health.go`

### ML Runtime

- [Runtime Pipeline](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/runtime/pipeline.py): `ML-Service-Core/core/runtime/pipeline.py`
- [Application State](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/runtime/app_state.py): `ML-Service-Core/core/runtime/app_state.py`
- [Event Bus](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/runtime/event_bus.py): `ML-Service-Core/core/runtime/event_bus.py`
- [Service Container](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/di/service_container.py): `ML-Service-Core/core/di/service_container.py`
- [Connector Registry](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/registry/registry.py): `ML-Service-Core/core/registry/registry.py`
- [Base Interface](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/core/base_class/base_interface.py): `ML-Service-Core/core/base_class/base_interface.py`
- [Runtime Logging](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/infrastructure/internal/logging.py): `ML-Service-Core/infrastructure/internal/logging.py`

### Connector Ports

- [Broker Port](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/inbound/broker/queue.py): `ML-Service-Core/ports/inbound/broker/queue.py`
- [Broker DTOs](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/inbound/broker/dto.py): `ML-Service-Core/ports/inbound/broker/dto.py`
- [Database Port](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/db/db.py): `ML-Service-Core/ports/outbound/db/db.py`
- [Database DTOs](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/db/dto.py): `ML-Service-Core/ports/outbound/db/dto.py`
- [LLM Port](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/ml/llm/llm.py): `ML-Service-Core/ports/outbound/ml/llm/llm.py`
- [LLM DTOs](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/ml/llm/dto.py): `ML-Service-Core/ports/outbound/ml/llm/dto.py`
- [HTTP Port](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/network/http.py): `ML-Service-Core/ports/outbound/network/http.py`
- [HTTP DTOs](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/network/dto.py): `ML-Service-Core/ports/outbound/network/dto.py`
- [Storage Port](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/storage/storage.py): `ML-Service-Core/ports/outbound/storage/storage.py`
- [Storage DTOs](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/outbound/storage/dto.py): `ML-Service-Core/ports/outbound/storage/dto.py`
- [Connector Protocols](https://github.com/kaiman30/hakaton-ldt-backend/blob/main/ML-Service-Core/ports/protocols.py): `ML-Service-Core/ports/protocols.py`

### Other components

- **API Client**

## Connections

- API Client → Gateway API: calls API
- API Client → Auth API: requests auth
- Runtime Pipeline → Application State: starts runtimes (evidence: `ML-Service-Core/core/runtime/pipeline.py`)
- Runtime Pipeline → Event Bus: accepts bus (evidence: `ML-Service-Core/core/runtime/pipeline.py`)
- Base Interface → Event Bus: publishes events (evidence: `ML-Service-Core/core/base_class/base_interface.py`)
- Base Interface → Connector Protocols: implements base (evidence: `ML-Service-Core/core/base_class/base_interface.py`)
- Storage Port → Base Interface: extends interface (evidence: `ML-Service-Core/ports/outbound/storage/storage.py`)
- Storage Port → Storage DTOs: uses DTOs (evidence: `ML-Service-Core/ports/outbound/storage/storage.py`)
- LLM Port → Base Interface: extends interface (evidence: `ML-Service-Core/ports/outbound/ml/llm/llm.py`)
- LLM Port → LLM DTOs: uses DTOs (evidence: `ML-Service-Core/ports/outbound/ml/llm/llm.py`)
- Broker Port → Broker DTOs: uses DTOs (evidence: `ML-Service-Core/ports/inbound/broker/queue.py`)
- Broker Port → Base Interface: extends interface (evidence: `ML-Service-Core/ports/inbound/broker/queue.py`)
- Database Port → Database DTOs: uses DTOs (evidence: `ML-Service-Core/ports/outbound/db/db.py`)
- Database Port → Base Interface: extends interface (evidence: `ML-Service-Core/ports/outbound/db/db.py`)
- HTTP Port → HTTP DTOs: uses DTOs (evidence: `ML-Service-Core/ports/outbound/network/http.py`)
- HTTP Port → Base Interface: extends interface (evidence: `ML-Service-Core/ports/outbound/network/http.py`)
- Storage Port → Connector Protocols: implements protocol (evidence: `ML-Service-Core/ports/outbound/storage/storage.py`)
- LLM Port → Connector Protocols: implements protocol (evidence: `ML-Service-Core/ports/outbound/ml/llm/llm.py`)
- Broker Port → Connector Protocols: implements protocol (evidence: `ML-Service-Core/ports/inbound/broker/queue.py`)
- Database Port → Connector Protocols: implements protocol (evidence: `ML-Service-Core/ports/outbound/db/db.py`)
- HTTP Port → Connector Protocols: implements protocol (evidence: `ML-Service-Core/ports/outbound/network/http.py`)
