Contributing to SonicJS

This guide is for developers who want to contribute to the SonicJS platform itself. If you're building an application with SonicJS, see the Installation guide instead.


Before You Start

We appreciate every developer who wants to contribute to SonicJS. To ensure the best experience for both contributors and maintainers, we've established a clear process for getting involved.

πŸ’‘

Important: Start with Code, Not Meetings

We receive many requests from developers interested in contributing. While we value every potential contributor, we've found that the most effective way to get involved is to demonstrate your commitment through contributions first. Please submit at least one meaningful pull request before requesting a meeting or deeper integration into the project.

What Counts as a Meaningful Contribution?

πŸ›

Bug Fixes

Fix a bug from the issue tracker with a well-tested solution

✨

New Features

Implement a feature that has been discussed and approved

πŸ“

Documentation

Significantly improve or add documentation

πŸ§ͺ

Test Coverage

Add meaningful tests for untested functionality

🎬

Video Content

Create tutorials, walkthroughs, or feature demos for YouTube

Create Video Content

We're looking for contributors to create video content for our YouTube channel. Video tutorials help developers learn SonicJS faster and reach a wider audience.

Video ideas:

  • Getting started tutorials
  • Feature walkthroughs and demos
  • Building real-world projects with SonicJS
  • Plugin development guides
  • Tips and tricks

Reach out via GitHub Discussions if you're interested in creating video content.


Monorepo Setup

SonicJS uses a monorepo structure managed by npm workspaces. This allows us to develop the core framework, CLI tools, and documentation in a single repository.

Clone the Repository

Clone & Install

# Fork the repository on GitHub first
# Then clone your fork:
git clone https://github.com/YOUR_USERNAME/sonicjs.git
cd sonicjs

# Add upstream remote
git remote add upstream https://github.com/lane711/sonicjs.git

# Install all dependencies (installs for all workspaces)
npm install

Start Development Server

Start Development

# Start the development application
npm run dev

# Or start the documentation site
npm run dev:www

The development server runs at http://localhost:8787


Project Structure

The SonicJS monorepo is organized as follows:

sonicjs/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/                    # @sonicjs-cms/core - The main framework
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts        # Package entry point
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/     # Request middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/         # HTTP route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ services/       # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ templates/      # HTML templates
β”‚   β”‚   β”‚   β”œβ”€β”€ plugins/        # Plugin system
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ core/       # Plugin architecture
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ core-plugins/  # Built-in plugins
β”‚   β”‚   β”‚   β”‚   └── available/  # Optional plugins
β”‚   β”‚   β”‚   β”œβ”€β”€ collections/    # Collection definitions
β”‚   β”‚   β”‚   └── types/          # TypeScript types
β”‚   β”‚   β”œβ”€β”€ migrations/         # Database migrations
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── create-app/             # create-sonicjs CLI tool
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   └── cli.js          # CLI entry point
β”‚       β”œβ”€β”€ templates/
β”‚       β”‚   └── starter/        # Starter project template
β”‚       └── package.json
β”‚
β”œβ”€β”€ www/                        # Documentation website (Next.js)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── app/               # MDX documentation pages
β”‚   └── package.json
β”‚
β”œβ”€β”€ my-sonicjs-app/            # Development/test application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── index.ts           # App entry point
β”‚   β”œβ”€β”€ wrangler.toml          # Cloudflare config
β”‚   └── package.json
β”‚
β”œβ”€β”€ tests/                      # E2E tests
β”‚   β”œβ”€β”€ e2e/                   # Playwright tests
β”‚   └── playwright.config.ts
β”‚
β”œβ”€β”€ docs/                       # Internal documentation
β”œβ”€β”€ package.json               # Root package.json (workspaces)
└── README.md

Key Directories

DirectoryDescription
packages/coreThe core SonicJS framework published as @sonicjs-cms/core
packages/create-appThe create-sonicjs CLI tool for scaffolding new projects
wwwDocumentation website built with Next.js
my-sonicjs-appDevelopment application for testing changes
testsEnd-to-end tests using Playwright

Available Scripts

