Thank you for your interest in contributing to Stellarlend! This document provides guidelines and instructions for contributing to the project.
- Fork the repository and clone your fork
- Create a branch for your feature or fix:
git checkout -b feature/your-feature-name - Install dependencies:
npm install(orpnpm install) - Make your changes following our coding standards
- Test your changes:
npm testandnpm run lint - Commit your changes using conventional commits
- Push to your fork and open a Pull Request
- Use TypeScript strict mode (already enabled)
- Define types for all function parameters and return values
- Prefer
interfacefor object shapes,typefor unions/intersections - Use meaningful, descriptive names
- Use functional components with hooks
- Prefer named exports for components
- Keep components focused and single-purpose
- Use TypeScript for all component props
- Components:
PascalCase.tsx(e.g.,LendingForm.tsx) - Utilities:
camelCase.ts(e.g.,formatCurrency.ts) - Types:
PascalCase.ts(e.g.,Transaction.ts) - Constants:
camelCase.ts(e.g.,design-tokens.ts)
Follow this structure for new components:
// 1. Imports (external, then internal)
import React from "react";
import { Button } from "@/components/shared/ui";
// 2. Types/Interfaces
interface ComponentProps {
// ...
}
// 3. Component
export default function Component({ ... }: ComponentProps) {
// ...
}
// 4. Exports (if needed)- Write tests for new features and bug fixes
- Use Vitest for unit tests
- Use React Testing Library for component tests
- Aim for meaningful test coverage
- Test user interactions, not implementation details
# Run all tests
npm test
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm test -- --coverage| Runner | Config file | Command | Scope | Coverage |
|---|---|---|---|---|
| Vitest (unit) | vitest.config.unit.mts |
npm test or vitest |
Unit tests in components/** and lib/** |
npm run test:coverage (vitest --coverage) |
| Vitest (server) | vitest.server.config.ts |
npm run test:server |
Server‑side tests (API, backend) | npm run test:server:coverage |
| Jest | jest.config.ts |
npm test (uses Vitest for unit) but also runs Jest tests |
Jest specific tests (**/*.test.{ts,tsx}) |
Coverage via npm test -- --coverage |
| Playwright (e2e) | playwright.config.ts |
npm run test:e2e |
End‑to‑end tests in test/ |
No coverage; reports in playwright-report/ |
| Storybook (component) | Storybook config (via storybook scripts) |
npm run storybook / npm run build-storybook |
Interactive component playground | No coverage; use Storybook a11y addon |
- Vitest unit test:
vitest path/to/file.test.ts - Vitest server test:
vitest run --project server path/to/server.test.ts - Jest test:
jest path/to/file.test.ts - Playwright test:
playwright test path/to/spec.spec.ts - Storybook:
npm run storybookthen navigate to the component.
Coverage thresholds are defined in jest.config.ts (global) and enforced in CI via .github/workflows/ci.yml and server-coverage.yml. The thresholds require at least 90% branches and 95% for functions, lines, and statements.
For Vitest coverage, the vitest command respects the same thresholds via the Vite config.
- Create a
.stories.tsxfile for your component - Document all props and variants
- Add examples for different states
- Test accessibility with Storybook's a11y addon
# Start Storybook
npm run storybook
# Build Storybook
npm run build-storybookUse our Plop generator for consistent component structure:
npm run generate-component- Use Tailwind CSS utility classes
- Follow the design tokens in
constants/design-tokens.ts - Use the
cn()utility for conditional classes - Keep styles co-located with components when possible
- Use CSS variables for theme values
Follow the established structure:
app/: Next.js App Router pagescomponents/: React components organized by:atoms/: Smallest reusable componentsmolecules/: Composite componentsorganisms/: Complex componentsfeatures/: Feature-specific componentsmarketing/: Marketing page componentsshared/: Shared components (ui, layout, common)
lib/: Utility libraries and helperstypes/: TypeScript type definitionsconstants/: Application constantscontext/: React context providersdocs/: Developer guides, including Client-side data-fetching conventions
feature/- New featuresfix/- Bug fixesdocs/- Documentation updatesrefactor/- Code refactoringtest/- Test additions/updates
We use Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test additions/changeschore: Maintenance tasks
Examples:
feat(lending): add interest rate calculator
fix(dashboard): resolve transaction display issue
docs(readme): update setup instructions
refactor(components): reorganize shared components
- Update documentation if needed
- Add tests for new features
- Ensure all tests pass:
npm test - Ensure linting passes:
npm run lint - Update CHANGELOG.md (if applicable)
- Request review from maintainers
- Address feedback and update PR as needed
When reporting bugs, please include:
- Description of the bug
- Steps to reproduce
- Expected behavior
- Actual behavior
- Screenshots (if applicable)
- Environment (browser, OS, Node version)
- Error messages or console logs
For feature requests:
- Check if the feature already exists or is planned
- Open an issue with a clear description
- Explain the use case and benefits
- Provide examples or mockups if possible
- Next.js Documentation
- React Documentation
- TypeScript Handbook
- Tailwind CSS Documentation
- Conventional Commits
- Open an issue for questions
- Check existing issues and discussions
- Reach out to maintainers
Thank you for contributing to Stellarlend! 🎉