Contributing to NetPad
Thank you for your interest in contributing to NetPad! This document provides guidelines and instructions for contributing.
Getting Startedโ
Prerequisitesโ
- Node.js 18+
- npm or yarn
- MongoDB (local or Atlas)
- Git
Development Setupโ
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/netpad-v3.git
cd netpad-v3 -
Install dependencies:
npm install -
Set up environment variables:
cp .env.example .env.localConfigure the required variables:
MONGODB_URI- Your MongoDB connection stringSESSION_SECRET- Generate withopenssl rand -hex 32VAULT_ENCRYPTION_KEY- Generate withopenssl rand -base64 32
-
Start the development server:
npm run dev
Development Workflowโ
Branch Namingโ
Use descriptive branch names:
feature/add-new-field-type- For new featuresfix/form-validation-bug- For bug fixesdocs/update-api-docs- For documentationrefactor/improve-performance- For refactoring
Making Changesโ
-
Create a new branch from
main:git checkout -b feature/your-feature-name -
Make your changes following the code style guidelines
-
Write or update tests as needed
-
Run the test suite:
npm test -
Run the linter:
npm run lint -
Build to check for TypeScript errors:
npm run build
Commit Messagesโ
Follow conventional commit format:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changes (formatting, etc.)refactor:Code refactoringtest:Adding or updating testschore:Maintenance tasks
Example:
feat: add date range picker field type
- Added DateRangePicker component
- Integrated with form builder
- Added validation for date ranges
Pull Requestsโ
Before Submittingโ
- Code follows the project style guidelines
- Tests pass locally (
npm test) - Lint checks pass (
npm run lint) - Build succeeds (
npm run build) - Documentation updated (if needed)
- Commit messages follow conventional format
PR Descriptionโ
Include in your PR description:
- Summary of changes
- Motivation for the change
- Testing done
- Screenshots (for UI changes)
Review Processโ
- Submit your PR against the
mainbranch - Wait for CI checks to pass
- Request review from maintainers
- Address any feedback
- Once approved, your PR will be merged
Code Styleโ
TypeScriptโ
- Use TypeScript for all new code
- Define interfaces for component props
- Avoid
anytypes where possible - Use meaningful variable and function names
React Componentsโ
- Use functional components with hooks
- Keep components focused and single-purpose
- Extract reusable logic into custom hooks
- Use MUI components consistently
File Organizationโ
src/
app/ # Next.js app router pages
components/ # React components
contexts/ # React contexts
hooks/ # Custom hooks
lib/ # Utility functions and core logic
types/ # TypeScript type definitions
Naming Conventionsโ
- Components: PascalCase (
FormBuilder.tsx) - Hooks: camelCase with
useprefix (useFormData.ts) - Utilities: camelCase (
formatDate.ts) - Types: PascalCase (
FormField.ts) - API Routes: kebab-case (
/api/form-submissions)
Testingโ
Running Testsโ
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
Writing Testsโ
- Place tests next to the code they test
- Use descriptive test names
- Test both success and error cases
- Mock external dependencies
Documentationโ
Code Documentationโ
- Add JSDoc comments to exported functions
- Document complex logic with inline comments
- Keep README and docs up to date
API Documentationโ
When adding new API endpoints:
- Update
docs/API.mdwith endpoint documentation - Include request/response examples
- Document error cases
Reporting Issuesโ
Bug Reportsโ
Include:
- Steps to reproduce
- Expected behavior
- Actual behavior
- Browser/environment info
- Screenshots (if applicable)
Feature Requestsโ
Include:
- Clear description of the feature
- Use case / motivation
- Any relevant examples
Securityโ
If you discover a security vulnerability:
- Do not open a public issue
- Email security@netpad.io with details
- We'll respond within 48 hours
Communityโ
- Be respectful and inclusive
- Help others when you can
- Ask questions if you're unsure
- Follow our Code of Conduct
Licenseโ
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to NetPad!