# sohomx/solana-idl-agent architecture

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

- Interactive diagram: https://gitdiagram.com/sohomx/solana-idl-agent
- Repository: https://github.com/sohomx/solana-idl-agent

## Overview

##### Project Type & Purpose
- This is a full-stack, monorepo Next.js application (“apps/web”) augmented by two workspace libraries (“packages/idl” and “packages/shared”).
- Purpose: Allow protocol engineers to ingest Anchor-compatible IDL files, assemble and preview Solana transactions via a browser UI, and send or export them without writing custom scripts.

##### File Structure Highlights
- apps/web/
- app/ – Next.js App Router entry (layout.tsx, page.tsx)
- components/ – React UI components (palette, queue, modals, wallet provider, etc.)
- lib/ – Business logic: IDL ingestion, instruction builders, simulation & summarization, export/send helpers.
- public/samples/ – Bundled IDL JSON samples.
- tests/ – Vitest suites for resolver and summary utilities.
- packages/idl – JSONC parser + Zod validator producing a typed IdlSpec.
- packages/shared – Shared TypeScript interfaces (IdlSpec, InstructionSpec, etc.).
- Root – pnpm workspace config, CI workflows, TypeScript base config, testing & linting config.

##### README Insights
- Layers clearly separated: UI <-> business-logic/lib <-> parser & types <-> Solana clusters & wallets.
- Core features map naturally to components & lib modules (IDL ingestion, palette/queue UI, transaction assembly, simulation, export/send).
- Technologies: Next.js 15, React, TypeScript, Zustand, jsonc-parser, Zod, Anchor client, pnpm workspaces, Vitest.

- Presentation Layer: “Next.js Frontend”
– UI Components (Palette, Queue, Modals, Panels)
– NetworkSwitch / MainnetBanner
- Business Logic Layer: apps/web/lib
– IDL ingestion & validation
– Instruction builder (deriveAta, derivePda)
– Transaction assembler (buildInstructions, buildTransaction)
– Simulator & summarizer (simulateBuiltTx, summarizeSim)
– Exporter (exportAsTypeScript) & Sender (sendQueueTx, ensureFeePayerFunds)
- Parser Service: packages/idl (JSONC-parser + Zod → IdlSpec)
- Shared Types Library: packages/shared (TypeScript interfaces)
- External Services:
– Solana RPC (Devnet / Mainnet)
– Wallet Adapters (Phantom, Solflare, Backpack, Burner)

1. User → Next.js UI (click “load IDL”)
2. UI → Parser Service (packages/idl) → returns typed IdlSpec
3. UI renders Palette from IdlSpec
4. User selects instructions → UI writes to Zustand store (queue)
5. On “Build TX”: Business Logic reads queue + shared types → constructs Transaction via Anchor or placeholder instruction
6. On “Simulate”: Business Logic → Solana RPC → returns raw response → summarizer → UI
7. On “Export”: Business Logic → TypeScript script download
8. On “Send”: Business Logic → Wallet Adapter signs → Solana RPC → returns tx signature → feed stored in store → UI SuccessFeed

c. Architectural Patterns & Principles
- Layered Separation: Presentation, State Management, Business Logic, Parser/Types, External Services
- Monorepo via pnpm workspaces for code sharing & consistent scripts
- Hook & store pattern (Zustand) for local persistence + reactivity
- Component-based UI for modularity & reusability
- Validation at the boundary (JSONC + Zod)

d. Key Technologies & Frameworks
- Next.js 15 & React 18
- TypeScript (strict types via packages/shared)
- Zustand + localStorage
- jsonc-parser & Zod (IDL parsing & validation)
- @solana/web3.js & Anchor client
- pnpm workspaces, Vitest, ESLint, Prettier

## Diagram (Mermaid)

