Skip to main content

Getting Started

Getting Started with NetPad Developmentโ€‹

This guide walks you through setting up your local development environment and making your first contribution to NetPad.


Prerequisitesโ€‹

Before you begin, ensure you have:

RequirementVersionNotes
Node.js18+LTS recommended
npm9+Comes with Node.js
Git2.30+For version control
MongoDB AtlasAccountFree tier works for development
Code EditorVS Code recommendedWith TypeScript support
ToolPurpose
OllamaLocal LLM for AI features (free)
DockerFor local services
Postman/InsomniaAPI testing

Initial Setupโ€‹

1. Clone the Repositoryโ€‹

git clone https://github.com/netpad-io/netpad.git
cd netpad

2. Install Dependenciesโ€‹

npm install

3. Set Up MongoDB Atlasโ€‹

  1. Create a free account at mongodb.com/atlas
  2. Create a new cluster (free tier M0 is fine)
  3. Create a database user with read/write permissions
  4. Get your connection string

4. Configure Environment Variablesโ€‹

# Copy the example env file
cp .env.example .env.local

Edit .env.local:

# Required
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net
MONGODB_DATABASE=netpad_dev

# Auth (generate a random string)
NEXTAUTH_SECRET=your-random-secret-here
NEXTAUTH_URL=http://localhost:3000

# AI Provider (at least one recommended)
# Option 1: Ollama (local, free)
OLLAMA_BASE_URL=http://localhost:11434

# Option 2: OpenAI
OPENAI_API_KEY=sk-...

# Option 3: OpenRouter
OPENROUTER_API_KEY=sk-or-...

Ollama lets you run AI features locally for free:

# Install Ollama (macOS)
brew install ollama

# Or download from ollama.ai

# Start Ollama
ollama serve

# Pull a model (in another terminal)
ollama pull llama3.2

6. Run the Development Serverโ€‹

npm run dev

Visit http://localhost:3000

7. Verify Everything Worksโ€‹

  • Homepage loads
  • Can create an account
  • Can create a new form
  • AI features work (if configured)

Project Structure Overviewโ€‹

netpad/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ app/ # Next.js App Router
โ”‚ โ”‚ โ”œโ”€โ”€ api/ # API routes (165+)
โ”‚ โ”‚ โ”œโ”€โ”€ (dashboard)/ # Dashboard pages
โ”‚ โ”‚ โ””โ”€โ”€ (public)/ # Public pages
โ”‚ โ”œโ”€โ”€ components/ # React components
โ”‚ โ”œโ”€โ”€ lib/ # Core libraries
โ”‚ โ”œโ”€โ”€ hooks/ # Custom React hooks
โ”‚ โ””โ”€โ”€ types/ # TypeScript definitions
โ”œโ”€โ”€ packages/ # NPM packages
โ”œโ”€โ”€ docs/ # Documentation
โ”œโ”€โ”€ public/ # Static assets
โ””โ”€โ”€ tests/ # Test files

Key directories to know:

DirectoryWhat's There
src/components/FormBuilder/Form builder UI
src/components/WorkflowEditor/Workflow editor UI
src/lib/ai/AI service layer
src/lib/platform/Database operations
src/app/api/All API endpoints

Code Standardsโ€‹

TypeScriptโ€‹

  • Strict mode enabled
  • No any types (use unknown if needed)
  • Export interfaces for public APIs
  • Document complex types
// โœ… Good
interface FormConfig {
name: string;
fields: FieldConfig[];
settings?: FormSettings;
}

// โŒ Avoid
const form: any = { ... };

React Componentsโ€‹

  • Functional components only
  • Use hooks for state management
  • Colocate related files
// โœ… Good
export function FormField({ field, value, onChange }: FormFieldProps) {
// ...
}

// โŒ Avoid
class FormField extends React.Component { ... }

Stylingโ€‹

  • Use Material-UI (MUI) - not Tailwind
  • Use MUI's sx prop for component-specific styles
  • Use theme tokens for consistency
