Thank you for your interest in contributing to OneURL! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Workflow
- Code Style Guidelines
- Commit Guidelines
- Pull Request Process
- Project Structure
- Common Tasks
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to kartik.labhshetwar@gmail.com.
- Node.js 20+ or Bun
- PostgreSQL database (local or cloud)
- Git
- Basic knowledge of TypeScript, React, and Next.js
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/oneurl.git cd oneurl -
Add upstream remote:
git remote add upstream https://github.com/KartikLabhshetwar/oneurl.git
-
Install dependencies:
bun install # or npm install -
Set up environment variables:
cp .env.example .env
Fill in the required environment variables (see README.md for details)
-
Set up the database:
bun prisma generate bun prisma migrate dev
-
Start the development server:
bun run dev
Always create a new branch from main for your work:
git checkout main
git pull upstream main
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix
# or
git checkout -b docs/your-documentation-updateBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation updatesrefactor/- Code refactoringtest/- Adding or updating testschore/- Maintenance tasks
- Write clean, maintainable code
- Follow the code style guidelines below
- Add comments where necessary
- Update documentation if needed
- Test your changes thoroughly
Follow the commit message guidelines (see below).
git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
- Use TypeScript for all new code
- Avoid
anytypes - use proper types orunknown - Use interfaces for object shapes, types for unions/intersections
- Prefer
constoverlet, avoidvar
- Use functional components with hooks
- Keep components small and focused (single responsibility)
- Extract reusable logic into custom hooks
- Use meaningful component and prop names
Example:
// Good
export function UserProfile({ userId }: { userId: string }) {
const { data, isLoading } = useProfile(userId);
if (isLoading) return <Spinner />;
return <div>{data.name}</div>;
}
// Avoid
export function Component({ id }: { id: string }) {
// ...
}- One component per file
- Use PascalCase for component files:
UserProfile.tsx - Use camelCase for utility files:
formatDate.ts - Group related files in folders
- Group imports: external packages, then internal modules
- Use absolute imports with
@/alias - Remove unused imports
// Good
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { useProfile } from "@/lib/hooks/use-profile";- Components: PascalCase (
UserProfile) - Functions/Variables: camelCase (
getUserData) - Constants: UPPER_SNAKE_CASE (
MAX_FILE_SIZE) - Types/Interfaces: PascalCase (
UserProfile,ApiResponse)
- Don't add unnecessary comments
- Comment complex logic or business rules
- Use JSDoc for public APIs
// Good - explains why, not what
// Skip validation for admin users to allow bulk operations
if (user.role === "admin") return;
// Avoid - obvious from code
// Set the name to the user's name
setName(user.name);- Always handle errors appropriately
- Provide meaningful error messages
- Use try-catch for async operations
- Validate user input
// Good
try {
const result = await apiCall();
return result;
} catch (error) {
console.error("Failed to fetch data:", error);
toastError("Failed to load data");
throw error;
}- Use Prisma for all database operations
- Keep queries in service files (
lib/services/) - Handle database errors gracefully
- Use transactions for multi-step operations
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
feat(settings): add avatar upload functionality
- Implement file upload with react-dropzone
- Add uploadthing integration
- Update avatar display in sidebar
Closes #123
fix(auth): handle expired session tokens
Previously, expired tokens caused app crashes.
Now properly redirects to login page.
Fixes #456
- Write clear, descriptive commit messages
- Keep commits focused (one logical change per commit)
- Use present tense ("add feature" not "added feature")
- Reference issues/PRs when applicable
-
Update your branch:
git checkout main git pull upstream main git checkout your-branch git rebase main
-
Run linting:
bun run lint
-
Test your changes:
- Test manually in the browser
- Verify all existing functionality still works
- Test edge cases
-
Update documentation if needed
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
How was this tested?
## Screenshots (if applicable)
Add screenshots here
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings/errors
- [ ] Tests pass- Maintainers will review your PR
- Address any feedback or requested changes
- Keep PRs focused and reasonably sized
- Respond to comments promptly
- Once approved, maintainers will merge
oneurl/
├── app/ # Next.js App Router
│ ├── (auth)/ # Authentication routes
│ ├── (dashboard)/ # Protected dashboard routes
│ ├── (onboarding)/ # Onboarding flow
│ ├── [username]/ # Public profile pages
│ └── api/ # API routes
├── components/ # React components
│ ├── landing/ # Landing page components
│ └── ui/ # Reusable UI components
├── lib/ # Utilities and services
│ ├── hooks/ # Custom React hooks
│ ├── services/ # Business logic
│ └── validations/ # Zod schemas
├── prisma/ # Database schema and migrations
└── public/ # Static assets
app/layout.tsx- Root layoutlib/db.ts- Database clientlib/auth.ts- Authentication setupprisma/schema.prisma- Database schema
- Create a feature branch
- Add necessary database migrations (if needed)
- Implement the feature
- Add/update tests
- Update documentation
- Create PR
- Reproduce the bug
- Create a fix branch
- Write a test that fails (if applicable)
- Fix the bug
- Verify the fix
- Create PR with clear description
- Create route file in
app/api/ - Add authentication if needed (
requireAuth) - Add input validation (Zod schemas)
- Handle errors properly
- Return appropriate status codes
- Update API documentation
- Create component in
components/ui/or appropriate folder - Make it reusable and well-typed
- Add proper accessibility attributes
- Use Tailwind CSS for styling
- Export from appropriate index file
- Update
prisma/schema.prisma - Create migration:
bun prisma migrate dev --name your-migration-name - Update related code
- Test thoroughly
- Questions? Open a discussion on GitHub
- Found a bug? Open an issue with details
- Have a feature request? Open an issue with use case
- Need clarification? Comment on the relevant issue/PR
Contributors will be recognized in:
- Project README
- Release notes
- GitHub contributors page
Thank you for contributing to OneURL! 🎉