How tranvugiang/cryptoplant works
Project Type and Purpose
• This is a blockchain dApp built on Solana:
– On-chain program (“cryptoplant”) written in Rust, managed by Anchor
– Frontend web application using Next.js (app router) + React + Tailwind
– A small standalone Node.js “server” for custom API endpoints
– TypeScript/IDL layers to bridge frontend ↔ on-chain interactions
File Structure
Top-level directories:
• anchor/ → Anchor workspace for the Solana program, migrations, IDL, tests
• server/ → Node.js application (app.ts, its own package.json)
• src/ → Next.js 13 “app” directory with pages, API routes, and components
• public/ → static assets
Config files: Anchor.toml, next.config.mjs, tsconfig.json, tailwind.config.ts
Indicators of patterns:
• anchor/programs: on-chain MVC style (program logic in lib.rs)
• src/app and src/components: React feature-driven modules
• API layer both in Next.js (app/api) and a separate server folder
README (assumed empty)
• No explicit architecture section, so rely on conventions:
– Anchor IDL under anchor/target/idl
– TypeScript exports in anchor/src/cryptoplant-exports.ts → frontend & server use
Main Components & Relationships
a. On-Chain Program (Anchor)
– Component: Rust program “cryptoplant”
– Interfaces: Anchor’s IDL → TypeScript clients
– Deploy: migrations/deploy.ts
b. Frontend (Next.js + React)
– Pages under src/app (account/, cryptoplant/, clusters/, etc.)
– Uses SolanaProvider (src/components/solana) to connect wallet & RPC cluster
– React-Query provider for data fetching
– Component modules: account, cluster, cryptoplant, dashboard in src/components
c. Backend Server (Node.js)
– server/app.ts exposes custom endpoints (e.g., analytics, off-chain data)
– May consume Anchor IDL + cryptoplant-exports.ts to talk on-chain
d. External Services
– Solana RPC nodes / clusters
– Wallet adapters (in browser)
Architectural Patterns & Design Principles
• Separation of concerns:
– On-chain logic isolated in Anchor workspace
– Frontend UI & data layers in Next.js + React
– Off-chain APIs in Node.js server
• Feature-driven frontend modules (data-access, UI, feature container)
• IDL as contract between on-chain and TypeScript clients