Contributing to SecureHealth
Guidelines for contributing to the SecureHealth project, including code standards, pull request process, and community guidelines.
Getting Startedβ
Prerequisitesβ
- PHP 8.1 or higher
- Composer
- MongoDB Atlas account
- Git
- Node.js (for frontend development)
Development Setupβ
-
Fork the Repository
git clone https://github.com/your-username/securehealth.git
cd securehealth -
Install Dependencies
composer install
npm install -
Environment Configuration
cp .env.example .env.local
# Edit .env.local with your configuration -
Database Setup
# Create MongoDB Atlas cluster
# Configure encryption keys
# Run database migrations
Code Standardsβ
PHP Coding Standardsβ
We follow PSR-12 coding standards:
<?php
declare(strict_types=1);
namespace App\Service;
use App\Entity\Patient;
use App\Repository\PatientRepository;
class PatientService
{
public function __construct(
private PatientRepository $patientRepository,
private EncryptionService $encryptionService
) {
}
public function createPatient(array $data): Patient
{
$patient = new Patient();
$patient->setFirstName($data['firstName']);
$patient->setLastName($data['lastName']);
return $this->patientRepository->save($patient);
}
}
JavaScript/TypeScript Standardsβ
We use ESLint and Prettier for code formatting:
// Use const/let instead of var
const patientData = await fetchPatient(id);
let processedData = processPatientData(patientData);
// Use arrow functions for callbacks
const patients = data.map(patient => ({
id: patient.id,
name: `${patient.firstName} ${patient.lastName}`
}));
// Use async/await instead of promises
async function fetchPatient(id) {
try {
const response = await fetch(`/api/patients/${id}`);
return await response.json();
} catch (error) {
console.error('Error fetching patient:', error);
throw error;
}
}
Security Standardsβ
-
Input Validation
// Always validate input
$validator = $this->validator->validate($data, [
'firstName' => [new NotBlank(), new Length(['min' => 2, 'max' => 50])],
'email' => [new NotBlank(), new Email()],
]); -
SQL Injection Prevention
// Use parameterized queries
$patients = $this->patientRepository->findBy([
'firstName' => $firstName,
'lastName' => $lastName
]); -
XSS Prevention
// Escape output
echo htmlspecialchars($userInput, ENT_QUOTES, 'UTF-8');
Pull Request Processβ
Before Submittingβ
-
Create a Feature Branch
git checkout -b feature/your-feature-name -
Write Tests
// tests/Service/PatientServiceTest.php
public function testCreatePatient(): void
{
$data = [
'firstName' => 'John',
'lastName' => 'Doe',
'email' => 'john@example.com'
];
$patient = $this->patientService->createPatient($data);
$this->assertInstanceOf(Patient::class, $patient);
$this->assertEquals('John', $patient->getFirstName());
} -
Run Tests
phpunit
npm test -
Check Code Quality
composer cs-check
composer cs-fix
Pull Request Guidelinesβ
-
Title Format
feat: add patient search functionality
fix: resolve encryption key validation issue
docs: update API documentation
test: add unit tests for PatientService -
Description Template
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows project standards
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or documented) -
Review Process
- All PRs require at least one review
- Address feedback promptly
- Keep PRs focused and small
- Update documentation as needed
Issue Reportingβ
Bug Reportsβ
Use the bug report template:
## Bug Description
Clear description of the bug
## Steps to Reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Expected Behavior
What you expected to happen
## Actual Behavior
What actually happened
## Environment
- OS: [e.g., macOS, Windows, Linux]
- PHP Version: [e.g., 8.1.0]
- MongoDB Version: [e.g., 6.0]
- Application Version: [e.g., 1.0.0]
## Additional Context
Any other context about the problem
Feature Requestsβ
Use the feature request template:
## Feature Description
Clear description of the feature
## Use Case
Why is this feature needed?
## Proposed Solution
How should this feature work?
## Alternatives Considered
Other solutions you've considered
## Additional Context
Any other context about the feature request
Development Workflowβ
Git Workflowβ
-
Main Branch
main: Production-ready codedevelop: Integration branch for features
-
Feature Branches
feature/feature-name: New featuresbugfix/bug-description: Bug fixeshotfix/critical-fix: Critical fixes
-
Commit Messages
feat: add patient search functionality
fix: resolve encryption key validation issue
docs: update API documentation
test: add unit tests for PatientService
refactor: improve code organization
Testing Strategyβ
-
Unit Tests
// Test individual methods
public function testEncryptPatientData(): void
{
$data = ['firstName' => 'John', 'lastName' => 'Doe'];
$encrypted = $this->encryptionService->encrypt($data);
$this->assertNotEquals($data, $encrypted);
} -
Integration Tests
// Test component interactions
public function testPatientCreationFlow(): void
{
$patientData = $this->createValidPatientData();
$patient = $this->patientService->createPatient($patientData);
$this->assertInstanceOf(Patient::class, $patient);
} -
End-to-End Tests
// Test complete user workflows
test('Patient can view their medical records', async () => {
await page.goto('/patient-portal');
await page.click('[data-testid="view-records"]');
await expect(page.locator('[data-testid="medical-history"]')).toBeVisible();
});
Code Review Guidelinesβ
For Reviewersβ
-
Check Code Quality
- Follows coding standards
- Proper error handling
- Security considerations
- Performance implications
-
Verify Tests
- Adequate test coverage
- Tests are meaningful
- Edge cases covered
-
Documentation
- Code is well-documented
- API documentation updated
- README updated if needed
For Authorsβ
-
Prepare for Review
- Self-review your code
- Run all tests
- Check code quality tools
- Update documentation
-
Respond to Feedback
- Address all comments
- Ask questions if unclear
- Be open to suggestions
- Keep discussions constructive
Community Guidelinesβ
Code of Conductβ
-
Be Respectful
- Use welcoming and inclusive language
- Respect different viewpoints
- Accept constructive criticism
-
Be Collaborative
- Help others learn and grow
- Share knowledge and experience
- Work together towards common goals
-
Be Professional
- Focus on the code, not the person
- Provide constructive feedback
- Maintain a positive attitude
Communicationβ
-
GitHub Issues
- Use for bug reports and feature requests
- Provide clear descriptions
- Use appropriate labels
-
Discussions
- Use for general questions
- Share ideas and proposals
- Get help and support
-
Pull Requests
- Use for code contributions
- Follow the PR process
- Respond to feedback promptly
Getting Helpβ
Resourcesβ
-
Documentation
- API Reference
- Configuration Guide
- Troubleshooting Guide
-
Community
- GitHub Discussions
- Stack Overflow
- Discord Server
-
Support
- GitHub Issues
- Email: support@securehealth.dev
Mentorshipβ
We welcome contributors of all skill levels:
-
New Contributors
- Start with documentation issues
- Look for "good first issue" labels
- Ask questions in discussions
-
Experienced Contributors
- Help mentor new contributors
- Review pull requests
- Share knowledge and experience
Recognitionβ
Contributorsβ
We recognize contributors in several ways:
-
GitHub Contributors
- Listed in repository contributors
- Mentioned in release notes
-
Hall of Fame
- Featured on project website
- Special recognition for significant contributions
-
Community Awards
- Monthly contributor spotlight
- Annual community awards
Next Stepsβ
- GitHub Integration - GitHub workflow and automation
- Support - Getting help and support
- Roadmap - Project roadmap and future plans