This document outlines the guidelines for contributing to the VPN Service project. Following these guidelines helps maintain code quality, consistency, and makes the development process more efficient.
- Project Structure
- Code Style
- Git Workflow
- Backend Development
- Frontend Development
- Docker Guidelines
- Testing
- Security
- Documentation
- CI/CD
The project consists of several key components:
- Backend: Node.js API service
- Admin Panel: Next.js web application
- Database: Managed by Supabase
- Infrastructure: Docker containers for local development and production deployment
We enforce code style with ESLint and EditorConfig:
- ESLint: Use the project's
.eslintrc.js
configurations for both backend and frontend - Indentation: 2 spaces
- Quotes: Single quotes for JavaScript/TypeScript, double quotes for HTML attributes
- Semicolons: Required
- Line length: 100 characters maximum
- Trailing commas: Required for multiline objects and arrays
main
: Production branch, always stabledev
: Development branch, contains features ready for next releasefeature/*
: Feature branches for new functionalityfix/*
: Bugfix branchesrefactor/*
: Code refactoring branchesdocs/*
: Documentation updates
All commit messages must follow the Conventional Commits specification:
Feat(scope): message
- New featuresFix(scope): message
- Bug fixesDocs(scope): message
- Documentation changesStyle(scope): message
- Code style changes (formatting, etc.)Refactor(scope): message
- Code refactoringPerf(scope): message
- Performance improvementsTest(scope): message
- TestsChore(scope): message
- Build, dependencies, config changes
Example: Feat(admin): add subscription management page
- Create PRs for all changes
- Request at least one review
- Ensure all tests and lint checks pass
- Squash commits when merging to main
- Follow RESTful principles
- Use consistent naming conventions
- Include version in API path (e.g.,
/api/v1/users
) - Document all endpoints using OpenAPI/Swagger
- Use appropriate HTTP status codes
- Return consistent error objects:
{ "error": { "code": "ERROR_CODE", "message": "Human readable message", "details": {} } }
- Always use HTTPS
- Implement rate limiting for authentication endpoints
- Use JWT tokens with appropriate expiration
- Group components by feature/domain
- Create reusable UI components in
components/ui
- Follow atomic design principles (atoms, molecules, organisms)
- Use React Query for server state
- Use React Context or Zustand for global UI state
- Keep local component state with useState when appropriate
- Use Tailwind CSS for styling
- Create reusable utility classes
- Use CSS variables for theming
- Use React Hook Form for form handling
- Implement client-side validation
- Show clear error messages
- Keep images as small as possible
- Use multi-stage builds
- Don't run containers as root
- Use specific version tags for base images
- Include health checks
- Document all environment variables
- Use Jest for unit and integration tests
- Maintain at least 70% code coverage
- Mock external services
- Use separate test database
- Use Jest and React Testing Library
- Test user flows and interactions
- Write component tests for reusable components
- Use Cypress for end-to-end testing
- Never commit secrets or credentials
- Use environment variables for configuration
- Validate all user input
- Implement proper authorization checks
- Follow OWASP security guidelines
- Regularly update dependencies
- Use Content Security Policy
- Document all APIs
- Maintain up-to-date README files
- Document environment variables in
.env.example
- Include setup instructions for new developers
- Comment complex code sections
Our CI/CD pipeline uses GitHub Actions for:
- Running tests
- Linting code
- Building Docker images
- Deploying to environments
- Development: Automatic deployment from
dev
branch - Staging: Manual promotion from development
- Production: Manual promotion from staging
- Clone the repository
- Copy
.env.example
to.env
and configure variables - Run
docker-compose up
to start local development environment - Make changes following the guidelines above
- Submit pull request
- Always commit your code changes after making modifications
- Use descriptive commit messages following the conventional commits specification
- Push your changes to the repository after committing
- When making multiple related changes, group them into logical commits
Follow the conventional commits specification:
feat(component): add new component
- New featuresfix(api): fix api error
- Bug fixesdocs(readme): update readme
- Documentation changesrefactor(utils): refactor utils
- Code refactoringstyle(tailwind): add new tailwind class
- Style changestest(unit): add unit test
- Test additions/changeschore(deps): update dependencies
- Routine tasks, dependency updates