```mermaid
graph TB
  %% Presentation Layer
  subgraph "Presentation Layer"
    Frontend["Next.js Frontend"]:::frontend
    subgraph "UI Components"
      Palette["Palette"]:::frontend
      Queue["Queue"]:::frontend
      EditIXModal["Edit IX Modal"]:::frontend
      IDLInput["IDL Input"]:::frontend
      NetworkSwitch["Network Switch"]:::frontend
      MainnetBanner["Mainnet Banner"]:::frontend
      SuccessFeed["Success Feed"]:::frontend
      TSPanel["TS Panel"]:::frontend
      WalletAdapterComponent["Solana Wallet Adapter"]:::frontend
    end
  end

  %% State Management
  subgraph "State Management"
    StateStore["Zustand Store\n(localStorage)"]:::database
  end

  %% Business Logic Layer
  subgraph "Business Logic"
    IDLIngestion["IDL Ingestion & Validation"]:::business
    InstrBuilder["Instruction Builder"]:::business
    TxAssembler["Transaction Assembler"]:::business
    SimulatorNode["Simulator"]:::business
    Summarizer["Summarizer"]:::business
    Exporter["Exporter"]:::business
    Sender["Sender"]:::business
    Airdrop["Airdrop Helper"]:::business
    NetworkLib["Network Endpoints"]:::business
    FeedMgmt["Feed Management"]:::business
  end

  %% Parser & Types
  ParserService["Parser Service\n(JSONC + Zod)"]:::parser
  SharedTypes["Shared Types Library"]:::parser

  %% External Services
  subgraph "External Services"
    SolanaRPC["Solana RPC\n(Devnet/Mainnet)"]:::external
    WalletAdapter["Wallet Adapters"]:::external
  end

  %% Tooling & CI
  subgraph "Tooling & CI"
    PNPM["pnpm Workspace"]:::tooling
    CI["CI Workflows"]:::tooling
    Vitest["Vitest Tests"]:::tooling
    ESLint["ESLint & Prettier"]:::tooling
  end

  %% Data Flows
  User(("User")):::external -->|clicks UI| Frontend
  Frontend -->|load IDL| IDLIngestion
  IDLIngestion -->|"parse JSONC"| ParserService
  ParserService -->|"typed IdlSpec"| IDLIngestion
  IDLIngestion -->|"IDL spec"| SharedTypes
  IDLIngestion -->|"render palette"| Frontend

  Frontend -->|interacts| StateStore
  Palette --> StateStore
  Queue --> StateStore

  StateStore -->|on Build TX| TxAssembler
  StateStore -->|feed updates| FeedMgmt

  TxAssembler -->|uses| InstrBuilder
  InstrBuilder -->|types| SharedTypes
  TxAssembler -->|builds instructions| SharedTypes
  TxAssembler -->|simulate| SimulatorNode
  SimulatorNode -->|RPC call| NetworkLib
  NetworkLib --> SolanaRPC
  SimulatorNode -->|raw response| Summarizer
  Summarizer -->|summary| Frontend

  TxAssembler -->|export| Exporter
  Exporter -->|TS download| Frontend

  TxAssembler -->|send queue| Sender
  Sender -->|fund payer| Airdrop
  Airdrop -->|RPC call| NetworkLib
  Sender -->|sign & send| WalletAdapter
  WalletAdapter -->|RPC send| NetworkLib
  NetworkLib --> SolanaRPC
  Sender -->|tx signature| FeedMgmt
  FeedMgmt -->|display feed| Frontend

  %% Click Events
  click Frontend "https://github.com/sohomx/solana-idl-agent/tree/main/apps/web/app"
  click Palette "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/palette.tsx"
  click Queue "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/queue.tsx"
  click EditIXModal "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/edit-ix-modal.tsx"
  click IDLInput "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/idl-input.tsx"
  click NetworkSwitch "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/network-switch.tsx"
  click MainnetBanner "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/mainnet-banner.tsx"
  click SuccessFeed "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/success-feed.tsx"
  click TSPanel "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/ts-panel.tsx"
  click WalletAdapterComponent "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/providers/solana-wallet.tsx"

  click StateStore "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/status.ts"
  click IDLIngestion "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/idl.ts"
  click InstrBuilder "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/builder.ts"
  click Airdrop "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/airdrop.ts"
  click TxAssembler "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/tx.ts"
  click SimulatorNode "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/resolvers.ts"
  click Summarizer "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/summarize.ts"
  click Exporter "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/export.ts"
  click Sender "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/sender.ts"
  click NetworkLib "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/network.ts"
  click FeedMgmt "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/feed.ts"

  click ParserService "https://github.com/sohomx/solana-idl-agent/blob/main/packages/idl/src/index.ts"
  click SharedTypes "https://github.com/sohomx/solana-idl-agent/blob/main/packages/shared/src/index.ts"

  click SolanaRPC "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/lib/network.ts"
  click WalletAdapter "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/components/providers/solana-wallet.tsx"

  click PNPM "https://github.com/sohomx/solana-idl-agent/blob/main/pnpm-workspace.yaml"
  click CI "https://github.com/sohomx/solana-idl-agent/blob/main/.github/workflows/ci.yml"
  click Vitest "https://github.com/sohomx/solana-idl-agent/blob/main/vitest.config.ts"
  click ESLint "https://github.com/sohomx/solana-idl-agent/blob/main/apps/web/eslint.config.mjs"

  %% Styles
  classDef frontend fill:#E3F2FD,stroke:#42A5F5,color:#0D47A1;
  classDef business fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20;
  classDef parser fill:#FFF3E0,stroke:#FFA726,color:#E65100;
  classDef external fill:#F3E5F5,stroke:#AB47BC,color:#4A148C;
  classDef database fill:#ECEFF1,stroke:#78909C,color:#263238;
  classDef tooling fill:#EEEEEE,stroke:#BDBDBD,color:#424242;
```
