How sohomx/solana-idl-agent works
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