# swiggy/grill architecture

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

- Interactive diagram: https://gitdiagram.com/swiggy/grill
- Repository: https://github.com/swiggy/grill

## Overview

##### Main Components

a) Core Framework Layer:
- TestCase Orchestrator (represented by test_case.go, runner.go)
- Action Handler (action.go)
- Lifecycle Manager (lifecycle.go)
- Core Interfaces (types.go)

b) Infrastructure Adapters Layer (pkg/):
- Database Adapters (MySQL, DynamoDB, Redis, Elasticsearch)
- Message Queue Adapters (Kafka, SQS)
- Service Discovery (Consul)
- Storage (S3/MinIO)
- Communication (HTTP, gRPC)
- Geospatial (Tile38)

c) Canned Configurations Layer (canned/):
- Pre-configured implementations for each supported infrastructure

**┌─────────────────────────────────────────────────────┐**
- Test Client Layer                  │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Core Framework Layer                 │
- ┌─────────┐  ┌─────────┐  ┌─────────┐  ┌───────┐  │
- TestCase │←→│ Runner  │←→│Lifecycle│←→│Actions│  │
- ┘  └─────────┘  └─────────┘  └───────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Infrastructure Adapters                │
- ┌────────┐ ┌─────┐ ┌────────┐ ┌────────────────┐  │
- Database│ │Queue│ │Storage │ │Communication    │  │
- ┘ └─────┘ └────────┘ └────────────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Container Management                    │
- (testcontainers-go)                  │
- ┘

##### Important Relationships

- How TestCase struct connects with Stubs, Assertions, and Cleaners interfaces
- Relationship between infrastructure adapters and their corresponding canned implementations
- Demonstrate how testcontainers-go manages the containerized dependencies
- Interaction flow from test client through the framework to the infrastructure

##### Additional Details

- Annotations showing supported features for each infrastructure component
- Version compatibility information
- Test flow direction with numbered steps

##### Implementation Notes

- Error handling and cleanup flows
- How the framework integrates with Go's testing package

Remember to highlight the key value proposition: the ability to test microservices from a user's perspective while managing all infrastructure dependencies through a unified interface.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#4d88ff
    classDef infra fill:#b3ffb3,stroke:#4d994d
    classDef container fill:#ffd9b3,stroke:#ff9933
    classDef queue fill:#ffb3d9,stroke:#ff4d94
    classDef db cylinder
    classDef legend fill:none,stroke:#666

    %% Test Client Layer
    TestClient["Test Client"]:::core

    %% Core Framework Layer
    subgraph CoreFramework["Core Framework Layer"]
        TestCase["TestCase Orchestrator"]:::core
        Runner["Test Runner"]:::core
        Lifecycle["Lifecycle Manager"]:::core
        Actions["Action Handler"]:::core
        Types["Core Interfaces"]:::core
    end

    %% Infrastructure Adapters Layer
    subgraph InfraAdapters["Infrastructure Adapters"]
        %% Databases
        subgraph Databases["Databases"]
            MySQL[(MySQL)]:::db
            DynamoDB[(DynamoDB)]:::db
            Redis[(Redis)]:::db
            Elasticsearch[(Elasticsearch)]:::db
        end

        %% Message Queues
        subgraph Queues["Message Queues"]
            Kafka{{"Kafka"}}:::queue
            SQS{{"SQS"}}:::queue
        end

        %% Other Services
        subgraph Services["Services"]
            Consul(("Consul")):::infra
            S3["S3/MinIO"]:::infra
            HTTP["HTTP Client"]:::infra
            GRPC["gRPC Client"]:::infra
            Tile38["Tile38"]:::infra
        end
    end

    %% Container Management Layer
    ContainerMgmt["Container Management (testcontainers-go)"]:::container

    %% Relationships
    TestClient --> TestCase
    TestCase <--> Runner
    Runner <--> Lifecycle
    Lifecycle <--> Actions
    Types --> TestCase
    
    Runner --> InfraAdapters
    InfraAdapters --> ContainerMgmt

    %% Click Events
    click TestCase "https://github.com/Swiggy/grill/blob/master/test_case.go"
    click Runner "https://github.com/Swiggy/grill/blob/master/runner.go"
    click Lifecycle "https://github.com/Swiggy/grill/blob/master/lifecycle.go"
    click Actions "https://github.com/Swiggy/grill/blob/master/action.go"
    click Types "https://github.com/Swiggy/grill/blob/master/types.go"
    click MySQL "https://github.com/Swiggy/grill/blob/master/pkg/grillmysql/mysql.go"
    click DynamoDB "https://github.com/Swiggy/grill/blob/master/pkg/grilldynamo/dynamo.go"
    click Redis "https://github.com/Swiggy/grill/blob/master/pkg/grillredis/redis.go"
    click Elasticsearch "https://github.com/Swiggy/grill/blob/master/pkg/grillelasticsearch/es.go"
    click Kafka "https://github.com/Swiggy/grill/blob/master/pkg/grillkafka/kafka.go"
    click SQS "https://github.com/Swiggy/grill/blob/master/pkg/grillsqs/sqs.go"
    click Consul "https://github.com/Swiggy/grill/blob/master/pkg/grillconsul/consul.go"
    click S3 "https://github.com/Swiggy/grill/blob/master/pkg/grills3/s3.go"
    click HTTP "https://github.com/Swiggy/grill/blob/master/pkg/grillhttp/http.go"
    click GRPC "https://github.com/Swiggy/grill/blob/master/pkg/grillgrpc/grpc.go"
    click Tile38 "https://github.com/Swiggy/grill/blob/master/pkg/grilltile38/tile38.go"

    %% Legend
    subgraph Legend["Legend"]
        L1["Core Components"]:::core
        L2["Infrastructure Components"]:::infra
        L3["Message Queues"]:::queue
        L4["Container Management"]:::container
    end
```
