# saviganga/flolyt architecture

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

- Interactive diagram: https://gitdiagram.com/saviganga/flolyt
- Repository: https://github.com/saviganga/flolyt

## Overview

flolyt-go is an HTTP API whose evidenced domain workflow creates or fetches an Airbyte access token, refreshing expired tokens before persisting the replacement. Startup wires configuration, logging, database access, the Airbyte provider, and HTTP routes. The README also documents a standalone database migration command. The graph follows relationships shown in excerpts or the source index; unsampled modules and optional wiring are not inferred.

Main entry points: [`main.go`](https://github.com/saviganga/flolyt/blob/main/main.go) (Application Startup), [`internal/services/data_ingest/data_ingest.go`](https://github.com/saviganga/flolyt/blob/main/internal/services/data_ingest/data_ingest.go) (Token Service), [`internal/database/implementation.go`](https://github.com/saviganga/flolyt/blob/main/internal/database/implementation.go) (GORM Repository), [`cmd/migrate.go`](https://github.com/saviganga/flolyt/blob/main/cmd/migrate.go) (Migration Command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["HTTP Server<br/>[server.go]"]
  node_routes["Versioned Routes<br/>[routes.go]"]
  node_token_handlers["Token Handlers<br/>[data_ingest.go]"]
  node_hello_handler["Hello Handler<br/>[hello.go]"]
  node_responses["API Responses<br/>[responses.go]"]
end

subgraph group_domain["Token Workflow"]
  node_token_service["Token Service<br/>[data_ingest.go]"]
  node_airbyte_provider["Airbyte Provider<br/>[airbyte.go]"]
  node_token_record["Token Record<br/>[airbyte.go]"]
end

subgraph group_infra["Runtime Infrastructure"]
  node_main["Application Startup<br/>[main.go]"]
  node_repository["GORM Repository<br/>[implementation.go]"]
  node_postgres[("PostgreSQL")]
  node_configuration["Configuration<br/>[env.go]"]
  node_database_config["Database Setup<br/>[db.go]"]
  node_logger["Application Logger<br/>[logger.go]"]
  node_http_util["HTTP Utilities<br/>[utils.go]"]
end

subgraph group_ops["Database Migration"]
  node_migration_cli["Migration Command<br/>[migrate.go]"]
  node_migration_files["Schema Migrations"]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"registers endpoints"| node_token_handlers
node_routes -->|"registers endpoint"| node_hello_handler
node_token_handlers -->|"calls"| node_token_service
node_token_handlers -->|"formats replies"| node_responses
node_hello_handler -->|"uses response helpers"| node_responses
node_token_service -->|"reads and writes"| node_repository
node_token_service -->|"requests token"| node_airbyte_provider
node_token_service -->|"logs failures"| node_logger
node_repository -->|"maps records"| node_token_record
node_repository -.->|"queries"| node_postgres
node_airbyte_provider -->|"sends request"| node_http_util
node_main -->|"loads config"| node_configuration
node_main -->|"opens database"| node_database_config
node_main -->|"creates repository"| node_repository
node_main -->|"creates provider"| node_airbyte_provider
node_main -->|"initializes logger"| node_logger
node_main -->|"starts server"| node_server
node_migration_cli -->|"loads config"| node_configuration
node_migration_cli -.->|"applies migrations"| node_migration_files
node_migration_cli -->|"migrates schema"| node_postgres

click node_main "https://github.com/saviganga/flolyt/blob/main/main.go"
click node_server "https://github.com/saviganga/flolyt/blob/main/api/server.go"
click node_routes "https://github.com/saviganga/flolyt/blob/main/api/v1/routes.go"
click node_token_handlers "https://github.com/saviganga/flolyt/blob/main/api/v1/handlers/data_ingest/data_ingest.go"
click node_hello_handler "https://github.com/saviganga/flolyt/blob/main/api/v1/handlers/hello/hello.go"
click node_responses "https://github.com/saviganga/flolyt/blob/main/api/utils/responses.go"
click node_token_service "https://github.com/saviganga/flolyt/blob/main/internal/services/data_ingest/data_ingest.go"
click node_airbyte_provider "https://github.com/saviganga/flolyt/blob/main/external/data_ingest/airbyte.go"
click node_repository "https://github.com/saviganga/flolyt/blob/main/internal/database/implementation.go"
click node_token_record "https://github.com/saviganga/flolyt/blob/main/internal/database/tables/airbyte.go"
click node_configuration "https://github.com/saviganga/flolyt/blob/main/config/env.go"
click node_database_config "https://github.com/saviganga/flolyt/blob/main/config/db.go"
click node_logger "https://github.com/saviganga/flolyt/blob/main/internal/logger/logger.go"
click node_http_util "https://github.com/saviganga/flolyt/blob/main/internal/utils/httputil/utils.go"
click node_migration_cli "https://github.com/saviganga/flolyt/blob/main/cmd/migrate.go"
click node_migration_files "https://github.com/saviganga/flolyt/tree/main/migrations"

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_server,node_routes,node_token_handlers,node_hello_handler,node_responses,node_client toneBlue
class node_token_service,node_airbyte_provider,node_token_record toneAmber
class node_main,node_repository,node_postgres,node_configuration,node_database_config,node_logger,node_http_util toneMint
class node_migration_cli,node_migration_files toneRose
```

## Components

### HTTP API

- [HTTP Server](https://github.com/saviganga/flolyt/blob/main/api/server.go): `api/server.go`
- [Versioned Routes](https://github.com/saviganga/flolyt/blob/main/api/v1/routes.go): `api/v1/routes.go`
- [Token Handlers](https://github.com/saviganga/flolyt/blob/main/api/v1/handlers/data_ingest/data_ingest.go): `api/v1/handlers/data_ingest/data_ingest.go`
- [Hello Handler](https://github.com/saviganga/flolyt/blob/main/api/v1/handlers/hello/hello.go): `api/v1/handlers/hello/hello.go`
- [API Responses](https://github.com/saviganga/flolyt/blob/main/api/utils/responses.go): `api/utils/responses.go`

### Token Workflow

- [Token Service](https://github.com/saviganga/flolyt/blob/main/internal/services/data_ingest/data_ingest.go): `internal/services/data_ingest/data_ingest.go`
- [Airbyte Provider](https://github.com/saviganga/flolyt/blob/main/external/data_ingest/airbyte.go): `external/data_ingest/airbyte.go`
- [Token Record](https://github.com/saviganga/flolyt/blob/main/internal/database/tables/airbyte.go): `internal/database/tables/airbyte.go`

### Runtime Infrastructure

- [Application Startup](https://github.com/saviganga/flolyt/blob/main/main.go): `main.go`
- [GORM Repository](https://github.com/saviganga/flolyt/blob/main/internal/database/implementation.go): `internal/database/implementation.go`
- **PostgreSQL**
- [Configuration](https://github.com/saviganga/flolyt/blob/main/config/env.go): `config/env.go`
- [Database Setup](https://github.com/saviganga/flolyt/blob/main/config/db.go): `config/db.go`
- [Application Logger](https://github.com/saviganga/flolyt/blob/main/internal/logger/logger.go): `internal/logger/logger.go`
- [HTTP Utilities](https://github.com/saviganga/flolyt/blob/main/internal/utils/httputil/utils.go): `internal/utils/httputil/utils.go`

### Database Migration

- [Migration Command](https://github.com/saviganga/flolyt/blob/main/cmd/migrate.go): `cmd/migrate.go`
- [Schema Migrations](https://github.com/saviganga/flolyt/tree/main/migrations): `migrations`

### Other components

- **API Client**

## Connections

- API Client → HTTP Server: sends requests (evidence: `api/server.go`)
- HTTP Server → Versioned Routes: mounts routes (evidence: `api/server.go`)
- Versioned Routes → Token Handlers: registers endpoints (evidence: `api/v1/routes.go`)
- Versioned Routes → Hello Handler: registers endpoint (evidence: `api/v1/routes.go`)
- Token Handlers → Token Service: calls (evidence: `api/v1/handlers/data_ingest/data_ingest.go`)
- Token Handlers → API Responses: formats replies (evidence: `api/v1/handlers/data_ingest/data_ingest.go`)
- Hello Handler → API Responses: uses response helpers (evidence: `api/v1/handlers/hello/hello.go`)
- Token Service → GORM Repository: reads and writes (evidence: `internal/services/data_ingest/data_ingest.go`)
- Token Service → Airbyte Provider: requests token (evidence: `internal/services/data_ingest/data_ingest.go`)
- Token Service → Application Logger: logs failures (evidence: `internal/services/data_ingest/data_ingest.go`)
- GORM Repository → Token Record: maps records (evidence: `internal/database/implementation.go`)
- GORM Repository → PostgreSQL: queries
- Airbyte Provider → HTTP Utilities: sends request (evidence: `external/data_ingest/airbyte.go`)
- Application Startup → Configuration: loads config (evidence: `main.go`)
- Application Startup → Database Setup: opens database (evidence: `main.go`)
- Application Startup → GORM Repository: creates repository (evidence: `main.go`)
- Application Startup → Airbyte Provider: creates provider (evidence: `main.go`)
- Application Startup → Application Logger: initializes logger (evidence: `main.go`)
- Application Startup → HTTP Server: starts server (evidence: `main.go`)
- Migration Command → Configuration: loads config (evidence: `cmd/migrate.go`)
- Migration Command → Schema Migrations: applies migrations (evidence: `README.md`)
- Migration Command → PostgreSQL: migrates schema (evidence: `cmd/migrate.go`)
