Welcome to the CommitLabs Frontend developer guide. This document provides guidelines and best practices for contributing to the codebase.
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS (v4) & CSS Modules
- State Management: React Context / Hooks
- Blockchain: Stellar SDK & Soroban
- Package Manager: pnpm
- Strict Mode: We use strict TypeScript configuration. Avoid
anywhenever possible. - Interfaces: Define interfaces for all component props and data models.
- Types: Use
typefor unions and simple aliases,interfacefor object shapes. - Naming:
- Components:
PascalCase(e.g.,CommitmentForm.tsx) - Functions/Variables:
camelCase(e.g.,handleSubmit) - Constants:
UPPER_SNAKE_CASE(e.g.,MAX_RETRY_ATTEMPTS)
- Components:
- A lightweight analytics logger lives in
src/lib/backend/logger.ts. - Exposed helpers include
logCommitmentCreated,logCommitmentSettled,logEarlyExit, andlogAttestation. - Call these from API routes whenever you want to emit structured events relevant to business actions. This makes it easy to wire an external analytics platform later on.
- Functional Components: Use functional components with hooks.
- Client vs Server: Explicitly mark Client Components with
'use client'at the top of the file. Default to Server Components where possible for performance. - Hooks: Custom hooks should be placed in
src/hooks(create if needed). - Project Structure:
page.tsx: Route entry point.layout.tsx: Layout wrapper.page.module.css: Page-specific styles (if not using Tailwind utility classes).
- Tailwind First: Prefer Tailwind utility classes for layout, spacing, and typography.
- CSS Modules: Use CSS Modules for complex, custom animations or specific component isolation that Tailwind handles less elegantly.
- Responsiveness: Build mobile-first using Tailwind's breakpoints (
sm:,md:,lg:).
(Note: Testing framework setup is currently in progress)
- Unit Tests: We plan to use Vitest + React Testing Library.
- Integration Tests: Test user flows (e.g., creating a commitment) end-to-end.
- Linting: Run
pnpm lintbefore committing to ensure code quality.
- Fork & Clone: Fork the repository and clone it locally.
- Branch: Create a feature branch (
git checkout -b feature/my-feature). - Develop: Write code following the standards above.
- Lint: Run
pnpm lintto check for errors. - Commit: Use descriptive commit messages.
feat: Add wallet connectionfix: Resolve layout issue on mobiledocs: Update README
- Push: Push to your fork and submit a Pull Request.
- We use
pnpmfor fast and efficient package management. - To add a dependency:
pnpm add <package-name> - To add a dev dependency:
pnpm add -D <package-name>
Interaction with smart contracts is handled in src/utils/soroban.ts.
- Contract Addresses: Managed via environment variables.
- ABIs: Types should be generated from the contract XDR/WASM (future task).
- We use
@stellar/freighter-apito communicate with the user's wallet. - Ensure you handle cases where the wallet is not installed or the user rejects a transaction.