Project Structure

The frontend follows Next.js App Router conventions with additional organization for DeFi-specific logic.

Directory Layout

src/
├── app/                    # Pages and API routes (Next.js App Router)
│   ├── (marketing)/        # Marketing/landing pages
│   ├── auth/               # Login, logout, wallet connection
│   ├── api/v1/             # Backend-for-frontend API routes
│   └── platform/           # Main authenticated app
│       ├── analysis/       # Portfolio analysis
│       ├── delegations/    # Permission management
│       ├── safes/          # Smart wallet management
│       ├── safe-modules/   # Module configuration
│       ├── transact/       # Transaction execution
│       ├── token-swap/     # Token swapping
│       ├── skills/         # Strategy execution
│       ├── pnl/            # Profit & loss
│       ├── goals/          # Goal tracking
│       ├── settings/       # User preferences
│       ├── admin/          # Admin panel
│       └── ...             # 10+ more sections
│
├── features/               # Business logic modules
│   ├── delegations/        # 11 sub-modules
│   ├── transact/           # 17 sub-modules
│   ├── safes/              # 4 sub-modules
│   ├── token-swap/         # 7 sub-modules
│   ├── analysis/           # 7 sub-modules
│   ├── comet-chat/         # 4 sub-modules
│   ├── pnl/                # 3 sub-modules
│   ├── consult/            # 6 sub-modules
│   ├── media/              # 5 sub-modules
│   ├── skills/             # 7 sub-modules
│   ├── settings/           # 4 sub-modules
│   └── goals/              # 3 sub-modules
│
├── lib/                    # Shared libraries
│   ├── defi/               # DeFi protocol adapters (71 files)
│   │   ├── aave/
│   │   ├── yearn/
│   │   ├── morpho/
│   │   ├── uniswap/        # V2, V3, V4
│   │   ├── aerodrome/
│   │   ├── aero-slipstream/
│   │   ├── krystal/
│   │   ├── trends/
│   │   └── positions/
│   ├── relay/              # Meta-transaction support
│   ├── session/            # Session management
│   ├── prisma/             # Database client
│   ├── dynamic/            # Dynamic Labs wallet setup
│   ├── zerion/             # Zerion API client
│   ├── moralis/            # Moralis API client
│   └── helius/             # Helius API (Solana)
│
├── components/             # Reusable UI components
│   ├── ui/                 # Basic components (buttons, inputs)
│   ├── core/               # Core components
│   ├── platform/           # Platform-specific components
│   ├── forms/              # Form components
│   └── layout/             # Layout components
│
└── types/                  # TypeScript type definitions

The Three Code Layers

1. app/ — Routes and Pages

Follows Next.js App Router conventions. Each folder is a route segment. Pages use React Server Components by default for fast initial loads.

Convention: Route folders map directly to URLs. app/platform/analysis/page.tsx renders at /platform/analysis.

2. features/ — Business Logic (Legacy)

Contains hooks, state management, and domain-specific logic. Features are self-contained modules that encapsulate everything needed for a specific business capability.

Example: The delegations feature contains 11 sub-modules handling everything from permission creation to delegate management.

2b. v2/ — New Architecture (Gradual Migration)

The codebase is undergoing a gradual migration. The v2/ directory contains the newer architecture for dashboards, admin panel, portfolio views, and data visualization. features/ retains the legacy protocol-specific transaction modules (deposit, withdraw, swap, etc.). Both coexist — v2/ is not a replacement but a parallel structure for newer pages. The nmt-v2.prisma schema introduces DeFi-specific position tracking tables (nmt_pool, nmt_position, etc.) that the v2 pages consume.

3. lib/ — Shared Utilities

Protocol adapters, API clients, and shared utilities. The lib/defi/ folder is particularly important — it contains 71 files covering all DeFi protocol integrations.

Example: lib/defi/aave/actions.ts contains functions to encode Aave supply/borrow transactions for the DelegateBundler.

results matching ""

    No results matching ""