// โœ… Good
<Box sx={{ p: 2, bgcolor: 'background.paper' }}>

// โŒ Avoid
<div className="p-4 bg-white">

File Namingโ€‹

TypeConventionExample
ComponentsPascalCaseFormBuilder.tsx
HookscamelCase with use prefixuseFormState.ts
UtilitiescamelCasevalidation.ts
TypesPascalCaseFormTypes.ts

Importsโ€‹

// Order: React, external, internal, types, styles
import { useState } from 'react';
import { Box, Button } from '@mui/material';
import { FormField } from '@/components/FormBuilder';
import type { FieldConfig } from '@/types';

First Contribution Workflowโ€‹

Branch Namingโ€‹

feature/add-rating-field
fix/form-validation-error
docs/update-api-reference
refactor/extract-form-utils

Commit Messagesโ€‹

Follow conventional commits:

feat: add rating field type
fix: resolve form validation on empty fields
docs: update API reference for submissions
refactor: extract validation utilities
test: add form builder integration tests

Pull Request Processโ€‹

  1. Create a branch from main
  2. Make your changes with clear commits
  3. Test locally - ensure existing tests pass
  4. Open a PR with:
    • Clear title describing the change
    • Description of what and why
    • Screenshots for UI changes
    • Link to related issue (if any)
  5. Address feedback promptly
  6. Merge after approval

PR Templateโ€‹

## What

Brief description of changes.

## Why

Motivation or problem being solved.

## How

Technical approach taken.

## Screenshots

(For UI changes)

## Testing

How you tested these changes.

## Checklist

- [ ] Tests pass locally
- [ ] No TypeScript errors
- [ ] Follows code standards
- [ ] Documentation updated (if needed)

Testingโ€‹

Running Testsโ€‹

# Run all tests
npm run test

# Run specific test file
npm run test -- forms.test.ts

# Run tests in watch mode
npm run test:watch

# Run E2E tests
npm run test:e2e

Getting Helpโ€‹

Documentationโ€‹

Communicationโ€‹

  • Questions: Open a GitHub discussion
  • Bugs: Open a GitHub issue
  • Ideas: Discuss before implementing large changes

Common Issuesโ€‹

IssueSolution
Build error with MongoDBEnsure you're not importing server code in client components
AI features not workingCheck your LLM provider configuration
Auth errorsVerify NEXTAUTH_SECRET is set
Database connection failsCheck MongoDB Atlas IP allowlist

Development Tipsโ€‹

VS Code Extensionsโ€‹

Recommended extensions:

  • ESLint
  • Prettier
  • TypeScript Importer
  • GitLens
  • Thunder Client (API testing)

Debuggingโ€‹

// Use console.log strategically
console.log('[FormBuilder]', { fields, values });

// For API routes
console.log('[API /forms]', { method: req.method, body: req.body });

Performanceโ€‹

  • Use React DevTools to identify re-renders
  • Check Network tab for API call efficiency
  • Profile with Chrome DevTools for bottlenecks

First Contribution Ideasโ€‹

Good First Issuesโ€‹

TaskDifficultySkills
Fix typo in documentationEasyNone
Add test caseEasyTesting
Improve error messageEasyTypeScript
Add field validationMediumTypeScript
UI polish taskMediumReact, MUI

How to Find Issuesโ€‹

  1. Check GitHub Issues labeled good-first-issue
  2. Look at Current Priorities
  3. Ask what's needed

Checklist Before Submittingโ€‹

  • Code follows project standards
  • No TypeScript errors (npm run type-check)
  • Tests pass (npm run test)
  • Linting passes (npm run lint)
  • Tested locally
  • PR description is clear
  • Screenshots for UI changes

Questions?โ€‹

Don't hesitate to ask. No question is too basic. We'd rather help you succeed than have you struggle silently.

Welcome to NetPad!