# shizlie/hcproduct-switchboard-mockup architecture

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

- Interactive diagram: https://gitdiagram.com/shizlie/hcproduct-switchboard-mockup
- Repository: https://github.com/shizlie/hcproduct-switchboard-mockup

## Overview

##### Main Components

a) Client Layer:
- Website (Static HTML files)
- Connection to API endpoints

b) API Gateway Layer:
- AWS API Gateway (implied from Lambda usage)
- Custom domain (switchboard.harrycorn.com)

c) Compute Layer:
- AWS Lambda Functions
- Caching mechanism using Ephemeral Storage (/tmp)
- Reserved Concurrency settings (10 instances)

d) Data Processing Layer:
- Query Processing Service
- Data Processing Service
- Logging Service

e) Database Layer:
- Supabase (as indicated by config files)

**[Client Layer]**
- ↓
**[API Gateway]**
- ↓
**[Lambda Function]**
- ↙     ↘
**[Cache]  [Processing Services]**
- ↓
**[Database]**

##### Important Details to Highlight

a) Lambda Configuration:
- 10GB Ephemeral Storage allocation
- Reserved Concurrency (10 instances)
- Cold start (7s) vs. warm start (1.2s-2s) times

b) Service Integration:
- Relationship between API management and API usage routes
- Data flow through processing services

##### Additional Elements

- A metrics/logging flow showing how usage patterns are collected
- Caching mechanism's interaction with the main processing flow
- Where future Evidence.dev integration might fit for log analysis

##### Technical Notes

- Node.js runtime environment
- Supabase integration points
- API endpoint routing structure
- Cache invalidation flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL[Client Layer]
        WH[Home]:::client
        WB[Blog]:::client
        WE[Error]:::client
    end

    %% API Gateway Layer
    subgraph AG[API Gateway Layer]
        APIG[AWS API Gateway]:::aws
        CD[Custom Domain]:::aws
    end

    %% Lambda Function Layer
    subgraph LF[Lambda Function Layer]
        LFM[Main Lambda Function]:::aws
        LFC[Cache Handler]:::aws
        note1[10GB Ephemeral Storage]:::note
        note2[10 Reserved Instances]:::note
    end

    %% Processing Layer
    subgraph PL[Processing Services Layer]
        DP[Data Processing]:::service
        QP[Query Processing]:::service
        LS[Logging Service]:::service
        AC[App Core]:::service
    end

    %% Database Layer
    subgraph DB[Database Layer]
        SB[Supabase]:::database
        EF[Edge Functions]:::database
    end

    %% Connections
    CL --> AG
    AG --> LF
    LF --> PL
    LF --> LFC
    PL --> DB
    LFC --> DB

    %% Performance Paths
    subgraph PS[Performance Scenarios]
        direction TB
        CS[Cold Start - 7s]:::perf
        WS[Warm Start - 1.2-2s]:::perf
        CH[Cache Hit]:::perf
        CM[Cache Miss]:::perf
    end

    %% Styling
    classDef client fill:#6495ED
    classDef aws fill:#90EE90
    classDef service fill:#FFD700
    classDef database fill:#9370DB
    classDef cache fill:#FF6347
    classDef note fill:#F0F0F0
    classDef perf fill:#DEB887

    %% Click Events
    click WH "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//website/home.html"
    click WB "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//website/blog.html"
    click WE "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//website/error.html"
    click LFM "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//lambda/index.js"
    click LFC "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//lambda/api-cache.js"
    click DP "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//src-nodejs/services/dataProcessing.js"
    click QP "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//src-nodejs/services/queryProcessing.js"
    click LS "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//src-nodejs/services/logging.js"
    click SB "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//src-nodejs/config/supabase.js"
    click EF "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//supabase/functions/api-usage/index.ts"
    click AC "https://github.com/shizlie/hcproduct-switchboard-mockup/blob/main//src-nodejs/app.js"

    %% Legend
    subgraph Legend
        L1[Client Components]:::client
        L2[AWS Services]:::aws
        L3[Processing Services]:::service
        L4[Database Components]:::database
        L5[Cache Components]:::cache
        L6[Performance Metrics]:::perf
    end
```
