Thank you for your interest in contributing to FluxGate! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Coding Standards
- Testing
- Submitting Changes
- Review Process
By participating in this project, you agree to maintain a respectful and inclusive environment. Please:
- Be respectful and constructive in discussions
- Welcome newcomers and help them get started
- Focus on what is best for the community
- Show empathy towards other community members
- Java 11+ - Required for building and running the project
- Maven 3.8+ - Build tool
- Docker - For running Redis and MongoDB during development
- Git - Version control
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/fluxgate.git
cd fluxgate- Add the upstream repository:
git remote add upstream https://github.com/OpenFluxGate/fluxgate.gitWe provide Docker Compose files for local development in the docker/ directory:
| File | Description |
|---|---|
docker/full.yml |
All services (Redis, MongoDB, ELK) - Recommended for development |
docker/redis-standalone.yml |
Redis standalone only |
docker/redis-cluster.yml |
Redis cluster (3 nodes) |
docker/mongo.yml |
MongoDB only |
docker/elk.yml |
Elasticsearch, Logstash, Kibana |
# Start all services (recommended)
docker compose -f docker/full.yml up -d
# Verify services are running
docker compose -f docker/full.yml ps
# Stop services
docker compose -f docker/full.yml down# Build all modules
./mvnw clean install
# Build without tests (faster)
./mvnw clean install -DskipTests# Run all tests and verify (required before PR)
./mvnw clean verify
# Run tests only
./mvnw test
# Run tests for specific module
./mvnw test -pl fluxgate-core- Open the project as a Maven project
- Enable annotation processing:
Settings > Build > Compiler > Annotation Processors - Import code style:
Settings > Editor > Code Style > Import Scheme
- Install "Extension Pack for Java"
- Open the project folder
- Let Maven import complete
Create a branch from main with a descriptive name:
feature/- New features (e.g.,feature/sliding-window-algorithm)development/- New module (e.g.,development/fluxgate-sample-something)fix/- Bug fixes (e.g.,fix/redis-connection-timeout)docs/- Documentation changes (e.g.,docs/api-reference)refactor/- Code refactoring (e.g.,refactor/cleanup-handlers)test/- Test additions or modifications (e.g.,test/redis-integration)
# Create a new branch
git checkout -b feature/your-feature-name
# Keep your branch updated
git fetch upstream
git rebase upstream/mainFollow the Conventional Commits specification:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or modifying testschore: Build process or auxiliary tool changes
Examples:
feat(redis): add connection pool monitoring
fix(core): handle null key resolver gracefully
docs(readme): add quick start guide
test(mongo): add integration tests for rule storeWe follow the Google Java Style Guide with some modifications:
- Indentation: 4 spaces (not tabs)
- Line length: 120 characters maximum
- Braces: Always use braces for control statements
- Write self-documenting code with clear variable/method names
- Add Javadoc for all public classes and methods
- Keep methods focused and small (< 30 lines preferred)
- Follow SOLID principles
- Avoid code duplication
All public APIs must have Javadoc:
/**
* Attempts to consume tokens from the rate limiter.
*
* @param context the request context containing client information
* @param ruleSet the rate limit rules to apply
* @param tokens the number of tokens to consume
* @return the result of the rate limit check
* @throws IllegalArgumentException if tokens is less than 1
*/
public RateLimitResult tryConsume(RequestContext context, RateLimitRuleSet ruleSet, long tokens);org.fluxgate
├── core # Core abstractions and interfaces
│ ├── config # Configuration classes
│ ├── context # Request context
│ ├── handler # Rate limit handlers
│ ├── key # Key resolution
│ └── ratelimiter # Rate limiter implementations
├── redis # Redis-specific implementation
├── adapter.mongo # MongoDB adapter
└── spring # Spring Boot integration
- Unit Tests - Test individual classes in isolation
- Integration Tests - Test component interactions
- End-to-End Tests - Test complete flows
- Use descriptive test method names
- Follow the Arrange-Act-Assert pattern
- Mock external dependencies in unit tests
- Use
@Tagfor test categorization
@Test
@DisplayName("Should reject request when rate limit exceeded")
void shouldRejectWhenRateLimitExceeded() {
// Arrange
RateLimiter limiter = createLimiter(10);
consumeTokens(limiter, 10);
// Act
RateLimitResult result = limiter.tryConsume(context, ruleSet, 1);
// Assert
assertThat(result.isAllowed()).isFalse();
assertThat(result.getRemainingTokens()).isZero();
}- Aim for at least 80% code coverage
- Focus on testing business logic and edge cases
- Don't test trivial getters/setters
-
Start infrastructure (if not running):
docker compose -f docker/full.yml up -d
-
Update your branch:
git fetch upstream git rebase upstream/main
-
Apply code formatting:
./mvnw spotless:apply
-
Run all tests and verify:
./mvnw clean verify
This command runs:
- Code compilation
- Unit tests
- Integration tests
- Code coverage checks (JaCoCo)
- Code formatting checks (Spotless)
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub
-
Fill in the PR template with:
- Clear description of changes
- Related issue numbers
- Testing performed
- Screenshots (if UI changes)
- Code follows the project style guide
- All tests pass locally
- New code has appropriate test coverage
- Javadoc added for new public APIs
- README updated if needed
- CHANGELOG updated for notable changes
- Automated checks run first (CI/CD)
- Code review by maintainers
- Feedback provided as comments
- Approval when all requirements met
- Merge by maintainer
- Be open to suggestions
- Ask questions if feedback is unclear
- Make requested changes promptly
- Mark conversations as resolved when addressed
- Delete your feature branch
- Pull the latest changes:
git checkout main git pull upstream main
- Questions/Bugs: Open a GitHub Issue
- Security: Email security@openfluxgate.org (do not open public issues)
Contributors are recognized in:
- Release notes
- GitHub contributors list
- Project documentation
Thank you for contributing to FluxGate!