# Contributing to WAMR Thank you for your interest in contributing to WAMR (WhatsApp Media Request Manager)! We welcome contributions from the community and are excited to have you on board. ## Table of Contents - [Code of Conduct](#code-of-conduct) - [How Can I Contribute?](#how-can-i-contribute) - [Getting Started](#getting-started) - [Development Workflow](#development-workflow) - [Coding Conventions](#coding-conventions) - [Commit Message Guidelines](#commit-message-guidelines) - [Pull Request Process](#pull-request-process) - [Issue Guidelines](#issue-guidelines) - [Testing Guidelines](#testing-guidelines) ## Code of Conduct This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers. ## How Can I Contribute? ### Reporting Bugs Before creating bug reports, please check the existing issues to avoid duplicates. When you create a bug report, include as many details as possible: - **Use a clear and descriptive title** - **Describe the exact steps to reproduce the problem** - **Provide specific examples** to demonstrate the steps - **Describe the behavior you observed** and what you expected - **Include screenshots or animated GIFs** if applicable - **Include your environment details** (OS, Node version, etc.) ### Suggesting Enhancements Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion: - **Use a clear and descriptive title** - **Provide a detailed description** of the suggested enhancement - **Explain why this enhancement would be useful** - **List any alternative solutions** you've considered ### Your First Code Contribution Unsure where to begin? Look for issues labeled: - `good first issue` - Simple issues suitable for beginners - `help wanted` - Issues where we'd appreciate community help - `documentation` - Documentation improvements ### Pull Requests We actively welcome your pull requests! Here's how to contribute code: 1. Fork the repo and create your branch from `main` 2. If you've added code that should be tested, add tests 3. Ensure the test suite passes 4. Make sure your code lints 5. Issue that pull request! ## Getting Started ### Prerequisites - Node.js >= 20.0.0 - npm >= 10.0.0 - Git ### Setup Development Environment 1. **Fork and clone the repository** ```bash git clone https://github.com/YOUR_USERNAME/wamr.git cd wamr ``` 2. **Install dependencies** ```bash npm install ``` 3. **Configure environment variables** ```bash # Backend cd backend cp .env.example .env # Edit .env with your configuration # Frontend cd ../frontend cp .env.example .env # Edit .env with your configuration ``` 4. **Generate security keys** ```bash # JWT Secret openssl rand -base64 32 # Encryption Key openssl rand -hex 32 ``` 5. **Setup database** ```bash cd backend npm run db:generate npm run db:migrate npm run db:seed ``` 6. **Start development servers** ```bash cd .. npm run dev ``` ## Development Workflow ### Branch Strategy - `main` - Production-ready code - `develop` - Integration branch for features (if used) - `feature/*` - New features - `bugfix/*` - Bug fixes - `hotfix/*` - Urgent production fixes - `docs/*` - Documentation updates ### Creating a Feature Branch ```bash git checkout main git pull origin main git checkout -b feature/your-feature-name ``` ### Making Changes 1. Make your changes in the feature branch 2. Follow the [coding conventions](#coding-conventions) 3. Write or update tests as needed 4. Ensure all tests pass: `npm run test` 5. Ensure code lints: `npm run lint` 6. Format your code: `npm run format` ### Committing Changes We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: ```bash git add . git commit -m "feat: add new feature" ``` See [Commit Message Guidelines](#commit-message-guidelines) for details. ## Coding Conventions ### TypeScript - Use TypeScript for all new code - Define types explicitly rather than using `any` - Use interfaces for object shapes - Use type aliases for unions and complex types - Export types from dedicated `types/` files ### Code Style We use ESLint and Prettier to maintain consistent code style: ```bash # Check linting npm run lint # Fix linting issues npm run lint:fix # Format code npm run format # Check formatting npm run format:check ``` **Key conventions:** - Use 2 spaces for indentation - Use single quotes for strings - Use semicolons - Use trailing commas in multi-line objects/arrays - Use arrow functions over function expressions - Use `const` over `let` when possible - Avoid `var` ### File Organization - Group related functionality in modules - Keep files focused and under 300 lines when possible - Use index files to export public APIs - Place tests alongside the code they test ### Naming Conventions - **Files**: `kebab-case.ts` - **Components**: `PascalCase.tsx` - **Variables/Functions**: `camelCase` - **Constants**: `UPPER_SNAKE_CASE` - **Types/Interfaces**: `PascalCase` - **Private members**: prefix with `_` ### Backend Conventions - Use dependency injection where appropriate - Separate concerns: routes → controllers → services → repositories - Validate all inputs using Zod schemas - Use proper error handling with custom error codes - Log important events using the provided logger - Never log sensitive information (passwords, tokens, etc.) ### Frontend Conventions - Use functional components with hooks - Keep components small and focused - Use custom hooks for reusable logic - Use React Query for server state - Use Zustand for client state - Follow the component structure: ```tsx // Imports // Types // Component // Exports ``` ## Commit Message Guidelines We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: ``` ():