API Routes

The frontend includes a backend-for-frontend (BFF) layer — API routes that run on the Next.js server. These routes handle authentication, proxy requests, and server-side logic.

Route Overview

All API routes live under src/app/api/v1/:

api/v1/
├── auth/               # Authentication
│   ├── login/          # Wallet-based login
│   ├── logout/         # Session termination
│   ├── session/        # Session validation
│   └── wallet/         # Wallet connection
│
├── pools/              # Pool data
│   └── [pool_id]/      # Individual pool details
│
├── positions/          # Position data
│   ├── summary/        # Aggregated position summary
│   ├── stacked-chart/  # Chart visualization data
│   └── aggregate/      # Cross-protocol aggregation
│
├── zerion/             # Zerion API proxy
│   ├── balances/       # Token balances
│   ├── chart/          # Portfolio chart
│   └── fungible-chart/ # Token-specific chart
│
├── users/              # User management
├── associates/         # Advisor/advisee relationships
├── subscriptions/      # Subscription management
│
├── search/             # Pool and protocol search
├── safe/               # Safe operations
├── relay/              # Relay operations
│
├── analytics/          # Platform analytics
├── email/              # Email services
│
├── chats/              # Chat operations
├── comet-chat/         # CometChat integration
│
├── webhooks/           # Webhook receivers
│   ├── dynamic/        # Dynamic Labs webhooks
│   └── cometchat/      # CometChat webhooks
│
└── [chain_id]/         # Chain-specific routes

Authentication

Authentication uses Dynamic Labs for wallet-based login:

  1. User connects wallet via Dynamic Labs SDK
  2. Dynamic Labs issues a JWT
  3. Frontend validates the JWT using jwks-rsa
  4. A session is created using iron-session (encrypted cookies)

Key Route Categories

Auth Routes

Handle wallet connection, session creation, and logout. Sessions are stored in encrypted cookies using iron-session.

Data Routes

Proxy and aggregate data from the backend API, blockchain, and third-party services. These exist to:

  • Keep API keys server-side (not exposed to the browser)
  • Combine data from multiple sources into a single response
  • Add caching headers

Webhook Routes

Receive callbacks from external services:

  • Dynamic webhooks — wallet connection events
  • CometChat webhooks — message delivery events

Chain-Specific Routes

Routes parameterized by chain ID for multi-chain operations.

results matching ""

    No results matching ""