A Java-based data synchronization agent that automatically pulls GitHub issues from repositories and stores them in Firebase Firestore. Built with scalability, maintainability, and error handling in mind.
- Automated GitHub Issue Sync: Fetches the most recent issues from any GitHub repository
- Firebase Firestore Integration: Stores issues as documents in Firestore collections
- Incremental Sync: Only syncs new/updated issues since the last sync to minimize API calls
- Duplicate Prevention: Automatically detects and skips existing issues
- Configurable Scheduling: Optional scheduled sync with configurable intervals
- Environment Support: Multi-environment configuration (dev/staging/prod)
- Robust Error Handling: Retry logic for network failures and API rate limits
- Comprehensive Logging: Detailed logging for monitoring and debugging
- Java 11+
- Maven 3.6+
- Firebase Project with Firestore enabled
- GitHub Personal Access Token (optional, for private repositories)
git clone <repository-url>
cd firesyncmvn clean packageThis creates a standalone JAR file at target/github-firestore-sync-1.0.0.jar.
- Create a Firebase project at Firebase Console
- Enable Firestore Database
- Generate a service account key:
- Go to Project Settings → Service Accounts
- Click "Generate new private key"
- Save the JSON file as
src/main/resources/firebase-service-account.json
The application uses environment-specific configuration files:
# GitHub Configuration
github.api.base.url=https://api.github.com
github.token=
# Repository Configuration
github.repo.owner=facebook
github.repo.name=react
# Firebase Configuration
firebase.project.id=your-firebase-project-id
firebase.service.account.path=src/main/resources/firebase-service-account.json
# Sync Configuration
sync.issues.limit=5
# Scheduler Configuration
sync.schedule.enabled=false
sync.schedule.interval.minutes=10application-dev.properties- Development environmentapplication-staging.properties- Staging environmentapplication-prod.properties- Production environment
Set the environment using the ENV variable:
export ENV=prod # or dev, stagingjava -jar target/github-firestore-sync-1.0.0.jar [options]Options:
-o, --repo-owner <owner>- GitHub repository owner-n, --repo-name <name>- GitHub repository name-h, --help- Show help message
Examples:
# Sync Facebook React repository
java -jar target/github-firestore-sync-1.0.0.jar --repo-owner facebook --repo-name react
# Sync Microsoft VSCode repository
java -jar target/github-firestore-sync-1.0.0.jar -o microsoft -n vscode
# Use production environment
ENV=prod java -jar target/github-firestore-sync-1.0.0.jarEnable scheduled sync by setting sync.schedule.enabled=true in your configuration:
sync.schedule.enabled=true
sync.schedule.interval.minutes=10When enabled, the application runs continuously and syncs at the specified interval.
Each GitHub issue is stored with the following fields:
{
"id": 123456789,
"title": "Issue title",
"state": "open|closed",
"html_url": "https://github.com/owner/repo/issues/123",
"created_at": "2023-10-15T10:30:00Z",
"updated_at": "2023-10-15T14:45:00Z"
}Issues are stored in collections named: {owner}_{repo}_issues
Example: facebook_react_issues
The application tracks sync progress in a sync_state collection. Each repository has its own sync state document with the following structure:
{
"lastSyncTimestamp": "2023-10-15T14:45:00Z",
"lastSyncedIssueId": 123456789,
"lastSyncedIssueUpdatedAt": "2023-10-15T12:30:00Z",
"updatedAt": "2023-10-15T14:45:00Z"
}Fields:
lastSyncTimestamp- When the last sync operation completedlastSyncedIssueId- ID of the most recently synced issuelastSyncedIssueUpdatedAt- When the most recent issue was last updated on GitHubupdatedAt- When this sync state document was last modified
Issues Collection: {owner}_{repo}_issues
- Example:
facebook_react_issues
Sync State Collection: sync_state
- Document ID:
{owner}_{repo}_sync_state - Example:
facebook_react_sync_state
GitHubFirestoreSync- Main application class and orchestratorGitHubService- Handles GitHub API interactionsFirestoreService- Manages Firestore operationsSyncStateService- Tracks sync state for incremental updatesSyncScheduler- Handles scheduled executionRetryUtil- Implements retry logic for failed operations
- Incremental Sync: Only fetches issues updated since the last sync
- Duplicate Prevention: Checks existing documents before inserting
- Error Recovery: Automatic retries with exponential backoff
- Connection Testing: Validates GitHub and Firebase connections before sync
- State Management: Tracks sync progress and last processed issue
Run the test suite:
mvn testGitHubServiceTest- Tests GitHub API integrationRetryUtilTest- Tests retry mechanism
The application uses SLF4J with Logback for logging. Logs are written to:
logs/firesync.log- Main application loglogs/firesync.{date}.log- Daily rotated logs
- INFO - General application flow and sync progress
- WARN - Non-critical issues and configuration warnings
- ERROR - Sync failures and critical errors
- DEBUG - Detailed debugging information
src/
├── main/
│ ├── java/com/firesync/
│ │ ├── config/ # Configuration classes
│ │ ├── exceptions/ # Custom exceptions
│ │ ├── models/ # Data models
│ │ ├── scheduler/ # Scheduling logic
│ │ ├── services/ # Core business logic
│ │ └── utils/ # Utility classes
│ └── resources/
│ ├── application*.properties # Configuration files
│ ├── firebase-service-account.json
│ └── logback.xml # Logging configuration
└── test/
└── java/com/firesync/ # Test classes
The application is designed to support multiple sync targets. To add a new target:
- Implement the
SyncTargetinterface - Add configuration for the new target
- Update the main application to use the new target
To sync additional GitHub issue fields:
- Update the
GitHubIssuemodel - Modify the
FirestoreServiceto handle new fields - Update tests accordingly
-
Firebase Authentication Error
- Verify service account JSON file path
- Check Firebase project ID configuration
- Ensure Firestore is enabled in Firebase console
-
GitHub API Rate Limiting
- Add GitHub personal access token for higher rate limits
- Check current rate limit status in logs
-
Network Connectivity
- Verify internet connection
- Check firewall settings
- Review proxy configuration if applicable
Enable debug logging by setting the log level:
<!-- In logback.xml -->
<logger name="com.firesync" level="DEBUG"/>This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For issues and questions:
- Check the troubleshooting section
- Review application logs
- Open an issue on GitHub with detailed information