Thank you for your interest in contributing! We welcome all kinds of contributions to the KhmerCoders community website, including bug reports, feature requests, code, and documentation.
- Code of Conduct
- How to Contribute
- Development Setup
- Scripts Reference
- Database Migrations & Seeding
- Coding Standards, Linting, Formatting, and Testing
- Pull Request Process
- Reporting Issues
- Community & Support
Please read and follow our Code of Conduct to foster a welcoming and respectful community.
- Fork the repository and clone it locally.
- Create a new branch for your feature or bugfix:
git checkout -b feat/your-feature-name
- Make your changes and commit them with clear messages.
- Push to your fork and submit a Pull Request (PR) to the
mainbranch. - Describe your changes in the PR and reference any related issues.
Prerequisites:
- Node.js (v18+ recommended)
- npm (v9+ recommended)
- Wrangler CLI (
npm install -g wrangler) - Cloudflare account (for production deployments)
Steps:
-
Install dependencies:
npm install
-
Run the setup script to configure your environment and database:
npm run setup
This will:
- Create a
.envfile (if missing) - Set up the local Cloudflare D1 database
- Apply database migrations
- Seed the database with initial data
- Create a
-
Start the development server:
npm run dev
The app will be available at http://localhost:3000.
| Script | Purpose |
|---|---|
| db:generate | Generate Drizzle ORM schema files |
| db:clean | Clean the local D1 database (see scripts/clean-database.js) |
| db:seed | Seed the main database (db/main/seed.sql) |
| db:seed:article | Seed articles into the main database (db/main/seed-article.sql) |
| db:migrate | Apply local database migrations |
| db:migrate:prod | Apply production database migrations |
| db:chatbot:schema | Setup chatbot database schema |
| db:chatbot:seed | Seed chatbot database |
| generate:main-schema | Generate a full schema SQL file for the main database |
| setup | Run all setup steps (env, DB, seeds, etc.) (see scripts/setup.js) |
| Script | Purpose |
|---|---|
| clean-database.js | Removes and recreates the local D1 database directory for a clean state |
| generate-auth-session.js | Generates a signed session token for testing authentication (requires BETTER_AUTH_SECRET) |
| generate-main-schema.js | Exports the current main D1 database schema to db/main/schema.sql for documentation/AI use |
| setup-env.js | Creates a .env file with required secrets and placeholders if it doesn't exist |
| setup.js | Runs all setup steps: env, clean DB, migrate, setup chatbot schema, and seed data |
-
Initialize setup:
npm run setup
-
Making changes to the database:
npm run db:generate # Generate migration files npm run db:migrate # Apply to local database npm run db:seed # Add test data if needed
-
Reset the database:
npm run db:clean # Clear everything npm run db:seed # Add fresh test data
-
Working with Chatbot Feature:
npm run db:chatbot:schema # Create the schema npm run db:chatbot:seed # Add test data
-
Linting:
- Run
npm run lintto check for code issues using ESLint. - The project uses
eslint-config-nextandeslint-config-prettierfor Next.js and Prettier compatibility. - Linting is set to be ignored during builds (see
next.config.mjs).
- Run
-
Formatting:
- Run
npm run formatto auto-format code using Prettier. - Run
npm run format:checkto check formatting without making changes.
- Run
-
Testing:
- Run
npm run testto execute tests using Vitest. - Example tests are in
src/utils/example.test.tsandsrc/utils/experience.test.ts.
- Run
-
General standards:
- Use consistent code style enforced by Prettier and ESLint.
- Write clear, descriptive commit messages.
- Prefer TypeScript for all new code.
- Validate user input and handle errors gracefully.
- Ensure your branch is up to date with
mainbefore submitting a PR. - All PRs are subject to review. Please respond to feedback and make requested changes.
- Ensure your code passes linting, formatting, and tests, and builds successfully.
- Document any new scripts or changes in this file or the README.
- Use GitHub Issues to report bugs or request features.
- Provide as much detail as possible, including steps to reproduce, expected behavior, and screenshots if relevant.
- Join our Discord, Telegram, Facebook for questions and discussions.
- Be respectful and constructive in all communications.
Thank you for helping make KhmerCoders better!