|
| 1 | +# InnerSource Measurement Tool - Architecture Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The InnerSource Measurement Tool is designed to analyze GitHub repositories and measure the level of cross-team collaboration (InnerSource) happening within them. This document provides detailed architectural information for developers and contributors. |
| 6 | + |
| 7 | +## System Architecture |
| 8 | + |
| 9 | +### Component Diagram |
| 10 | + |
| 11 | +```bash |
| 12 | +┌─────────────────────────────────────────────────────────────────────────────────┐ |
| 13 | +│ InnerSource Measurement Tool │ |
| 14 | +│ │ |
| 15 | +│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │ |
| 16 | +│ │ Environment │ │ Authentication │ │ Report Writer │ │ Markdown │ │ |
| 17 | +│ │ Configuration │ │ Manager │ │ │ │ Helpers │ │ |
| 18 | +│ │ (config.py) │ │ (auth.py) │ │(markdown_writer │ │(markdown_ │ │ |
| 19 | +│ │ │ │ │ │ .py) │ │helpers.py) │ │ |
| 20 | +│ └─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────┘ │ |
| 21 | +│ │ │ |
| 22 | +│ ┌─────────────────────────────────────────────────────────────────────────────┐ │ |
| 23 | +│ │ Core Analysis Engine │ │ |
| 24 | +│ │ (measure_innersource.py) │ │ |
| 25 | +│ │ │ │ |
| 26 | +│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ ┌─────────────┐ │ │ |
| 27 | +│ │ │ Repository │ │ Organization │ │ Team Boundary │ │ Contribution│ │ │ |
| 28 | +│ │ │ Data Fetcher │ │ Data Loader │ │ Detector │ │ Analyzer │ │ │ |
| 29 | +│ │ └───────────────┘ └───────────────┘ └───────────────┘ └─────────────┘ │ │ |
| 30 | +│ └─────────────────────────────────────────────────────────────────────────────┘ │ |
| 31 | +└─────────────────────────────────────────────────────────────────────────────────┘ |
| 32 | + │ |
| 33 | + ▼ |
| 34 | +┌─────────────────────────────────────────────────────────────────────────────────┐ |
| 35 | +│ External Dependencies │ |
| 36 | +│ │ |
| 37 | +│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │ |
| 38 | +│ │ GitHub API │ │ File System │ │ org-data.json │ │ Output │ │ |
| 39 | +│ │ │ │ │ │ │ │ Files │ │ |
| 40 | +│ │ • Repositories │ │ • Read/Write │ │ • Org Structure │ │ • Markdown │ │ |
| 41 | +│ │ • Commits │ │ • File Handling │ │ • Manager Data │ │ • Reports │ │ |
| 42 | +│ │ • Pull Requests │ │ │ │ │ │ │ │ |
| 43 | +│ │ • Issues │ │ │ │ │ │ │ │ |
| 44 | +│ └─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────┘ │ |
| 45 | +└─────────────────────────────────────────────────────────────────────────────────┘ |
| 46 | +``` |
| 47 | + |
| 48 | +## Core Components |
| 49 | + |
| 50 | +### 1. Configuration Management (`config.py`) |
| 51 | + |
| 52 | +**Responsibilities:** |
| 53 | + |
| 54 | +- Parse and validate environment variables |
| 55 | +- Provide type-safe configuration access |
| 56 | +- Handle default values and required parameters |
| 57 | +- Support multiple authentication methods |
| 58 | + |
| 59 | +### 2. Authentication Manager (`auth.py`) |
| 60 | + |
| 61 | +**Responsibilities:** |
| 62 | + |
| 63 | +- Authenticate with GitHub using multiple methods |
| 64 | +- Handle GitHub Enterprise Server installations |
| 65 | +- Manage JWT tokens for GitHub App authentication |
| 66 | +- Provide unified authentication interface |
| 67 | + |
| 68 | +### 3. Core Analysis Engine (`measure_innersource.py`) |
| 69 | + |
| 70 | +**Responsibilities:** |
| 71 | + |
| 72 | +- Orchestrate the entire analysis process |
| 73 | +- Implement team boundary detection algorithm |
| 74 | +- Manage chunked processing for large repositories |
| 75 | +- Calculate InnerSource metrics and ratios |
| 76 | + |
| 77 | +### 4. Report Generation (`markdown_writer.py`) |
| 78 | + |
| 79 | +**Responsibilities:** |
| 80 | + |
| 81 | +- Generate structured Markdown reports |
| 82 | +- Format data for human consumption |
| 83 | +- Handle edge cases and missing data |
| 84 | +- Provide consistent report structure |
| 85 | + |
| 86 | +### 5. Utility Functions (`markdown_helpers.py`) |
| 87 | + |
| 88 | +**Responsibilities:** |
| 89 | + |
| 90 | +- Manage file size constraints |
| 91 | +- Split large files intelligently |
| 92 | +- Preserve content integrity during splits |
| 93 | + |
| 94 | +## Data Flow Architecture |
| 95 | + |
| 96 | +### Processing Pipeline |
| 97 | + |
| 98 | +```bash |
| 99 | +┌─────────────────┐ |
| 100 | +│ Start Process │ |
| 101 | +└─────────────────┘ |
| 102 | + │ |
| 103 | + ▼ |
| 104 | +┌─────────────────┐ |
| 105 | +│ Load & Validate │ |
| 106 | +│ Configuration │ |
| 107 | +└─────────────────┘ |
| 108 | + │ |
| 109 | + ▼ |
| 110 | +┌─────────────────┐ |
| 111 | +│ Authenticate │ |
| 112 | +│ with GitHub │ |
| 113 | +└─────────────────┘ |
| 114 | + │ |
| 115 | + ▼ |
| 116 | +┌─────────────────┐ |
| 117 | +│ Fetch Repository│ |
| 118 | +│ Metadata │ |
| 119 | +└─────────────────┘ |
| 120 | + │ |
| 121 | + ▼ |
| 122 | +┌─────────────────┐ |
| 123 | +│ Load org-data │ |
| 124 | +│ .json File │ |
| 125 | +└─────────────────┘ |
| 126 | + │ |
| 127 | + ▼ |
| 128 | +┌─────────────────┐ |
| 129 | +│ Determine Team │ |
| 130 | +│ Boundaries │ |
| 131 | +└─────────────────┘ |
| 132 | + │ |
| 133 | + ▼ |
| 134 | +┌─────────────────┐ |
| 135 | +│ Analyze Commits │ |
| 136 | +│ (Chunked) │ |
| 137 | +└─────────────────┘ |
| 138 | + │ |
| 139 | + ▼ |
| 140 | +┌─────────────────┐ |
| 141 | +│ Analyze PRs │ |
| 142 | +│ (Chunked) │ |
| 143 | +└─────────────────┘ |
| 144 | + │ |
| 145 | + ▼ |
| 146 | +┌─────────────────┐ |
| 147 | +│ Analyze Issues │ |
| 148 | +│ (Chunked) │ |
| 149 | +└─────────────────┘ |
| 150 | + │ |
| 151 | + ▼ |
| 152 | +┌─────────────────┐ |
| 153 | +│ Calculate │ |
| 154 | +│ Metrics │ |
| 155 | +└─────────────────┘ |
| 156 | + │ |
| 157 | + ▼ |
| 158 | +┌─────────────────┐ |
| 159 | +│ Generate Report │ |
| 160 | +└─────────────────┘ |
| 161 | + │ |
| 162 | + ▼ |
| 163 | +┌─────────────────┐ |
| 164 | +│ Handle File │ |
| 165 | +│ Size Limits │ |
| 166 | +└─────────────────┘ |
| 167 | + │ |
| 168 | + ▼ |
| 169 | +┌─────────────────┐ |
| 170 | +│ Output Results │ |
| 171 | +└─────────────────┘ |
| 172 | +``` |
| 173 | + |
| 174 | +## Error Handling |
| 175 | + |
| 176 | +### Error Categories |
| 177 | + |
| 178 | +1. **Configuration Errors**: Missing or invalid environment variables |
| 179 | +2. **Authentication Errors**: Invalid tokens or insufficient permissions |
| 180 | +3. **Network Errors**: API timeouts or connectivity issues |
| 181 | +4. **Data Errors**: Missing org-data.json or invalid format |
| 182 | +5. **Processing Errors**: Unexpected data structures or edge cases |
0 commit comments