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
- Documentation Index (docs/README.md)
- Features
- Architecture
- Getting Started
- Configuration
- Project Structure
- Backend API Changelog
- Settlement and Early Exit UI Flows
- Error Page Recovery Flows
- Contributing
- Community & 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.
- Settlement and Early Exit Flows: Guided settlement eligibility, settlement success, and early-exit confirmation surfaces backed by preview and execution endpoints. See Settlement and Early Exit UI Flows.
- Error Page Recovery Flows: App Router error boundaries and recovery pages are documented in ERROR_PAGES_README.md.
- 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.
For a frontend-focused map of pages to components to API routes, plus wallet/auth state flow, see FRONTEND_ARCHITECTURE.md.
This project uses Vitest for unit and integration testing of API routes.
# Run all tests
pnpm test
# Run tests in watch mode (re-runs on file changes)
pnpm run test:watch
# Run tests with coverage report
pnpm run test:coverageCoverage Requirements: The project enforces a 95% threshold on statements, branches, functions, and lines.
For detailed testing conventions, patterns, and best practices, see TESTING_GUIDE.md, which covers:
- Mocking fetch and external APIs
- Mocking the Freighter wallet API
- Using fake timers for async testing
- React Testing Library patterns and accessibility-first queries
- Test organization and naming conventions
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.
Browser-facing backend routes also use an explicit CORS policy helper. Configure
trusted first-party origins with COMMITLABS_FIRST_PARTY_ORIGINS and public
browser origins with COMMITLABS_PUBLIC_API_ORIGINS. See
docs/backend-cors-policy.md for the route
strategy and allowed methods.
Backend API storage uses a provider-agnostic adapter. Configure
COMMITLABS_STORAGE_PROVIDER=memory by default and see
docs/backend-storage.md for adapter 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
βββ hooks/ # React hooks (useWallet, etc.)
βββ lib/ # Backend lib, services, mocks
βββ utils/ # Utility functions (Soroban, formatting)
βββ ...
See [docs/FRONTEND_ARCHITECTURE.md](./docs/FRONTEND_ARCHITECTURE.md) for a
detailed pageβcomponentβAPI-route map and state/data-flow conventions.
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.
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.
We welcome contributions to CommitLabs! Before you start, please read our Developer Guide and check out the Documentation Index (docs/README.md) for details on all available documentation, coding standards, naming conventions, and testing guidelines.
To standardize submissions and streamline reviews, we use structured templates:
- Bug Reports: Use the Bug Report Form to report issues.
- Feature Requests: Use the Feature Request Form to suggest enhancements.
- Pull Requests: Every pull request must follow the checklist in our Pull Request Template (verifying 95% test coverage, the 96-hour campaign timeframe, lint checks, etc.).
- Discussions: Have questions or need support? Join our CommitLabs Discord server.
- Fork the repository and clone it to your local machine.
- Create a branch for your changes:
git checkout -b feat/your-feature-name
- Develop & Test following the conventions in the Developer Guide. Ensure any new or modified logic meets the minimum 95% test coverage requirement.
- Lint your code:
pnpm lint
- Commit and Push your changes to your fork.
- Open a Pull Request pointing to the upstream repository's
masterbranch.
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions! Please review our community guidelines before getting started:
- Contributing Guidelines: Details on branching, PR flow, and test expectations.
- Code of Conduct: Our expectations for community interactions.
- Security Policy: How to report vulnerabilities privately.
- Developer Guide: Instructions on local setup, testing, and architecture.
- Fork the repository and clone it to your local machine.
- Create a new branch for your changes.
- Make and test your updates following the project guidelines.
- Commit and push your changes to your fork.
- Open a Pull Request with a clear description.