# useinsider/go-pkg architecture

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

- Interactive diagram: https://gitdiagram.com/useinsider/go-pkg
- Repository: https://github.com/useinsider/go-pkg

## Overview

##### Project type and purpose
- This repository is a Go “monorepo” containing a collection of reusable Go packages (“go-pkg”).
- It is intended to be imported by other Go applications to provide common functionality: caching, error wrapping, logging, metrics (dash), AWS integrations (Kinesis, SQS, SSM), Redis, SQL, HTTP requester, and Sentry.

##### File structure
- Top-level files: go.mod/go.sum, CI workflows (.github/workflows), license, README, SECURITY.MD.
- Each subdirectory (inscacheable, inscodeerr, insdash, inskinesis, inslogger, insredis, insrequester, inssentry, inssimpleroute, inssql, inssqs, insssm) is a standalone package.
- Tests and mocks in many packages indicate a clear boundary for unit testing each component.
- No “application” binary here—this is a library repository.

##### Key README insights
- Lists available packages: Redis, Sentry, Sql, Cacheable, Ssm (and others present in file tree).
- Usage example shows how an external Go program would import the needed sub-package(s).

a. Main components
- Consumer Application
- Core Utility Packages
– inscodeerr (error handling)
– insdash (metrics/monitoring)
– inslogger (structured logging)
– insrequester (HTTP client)
– inscacheable (in-memory or distributed caching abstraction)
– inssimpleroute (URI encoding/decoding helper)
- External Service Adapters
– insredis → Redis
– inssql → SQL-database
– inssentry → Sentry
– inssqs → AWS SQS
– inskinesis → AWS Kinesis
– insssm → AWS SSM Parameter Store
b. Relationships and interactions
- The Consumer Application imports one or more of these packages.
- Core utility packages are independent and can be used standalone or composed.
- Each adapter package manages its own connection to an external system.
- Some adapters rely on core utilities (e.g., insredis may use inslogger for logging).
c. Architectural patterns and design principles
- Modular, package-based design—each folder is a single responsibility.
- Use of interfaces and mocks for easy unit testing and DI (see *_mock.go).
- Separation of concerns: utility vs external service adapters.
- Dependency inversion: application code depends on interfaces, not implementations.
d. Technologies, frameworks, libraries
- Language: Go modules.
- Testing: built-in go test, table-driven tests, mocks/fakes.
- AWS SDK clients wrapped in inskinesis, inssqs, insssm.

##### Detail
- Break out each package as its own node.
- Keep names consistent with import paths (github.com/useinsider/go-pkg/insredis).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Consumer Application
    ConsumerApp["Consumer Application"]:::app

    %% Core Utilities
    subgraph "Core Utilities"
        inscodeerr["inscodeerr\n(err.go)"]:::utility
        insdash["insdash\n(insdash.go)"]:::utility
        inslogger["inslogger\n(inslogger.go)"]:::utility
        insrequester["insrequester\n(requester.go, errors.go)"]:::utility
        inscacheable["inscacheable\n(cacheable.go)"]:::utility
        inssimpleroute["inssimpleroute\n(encode_decode.go,\n simpleroute.go)"]:::utility
    end

    %% External Adapters
    subgraph "External Service Adapters"
        insredis["insredis\n(redis.go)"]:::adapter
        inssql["inssql\n(sql.go)"]:::adapter
        inssentry["inssentry\n(sentry.go)"]:::adapter
        inssqs["inssqs\n(inssqs.go,\n errors.go,\n model.go,\n sqs/iface.go)"]:::adapter
        inskinesis["inskinesis\n(inskinesis.go,\n helper.go,\n partitioners.go)"]:::adapter
        insssm["insssm\n(ssm.go)"]:::adapter
    end

    %% External Systems
    Redis["Redis"]:::external
    SQLDB["SQL Database"]:::external
    SentrySvc["Sentry Service"]:::external
    AWSSQS["AWS SQS"]:::external
    AWSKinesis["AWS Kinesis"]:::external
    AWSSSM["AWS SSM"]:::external

    %% Relationships
    ConsumerApp -->|"uses"| inscodeerr
    ConsumerApp -->|"uses"| insdash
    ConsumerApp -->|"uses"| inslogger
    ConsumerApp -->|"uses"| insrequester
    ConsumerApp -->|"uses"| inscacheable
    ConsumerApp -->|"uses"| inssimpleroute
    ConsumerApp -->|"uses"| insredis
    ConsumerApp -->|"uses"| inssql
    ConsumerApp -->|"uses"| inssentry
    ConsumerApp -->|"uses"| inssqs
    ConsumerApp -->|"uses"| inskinesis
    ConsumerApp -->|"uses"| insssm

    insredis -->|"logs via"| inslogger
    inssql -->|"logs via"| inslogger
    inssql -->|"metrics via"| insdash
    inssqs -->|"logs via"| inslogger
    inskinesis -->|"logs via"| inslogger
    insssm -->|"logs via"| inslogger

    insredis -->|"connects to"| Redis
    inssql -->|"connects to"| SQLDB
    inssentry -->|"reports to"| SentrySvc
    inssqs -->|"sends to"| AWSSQS
    inskinesis -->|"writes to"| AWSKinesis
    insssm -->|"reads from"| AWSSSM

    %% Click Events
    click inscodeerr "https://github.com/useinsider/go-pkg/blob/develop/inscodeerr/err.go"
    click insdash "https://github.com/useinsider/go-pkg/blob/develop/insdash/insdash.go"
    click inslogger "https://github.com/useinsider/go-pkg/blob/develop/inslogger/inslogger.go"
    click insrequester "https://github.com/useinsider/go-pkg/blob/develop/insrequester/requester.go"
    click insrequester "https://github.com/useinsider/go-pkg/blob/develop/insrequester/errors.go"
    click inscacheable "https://github.com/useinsider/go-pkg/blob/develop/inscacheable/cacheable.go"
    click inssimpleroute "https://github.com/useinsider/go-pkg/blob/develop/inssimpleroute/encode_decode.go"
    click inssimpleroute "https://github.com/useinsider/go-pkg/blob/develop/inssimpleroute/simpleroute.go"
    click insredis "https://github.com/useinsider/go-pkg/blob/develop/insredis/redis.go"
    click inssql "https://github.com/useinsider/go-pkg/blob/develop/inssql/sql.go"
    click inssentry "https://github.com/useinsider/go-pkg/blob/develop/inssentry/sentry.go"
    click inssqs "https://github.com/useinsider/go-pkg/blob/develop/inssqs/inssqs.go"
    click inssqs "https://github.com/useinsider/go-pkg/blob/develop/inssqs/errors.go"
    click inssqs "https://github.com/useinsider/go-pkg/blob/develop/inssqs/model.go"
    click inssqs "https://github.com/useinsider/go-pkg/blob/develop/inssqs/sqs/iface.go"
    click inskinesis "https://github.com/useinsider/go-pkg/blob/develop/inskinesis/inskinesis.go"
    click inskinesis "https://github.com/useinsider/go-pkg/blob/develop/inskinesis/helper.go"
    click inskinesis "https://github.com/useinsider/go-pkg/blob/develop/inskinesis/partitioners.go"
    click insssm "https://github.com/useinsider/go-pkg/blob/develop/insssm/ssm.go"

    %% Styles
    classDef app fill:#8dd,stroke:#333,stroke-width:2px
    classDef utility fill:#aed,stroke:#333,stroke-width:1px
    classDef adapter fill:#fea,stroke:#333,stroke-width:1px
    classDef external fill:#ffa,stroke:#333,stroke-width:1px
```
