Thank you for your interest in contributing to OpenCodeHub! This document provides guidelines and information about contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Coding Standards
- Pull Request Process
- Testing
- Documentation
By participating in this project, you agree to abide by our Code of Conduct. Please be respectful and constructive in all interactions.
- Node.js 20 or later
- npm or pnpm
- Docker (for running services)
- Git
-
Fork the repository
Click the "Fork" button on GitHub to create your own copy.
-
Clone your fork
git clone https://github.com/YOUR_USERNAME/opencodehub.git cd opencodehub -
Install dependencies
npm install
-
Set up environment
cp .env.example .env # Edit .env with your local settings -
Start development services
# Start database and Redis docker-compose up -d postgres redis # Run database migrations npm run db:migrate
-
Start the development server
npm run dev
The application will be available at
http://localhost:4321
opencodehub/
├── src/
│ ├── components/ # React and Astro components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── layout/ # Layout components
│ │ ├── editor/ # Code editor components
│ │ └── git/ # Git-related components
│ ├── db/ # Database layer
│ │ ├── adapter/ # Universal Database Adapter
│ │ └── schema/ # Drizzle ORM schemas
│ ├── lib/ # Core utilities and services
│ │ ├── auth.ts # Authentication
│ │ ├── git.ts # Git operations
│ │ ├── ssh.ts # SSH server
│ │ ├── pipeline.ts # CI/CD pipeline
│ │ └── storage.ts # File storage
│ ├── pages/ # Astro pages and API routes
│ │ ├── api/ # REST API endpoints
│ │ └── [owner]/ # Dynamic repository pages
│ ├── layouts/ # Astro layouts
│ └── styles/ # Global styles
├── scripts/ # Build and utility scripts
├── public/ # Static assets
├── tests/ # Test files
└── docker/ # Docker configuration
- Use TypeScript for all code
- Enable strict mode
- Avoid
anytypes when possible - Use interfaces for object types
- Document complex functions with JSDoc
/**
* Creates a new repository for the given user.
* @param userId - The ID of the user creating the repository
* @param options - Repository creation options
* @returns The created repository
*/
export async function createRepository(
userId: string,
options: CreateRepositoryOptions
): Promise<Repository> {
// Implementation
}- Use functional components with hooks
- Use TypeScript interfaces for props
- Keep components small and focused
- Use composition over inheritance
interface ButtonProps {
variant?: "default" | "outline" | "ghost";
size?: "sm" | "md" | "lg";
children: React.ReactNode;
onClick?: () => void;
}
export function Button({
variant = "default",
size = "md",
children,
onClick,
}: ButtonProps) {
return (
<button className={cn(buttonVariants({ variant, size }))} onClick={onClick}>
{children}
</button>
);
}- Use
.astroextension for pages - Keep pages thin - delegate logic to components
- Use layouts for common structure
- Follow REST conventions
- Use proper HTTP status codes
- Validate input with Zod
- Return consistent response shapes
// Good response shape
{
success: true,
data: { ... }
}
// Error response
{
success: false,
error: {
code: "VALIDATION_ERROR",
message: "Invalid email address"
}
}- Use conventional commits format:
feat:New featuresfix:Bug fixesdocs:Documentationstyle:Code style changesrefactor:Code refactoringtest:Testschore:Build/tooling changes
feat: add repository forking functionality
- Add fork button to repository page
- Create API endpoint for forking
- Handle fork conflicts
Closes #123
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Write clean, well-documented code
- Add tests for new functionality
- Update documentation as needed
-
Run tests and linting
npm run lint npm run test npm run build -
Commit your changes
git add . git commit -m "feat: add your feature description"
-
Push to your fork
git push origin feature/your-feature-name
-
Open a Pull Request
- Provide a clear description of changes
- Reference any related issues
- Add screenshots for UI changes
- Request review from maintainers
- Code follows project style guidelines
- Tests pass and new tests added
- Documentation updated
- No breaking changes (or documented)
- Security considerations addressed
- Performance impact considered
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageimport { describe, it, expect } from "vitest";
import { createRepository } from "../lib/repository";
describe("createRepository", () => {
it("should create a repository with default settings", async () => {
const repo = await createRepository("user-1", {
name: "test-repo",
description: "A test repository",
});
expect(repo.name).toBe("test-repo");
expect(repo.visibility).toBe("public");
});
it("should throw on invalid repository name", async () => {
await expect(
createRepository("user-1", { name: "invalid name!" })
).rejects.toThrow("Invalid repository name");
});
});# Run E2E tests
npm run test:e2e- Add JSDoc comments to public functions
- Document complex algorithms
- Include usage examples
- Update README for new features
- Keep installation instructions current
- Add to API documentation
- Add entries to CHANGELOG.md
- Follow Keep a Changelog format
- Open an issue for bugs or features
- Join our Discord community
- Check existing issues and PRs
Contributors are recognized in:
- README.md contributors section
- Release notes
- Special thanks in major releases
Thank you for contributing to OpenCodeHub! 🎉