The frontend application for the CommitLabs protocol, a decentralized platform for managing liquidity commitments on the Stellar network. Built with Next.js, TypeScript, and Tailwind CSS.
- Overview
- Features
- Architecture
- Getting Started
- Configuration
- Project Structure
- Backend API Changelog
- Contributing
- API Reference
- License
CommitLabs allows users to create, manage, and trade liquidity commitments. These commitments are on-chain contracts that lock assets for a specified duration in exchange for yield, with specific compliance and risk parameters.
This frontend interacts with the CommitLabs Soroban smart contracts to:
- Create new commitments with customizable parameters (Safe, Balanced, Aggressive).
- Monitor the health and performance of existing commitments.
- Trade commitments on a secondary marketplace.
- Commitment Creation Wizard: Step-by-step process to configure asset, amount, duration, and risk parameters.
- Dashboard: Real-time visualization of commitment health, including value history, drawdown, and compliance scores.
- Marketplace: Browse and filter active commitments available for purchase.
- Wallet Integration: Connect with Stellar wallets (e.g., Freighter) to sign transactions (In Progress).
- Responsive Design: Optimized for both desktop and mobile devices.
The application is built using the Next.js App Router architecture.
- Framework: Next.js 14
- Language: TypeScript
- Styling: Tailwind CSS (v4) with CSS Modules for component-specific styles.
- State Management: React Context & Hooks (Local state for forms).
- Blockchain Interaction:
@stellar/stellar-sdkand@stellar/freighter-api(viasrc/utils/soroban.ts). - Data Visualization:
rechartsfor health metrics and performance charts.
For a deep dive into the system design, modules, and data flow, please refer to ARCHITECTURE.md.
This project uses Vitest for unit and integration testing of API routes.
# Run all tests
npm test
# Run tests in watch mode (re-runs on file changes)
npm run test:watch
# Run tests with coverage report
npm run test:coverageTests are organized in the tests/ directory:
tests/
└── api/
├── helpers.ts # Test utilities and mock request helpers
├── health.test.ts # Tests for /api/health route
└── commitments.test.ts # Tests for /api/commitments route
- GET /api/health - Health check endpoint returning status and version
- GET /api/commitments - Fetch commitments with optional filtering and pagination
- POST /api/commitments - Create a new commitment (mocked for now)
Tests demonstrate:
- Mocking Next.js API routes without network requests
- Testing request/response handling
- Parameter validation and error handling
- Mock data without external dependencies
To add new API route tests, create a .test.ts file in tests/api/ following the same pattern.
Breaking backend API changes are tracked in docs/backend-changelog.md. Update this changelog whenever a backend change can break existing frontend integrations.
- Node.js 18.x or later
- pnpm (recommended) or npm/yarn
- A Stellar wallet extension (e.g., Freighter) installed in your browser.
-
Clone the repository:
git clone https://github.com/your-org/commitlabs-frontend.git cd commitlabs-frontend -
Install dependencies:
pnpm install # or npm install -
Set up environment variables: Copy the example environment file and configure it.
cp .env.example .env
See Configuration for details.
-
Run the development server:
pnpm dev # or npm run dev -
Open the application: Visit http://localhost:3000 in your browser.
The application requires the following environment variables (defined in .env):
| Variable | Description | Default (Testnet) |
|---|---|---|
NEXT_PUBLIC_SOROBAN_RPC_URL |
URL of the Soroban RPC endpoint | https://soroban-testnet.stellar.org |
NEXT_PUBLIC_NETWORK_PASSPHRASE |
Stellar network passphrase | Test SDF Network ; September 2015 |
NEXT_PUBLIC_COMMITMENT_NFT_CONTRACT |
Address of the Commitment NFT contract | Required |
NEXT_PUBLIC_COMMITMENT_CORE_CONTRACT |
Address of the Core Logic contract | Required |
NEXT_PUBLIC_ATTESTATION_ENGINE_CONTRACT |
Address of the Attestation Engine contract | Required |
Note: The project also supports a versioned contract configuration via NEXT_PUBLIC_CONTRACTS_JSON and NEXT_PUBLIC_ACTIVE_CONTRACT_VERSION. See docs/config.md for details.
src/
├── app/ # Next.js App Router pages and layouts
│ ├── commitments/ # Dashboard & Commitment Details
│ ├── create/ # Commitment Creation Wizard
│ ├── marketplace/ # Marketplace Listing
│ └── page.tsx # Landing Page
├── components/ # Reusable UI components
│ ├── dashboard/ # Charts and metrics components
│ ├── modals/ # Global modals (Success, Errors)
│ └── ...
├── types/ # TypeScript interfaces and types
├── utils/ # Utility functions (Soroban, formatting)
└── ...
This project includes a reusable helper to attach standard security headers to HTTP responses.
Usage:
-
Import the helper:
import { attachSecurityHeaders } from "@/utils/response";
-
Wrap your response object before returning it in a route handler:
import { NextResponse } from "next/server"; import { attachSecurityHeaders } from "@/utils/response"; export async function GET() { const response = NextResponse.json({ data: "secure content" }); return attachSecurityHeaders(response); }
Customization:
-
Content-Security-Policy (CSP): You can override the default CSP by passing a second argument.
return attachSecurityHeaders(response, "default-src 'none'; img-src 'self'");
-
Disabling/Modifying Headers: The
attachSecurityHeadersfunction returns the modifiedResponseobject. You can further modify headers on the returned object if needed, or update thesrc/utils/response.tsfile to change default behaviors globally.
We welcome contributions! Please see our Developer Guide for detailed instructions on coding standards, testing procedures, and the pull request process.
A description of the backend endpoints exposed under /api can be found in:
This document includes available routes, required parameters, and example requests/responses. It is intended for developers building against or testing the backend.
This project is licensed under the MIT License - see the LICENSE file for details.