# ziptalk/kaiseki-frontend-typescript architecture

> Architecture diagram of the GitHub repository ziptalk/kaiseki-frontend-typescript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ziptalk/kaiseki-frontend-typescript
- Repository: https://github.com/ziptalk/kaiseki-frontend-typescript

## Overview

##### Project Type and Purpose
- This is a full‐stack web application built with Next.js (the “app” directory) that serves React pages, implements serverless API endpoints (under app/api), and interacts with blockchain contracts (via ABIs, ethers.js) and external services (Pinata/IPFS, TradingView datafeeds). Its features include token creation, raffles, charting, and on‐chain interactions.

##### High‐Level Architecture Components
a. Client (Browser)
- Renders React pages and components (under app/, components/, layout/)
- Loads static assets (fonts, images, charting_library) from CDN or Next.js public folder
- Embeds TradingView chart UI (public/static/charting_library + custom UDF datafeed)
b. Next.js Server / Serverless Platform (Vercel)
- Page Routes (app/[...]/page.tsx): SSR/SSG & client hydration
- API Routes (app/api/pinata/route.ts): serverless functions for Pinata/IPFS uploads
- Environment & Build: next.config.mjs, .env.example
c. Blockchain Interaction Layer
- utils/ethersProvider.ts and ethersSigner.ts: RPC connections to Ethereum or testnets
- abis/: JSON interfaces & mock providers for smart contracts (ReserveToken, interfaces, lib)
- global/contracts.ts: on‐chain addresses & ABIs
d. External Services
- Ethereum JSON‐RPC (Infura/Alchemy/etc.)
- Pinata/IPFS REST API
- TradingView Datafeed (custom under public/static/datafeeds/udf)
- CDN for charting_library bundles

##### Architectural Patterns & Design Principles
- Separation of Concerns: UI (components/layout) vs. data layer (utils/apis, ethers) vs. static assets vs. API functions
- Serverless Functions: lightweight back‐end under app/api
- Client‐Side Charting: TradingView chart library loaded statically, communicates with a custom UDF provider
- Smart Contract Abstraction: ABIs in “abis/” + ethers provider in “utils/”

##### Technologies & Frameworks
- Next.js (React + SSR/SSG + API Routes)
- TypeScript
- ethers.js (blockchain RPC client)
- Pinata REST API (upload metadata to IPFS)
- TradingView Charting Library (public/static/charting_library) + custom UDF datafeed
- ESLint, Prettier, Tailwind/PostCSS (postcss.config.mjs)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    Browser["Client Browser"]:::browser

    subgraph "Frontend (Browser)" 
        direction TB
        Pages["Next.js Pages (SSR/SSG)"]:::pages
        TVWidget["TradingView Widget"]:::pages
    end

    %% Next.js Layer
    subgraph "Next.js Serverless (Vercel)" 
        direction TB
        SSR["SSR/SSG Pages"]:::nextjs
        API["POST /api/pinata (HTTPS)"]:::nextjs
        CDNStatic["Static CDN Hosting"]:::static
    end

    %% Blockchain & IPFS Layer
    subgraph "Data & Blockchain Services"
        direction TB
        EthNode["Ethereum JSON-RPC"]:::external
        Pinata["Pinata/IPFS REST API"]:::external
        Datafeed["TradingView UDF Datafeed"]:::external
    end

    %% Interactions
    Browser -->|"HTTP GET"| SSR
    Browser -->|"HTTP POST /api/pinata"| API
    Browser -->|"Chart requests"| Datafeed
    Browser -->|"Static assets"| CDNStatic
    SSR -->|"JSON-RPC calls"| EthNode
    API -->|"HTTPS REST"| Pinata
    SSR -->|"Serves static files"| CDNStatic

    %% Click Events - Next.js Pages
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/page.tsx"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/[id]/page.tsx"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/create/page.tsx"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/chart/page.tsx"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/raffle/check/page.tsx"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/raffle/fail/page.tsx"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/test/page.tsx"

    %% Click Events - Layout Components
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/layout.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/detail/HolderDistrubutionLayout.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/detail/TradesLayout.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/home/BuySellLayout.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/home/SlotLayout.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/home/TokensLayout.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/mypage/MyMeme.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/mypage/Raffle.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/mypage/Tokens.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/layout/mypage/Trade.tsx"

    %% Click Events - Shared UI Components
    click TVWidget "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/components/common/TradingViewWidget.tsx"
    click TVWidget "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/components/TVChartContainer/index.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/components/common/Header.tsx"
    click Pages "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/components/common/Footer.tsx"

    %% Click Events - API Route
    click API "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/app/api/pinata/route.ts"

    %% Click Events - Blockchain Interaction Layer
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/utils/ethersProvider.ts"
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/utils/ethersSigner.ts"
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/global/contracts.ts"
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/abis/ReserveToken/ReserveToken.json"
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/tree/main/abis/interfaces/"
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/tree/main/abis/lib/"
    click EthNode "https://github.com/ziptalk/kaiseki-frontend-typescript/tree/main/abis/mock/"

    %% Click Events - TradingView Datafeed
    click Datafeed "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/public/static/datafeeds/udf/src/udf-compatible-datafeed.ts"
    click Datafeed "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/public/static/datafeeds/udf/dist/bundle.js"
    click Datafeed "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/public/static/datafeeds/udf/lib/udf-compatible-datafeed.js"

    %% Click Events - Charting Library & Static Assets
    click CDNStatic "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/public/static/charting_library/charting_library.js"
    click CDNStatic "https://github.com/ziptalk/kaiseki-frontend-typescript/tree/main/public/static/charting_library/bundles/"
    click CDNStatic "https://github.com/ziptalk/kaiseki-frontend-typescript/tree/main/public/icons/"
    click CDNStatic "https://github.com/ziptalk/kaiseki-frontend-typescript/tree/main/public/images/"

    %% Click Events - Config
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/.env.example"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/next.config.mjs"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/tsconfig.json"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/postcss.config.mjs"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/.eslintrc.json"
    click SSR "https://github.com/ziptalk/kaiseki-frontend-typescript/blob/main/.prettierrc"

    %% Styles
    classDef browser fill:#F0F8FF,stroke:#333,stroke-width:1px
    classDef pages fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef nextjs fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef static fill:#FFFF99,stroke:#333,stroke-width:1px
```
