Welcome to CodeForge! This guide will help you get started with contributing to our competitive programming platform.
- Getting Started
- Development Workflow
- Coding Standards
- Git Workflow
- Pull Request Process
- Code Review Guidelines
- Node.js 20+
- npm 9+
- Git
# Clone the repository
git clone https://github.com/gfg-mitadt/codeforge.git
cd codeforge
# Install all dependencies
npm run install:all
# Set up Husky (pre-commit hooks)
npx husky install
# Copy environment files
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env.local
# Start development servers
npm run devBackend (backend/.env):
DATABASE_URL="your-supabase-url"
JWT_SECRET="random-secret-key"
Frontend (frontend/.env.local):
NEXT_PUBLIC_API_URL="http://localhost:5000"
NEXT_PUBLIC_WS_URL="http://localhost:5000"
- Pull latest changes from
develop - Create a feature branch
- Make your changes
- Run linting:
npm run lint - Test locally
- Commit with a meaningful message
- Push and create a PR
# Both frontend and backend
npm run dev
# Frontend only (http://localhost:3000)
cd frontend && npm run dev
# Backend only (http://localhost:5000)
cd backend && npm run dev| Command | Description |
|---|---|
npm run dev |
Start both servers |
npm run lint |
Run ESLint on all code |
npm run format |
Format code with Prettier |
npm run build |
Build for production |
npm run db:push |
Push Prisma schema to DB |
npm run db:seed |
Seed sample data |
- Use TypeScript for all new code
- Avoid
anytype - use proper types orunknown - Use interfaces for object shapes
- Export types alongside functions
// Good
interface User {
id: string
email: string
rating: number
}
export function getUser(id: string): Promise<User> {
// ...
}
// Bad
export function getUser(id: any): Promise<any> {
// ...
}| Type | Convention | Example |
|---|---|---|
| Variables | camelCase | userName, contestId |
| Functions | camelCase | fetchProblems(), handleSubmit() |
| Components | PascalCase | ProblemCard, Navbar |
| Files (components) | PascalCase | ProblemCard.tsx |
| Files (utilities) | camelCase | api.ts, utils.ts |
| Constants | UPPER_SNAKE | MAX_RATING, API_URL |
| Types/Interfaces | PascalCase | User, Problem |
// Use function components with TypeScript
interface Props {
title: string
rating: number
onSolve?: () => void
}
export function ProblemCard({ title, rating, onSolve }: Props) {
return (
<div className="...">
<h3>{title}</h3>
<span>{rating}</span>
{onSolve && <button onClick={onSolve}>Solve</button>}
</div>
)
}- Use Tailwind CSS classes
- Follow the GFG MIT-ADT color palette
- Use CSS variables for theme colors
- Keep class lists readable with line breaks for long lists
// Good
<div className="
flex items-center gap-4 p-4
bg-card border border-border rounded-lg
hover:shadow-lg transition-shadow
">
// Bad - too long single line
<div className="flex items-center gap-4 p-4 bg-card border border-border rounded-lg hover:shadow-lg transition-shadow">// Route structure
router.get('/', async (req, res) => {
try {
const data = await prisma.problem.findMany()
res.json(data)
} catch (err) {
console.error(err)
res.status(500).json({ message: 'Failed to fetch' })
}
})
// Always:
// - Use try/catch
// - Return meaningful error messages
// - Log errors for debugging
// - Use proper HTTP status codes- Always catch async errors
- Use meaningful error messages
- Log errors with context
- Return user-friendly messages
try {
await submitCode(code, problemId)
} catch (err) {
console.error('Submission failed:', err)
toast.error('Failed to submit. Please try again.')
}feature/user-profile
feature/contest-leaderboard
fix/login-redirect
fix/rating-calculation
chore/update-deps
docs/api-documentation
Follow Conventional Commits:
feat: add user profile page
fix: correct rating calculation
docs: update API documentation
style: format code with prettier
refactor: simplify submission logic
test: add contest registration tests
chore: update dependencies
main (protected)
└── develop
├── feature/user-profile
├── feature/contest-timer
└── fix/login-error
main: Production-ready codedevelop: Integration branchfeature/*: New featuresfix/*: Bug fixes
- Run
npm run lintand fix errors - Test your changes locally
- Update documentation if needed
- Rebase on latest
develop
feat: add problem difficulty filter
fix: resolve leaderboard sorting issue
docs: update setup instructions
Use the PR template. Include:
- What changes were made
- Why they were made
- How to test
- Screenshots for UI changes
- Create PR from your branch to
develop - Request review from at least 1 team member
- Address review comments
- Squash and merge when approved
- Keep PRs small and focused
- Respond to feedback promptly
- Explain your decisions
- Be open to suggestions
- Be respectful and constructive
- Focus on logic and correctness
- Suggest improvements, don't demand
- Approve promptly when ready
- Code correctness
- Error handling
- Performance concerns
- Security issues
- Type safety
- Naming clarity
- Code duplication