# yjl9903/resonance-market architecture

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

- Interactive diagram: https://gitdiagram.com/yjl9903/resonance-market
- Repository: https://github.com/yjl9903/resonance-market

## Overview

##### Main Components

a) Frontend Layer:
- Vue.js/Nuxt.js application structure
- UI Components (from the extensive /components/ui directory)
- Pages and Layouts
- Client-side stores (from /stores directory)

b) Backend Layer:
- Server API endpoints (from /server/api directory)
- Database layer (SQLite with Drizzle ORM)
- Caching system (indicated by server/utils/cache.ts)

c) External Services:
- GitHub Actions for CI/CD
- Cloudflare Workers (indicated by wrangler.toml)

**[Client Layer]**
- ↑↓
**[API Layer]**
- ↑↓
**[Data Layer]**

##### Specific Elements

Frontend Components:
- Sub-sections for:
- Pages (market view, transaction planning, reports)
- UI Components (shadcn/ui components)
- State Management (stores)
- Composables

API Layer:
- /api/log (POST)
- /api/logs (POST - batch upload)
- /api/info/* (GET - cities and products)
- /api/product (GET)
- /api/stream/product (real-time updates)

Data Layer:
- SQLite Database with Drizzle ORM
- Cache System
- Product Data Storage

##### Important Flows to Highlight

- Market Data Upload Flow:
- Client → API (/api/log or /api/logs) → Database
- Product Information Flow:
- Database → Cache → API → Client
- Real-time Updates:
- Stream API → Client

##### Deployment Architecture

Serverless architecture:
**[Cloudflare Pages] ← [GitHub Actions] → [Cloudflare D1 (Database)]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Frontend Application]
        UI[UI Components]
        Pages[Application Pages]
        Layout[Application Layout]
        Store[State Management]
        
        FE --> UI
        FE --> Pages
        FE --> Layout
        FE --> Store
    end

    subgraph API
        EP[API Endpoints]
        LOG["/api/log"]
        LOGS["/api/logs"]
        INFO["/api/info"]
        PROD["/api/product"]
        STREAM["/api/stream/product"]
        
        EP --> LOG
        EP --> LOGS
        EP --> INFO
        EP --> PROD
        EP --> STREAM
    end

    subgraph Data
        DB[(Database Layer)]
        Cache[(Cache System)]
        DBUtils[Database Utilities]
        QueryUtils[Query Utilities]
        
        DB <--> DBUtils
        DB <--> QueryUtils
        DBUtils <--> Cache
    end

    subgraph External
        GH[GitHub Actions]
        CF[Cloudflare Workers]
    end

    subgraph Features
        ML[Market Logging]
        TP[Transaction Planning]
        MR[Market Reports]
        PI[Product Information]
    end

    Client --> API
    API --> Data
    External --> API
    Features --> Client

    %% Component Mappings
    click UI "https://github.com/yjl9903/resonance-market/tree/main/components/ui/"
    click Pages "https://github.com/yjl9903/resonance-market/tree/main/pages/"
    click Layout "https://github.com/yjl9903/resonance-market/blob/main/layouts/default.vue"
    click Store "https://github.com/yjl9903/resonance-market/tree/main/stores/"
    click EP "https://github.com/yjl9903/resonance-market/tree/main/server/api/"
    click DB "https://github.com/yjl9903/resonance-market/tree/main/drizzle/schema/"
    click Cache "https://github.com/yjl9903/resonance-market/blob/main/server/utils/cache.ts"
    click DBUtils "https://github.com/yjl9903/resonance-market/blob/main/server/utils/database.ts"
    click QueryUtils "https://github.com/yjl9903/resonance-market/blob/main/server/utils/query.ts"
    click GH "https://github.com/yjl9903/resonance-market/tree/main/.github/workflows/"
    click CF "https://github.com/yjl9903/resonance-market/blob/main/wrangler.toml"
    click ML "https://github.com/yjl9903/resonance-market/blob/main/components/CreateLog.vue"
    click TP "https://github.com/yjl9903/resonance-market/tree/main/pages/transaction/"
    click MR "https://github.com/yjl9903/resonance-market/tree/main/pages/report/"
    click PI "https://github.com/yjl9903/resonance-market/tree/main/pages/product/"
    click LOG "https://github.com/yjl9903/resonance-market/tree/main/server/api/log/"
    click INFO "https://github.com/yjl9903/resonance-market/tree/main/server/api/info/"
    click STREAM "https://github.com/yjl9903/resonance-market/blob/main/server/api/stream/product.ts"

    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef api fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef data fill:#f1c40f,stroke:#f39c12,color:#000
    classDef external fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef features fill:#e74c3c,stroke:#c0392b,color:#fff

    class FE,UI,Pages,Layout,Store frontend
    class EP,LOG,LOGS,INFO,PROD,STREAM api
    class DB,Cache,DBUtils,QueryUtils data
    class GH,CF external
    class ML,TP,MR,PI features
```