Root Level Scripts

Run these from the repository root:

CommandDescription
npm run devStart development server (my-sonicjs-app)
npm run dev:wwwStart documentation site
npm run buildBuild core package and development app
npm run build:coreBuild only the core package
npm run build:wwwBuild documentation site
npm testRun core package unit tests
npm run test:e2eRun Playwright end-to-end tests
npm run deployDeploy development app to Cloudflare
npm run deploy:wwwDeploy documentation site

Database Scripts

CommandDescription
npm run db:generateGenerate migration files from schema changes
npm run db:migrateApply migrations to local D1 database
npm run db:migrate:prodApply migrations to production database
npm run db:studioOpen Drizzle Studio (database GUI)

Testing Scripts

CommandDescription
npm testRun Vitest unit tests
npm run test:watchRun tests in watch mode
npm run test:covRun tests with coverage report
npm run test:e2eRun Playwright E2E tests
npm run test:e2e:uiRun E2E tests with UI mode

Plugin Scripts

CommandDescription
npm run plugins:generateRegenerate plugin registry from manifests
npm run plugins:watchWatch plugin manifests and auto-regenerate

Contribution Process

Step 1: Find Something to Work On

Browse our GitHub Issues to find something to work on:

Step 2: Create a Feature Branch

# Sync with upstream
git fetch upstream
git checkout main
git merge upstream/main

# Create a feature branch
git checkout -b feature/your-feature-name

Step 3: Make Your Changes

  1. Make your changes in the appropriate package
  2. Write tests for new functionality
  3. Run tests to ensure everything passes
  4. Update documentation if needed

Have questions? Ask in our Discord server - we're happy to help!

Step 4: Submit Your Pull Request

# Commit your changes
git add .
git commit -m "feat: add your feature description"

# Push to your fork
git push origin feature/your-feature-name

Then create a Pull Request on GitHub.

Step 5: After Your First PR is Merged

πŸŽ‰

Congratulations!

After your first meaningful contribution is merged, you'll be:

  • Added to our contributors list
  • Eligible for deeper project discussions
  • Welcome to schedule a call with maintainers if desired
  • Considered for more significant responsibilities

Code Standards

General Guidelines

  • TypeScript: All code must be in TypeScript with proper types
  • Testing: New features must include tests
  • Documentation: Public APIs must be documented
  • Formatting: Use Prettier (runs automatically on commit)
  • Linting: ESLint rules must pass

Commit Messages

We use conventional commit messages. Reference issue numbers when applicable.

feat: add new caching strategy
fix: resolve authentication bug (#123)
docs: update installation guide
test: add tests for plugin loader

Pull Request Checklist

Before submitting a PR, ensure:

  • All tests pass (npm test)
  • E2E tests pass (npm run test:e2e)
  • Code is formatted (npm run format)
  • Linting passes (npm run lint)
  • Changes are documented if needed
  • PR description explains the changes
  • Related issue is referenced

Troubleshooting

Common Issues

Database Connection Errors

Error: Error: no such table: users

Solution:

# Run migrations
npm run db:migrate

# Verify migration status
wrangler d1 migrations list DB --local

Port Already in Use

Error: Error: listen EADDRINUSE: address already in use :::8787

Solution:

# Find and kill the process using port 8787
lsof -ti:8787 | xargs kill -9

Module Not Found / Import Errors

Error: Cannot find module 'hono'

Solution:

# Clear and reinstall dependencies
rm -rf node_modules package-lock.json
npm install

# Clear TypeScript build cache
rm -rf .wrangler

Build Failures

Error: Build fails when running npm run build:core

Solution:

  1. Ensure you're using Node.js 18+
  2. Clear build artifacts: rm -rf packages/core/dist
  3. Reinstall dependencies: npm install
  4. Try building again: npm run build:core

Getting Help

Resources:


Ready to Contribute?


Questions?

If you have questions about contributing:

  1. Check existing issues - your question may already be answered
  2. Ask in Discord - for general questions
  3. Comment on the issue - for specific issue clarifications

We look forward to your contributions!

Was this page helpful?