Skip to content

Latest commit

 

History

History
745 lines (614 loc) · 17.2 KB

File metadata and controls

745 lines (614 loc) · 17.2 KB

🏗️ GitForge Equity System - Technical Overview

Complete System Architecture & Implementation Details


📊 System Architecture

┌─────────────────────────────────────────────────────────────────┐
│                     GitForge Equity System                       │
└─────────────────────────────────────────────────────────────────┘
                                │
                ┌───────────────┴───────────────┐
                │                               │
        ┌───────▼────────┐            ┌────────▼────────┐
        │  GitHub Actions │            │  Data Storage   │
        │   Workflows     │◄───────────┤   (JSON)        │
        └───────┬────────┘            └────────┬────────┘
                │                               │
    ┌───────────┼───────────┐                  │
    │           │           │                  │
┌───▼───┐  ┌───▼───┐  ┌───▼───┐         ┌────▼─────┐
│Equity │  │Notify │  │Analytics│         │Dashboard │
│Tracker│  │System │  │Engine   │         │Generator │
└───┬───┘  └───┬───┘  └───┬───┘         └────┬─────┘
    │          │          │                   │
    └──────────┴──────────┴───────────────────┘
                        │
            ┌───────────┴───────────┐
            │                       │
    ┌───────▼────────┐    ┌────────▼────────┐
    │  Notifications  │    │   Dashboards    │
    │  Discord/Twitter│    │  HTML/Charts    │
    └────────────────┘    └─────────────────┘

🔄 Data Flow Diagram

┌──────────────┐
│ PR Merged    │
│ (with bounty)│
└──────┬───────┘
       │
       ▼
┌──────────────────────┐
│ equity-tracker.yml   │
│ Workflow Triggered   │
└──────┬───────────────┘
       │
       ▼
┌──────────────────────┐
│ Check PR Labels      │
│ Extract Equity Info  │
└──────┬───────────────┘
       │
       ▼
┌──────────────────────┐
│ Update               │
│ EQUITY_TRACKING.json │
└──────┬───────────────┘
       │
       ├─────────────────┐
       │                 │
       ▼                 ▼
┌──────────────┐  ┌──────────────┐
│ Generate     │  │ Send         │
│ Dashboard    │  │ Notifications│
└──────┬───────┘  └──────┬───────┘
       │                 │
       ▼                 ▼
┌──────────────┐  ┌──────────────┐
│ Create       │  │ Discord      │
│ Charts       │  │ Twitter      │
└──────┬───────┘  │ Email        │
       │          └──────────────┘
       ▼
┌──────────────┐
│ Calculate    │
│ Analytics    │
└──────┬───────┘
       │
       ▼
┌──────────────┐
│ Commit &     │
│ Push Changes │
└──────────────┘

🗂️ File Structure & Responsibilities

Workflows (.github/workflows/)

equity-tracker.yml

Purpose: Main automation workflow
Triggers: PR merge, issue close, schedule, manual
Actions:

  • Detects bounty completions
  • Updates equity data
  • Generates dashboard
  • Creates visualizations
  • Sends notifications
  • Commits changes

Key Features:

  • Real-time processing
  • Automatic equity allocation
  • Multi-step pipeline
  • Error handling
  • Rollback capability

notifications.yml

Purpose: Notification distribution
Triggers: PR/issue events
Actions:

  • Discord webhooks
  • Twitter posts
  • Email notifications
  • Achievement badges
  • Community updates

Notification Types:

  • New bounty alerts
  • Completion celebrations
  • Achievement unlocks
  • Weekly summaries

analytics-update.yml

Purpose: Analytics generation
Triggers: Schedule (12h), manual
Actions:

  • Calculate metrics
  • Generate reports
  • Update analytics data
  • Create CSV exports

Scripts (.github/scripts/)

generate-dashboard.js

Purpose: Create live dashboard HTML
Input: EQUITY_TRACKING.json
Output: dashboard.html

Features:

  • Responsive design
  • Real-time metrics
  • Interactive charts
  • Contributor leaderboard
  • Active bounties list

Technologies:

  • Vanilla JavaScript
  • Chart.js for visualizations
  • CSS Grid/Flexbox
  • Mobile-first approach

generate-charts.js

Purpose: Create SVG visualizations
Input: EQUITY_TRACKING.json
Output: SVG files in assets/charts/

Charts Generated:

  1. equity-distribution.svg - Bar chart of contributors
  2. equity-pie-chart.svg - Pie chart of distribution
  3. equity-timeline.svg - Timeline of allocations

Features:

  • Animated SVGs
  • Responsive sizing
  • Custom color schemes
  • Accessibility support

generate-analytics.js

Purpose: Calculate comprehensive analytics
Input: EQUITY_TRACKING.json
Output: Multiple formats (JSON, MD, CSV)

Metrics Calculated:

  • Overview statistics
  • Velocity metrics (7d, 30d)
  • Distribution analysis
  • Top performers
  • Timeline data
  • Projections

Outputs:

  • analytics.json - Machine-readable
  • analytics-report.md - Human-readable
  • contributors.csv - Spreadsheet export

weekly-report.js

Purpose: Generate weekly summaries
Input: EQUITY_TRACKING.json
Output: weekly-report.md

Report Sections:

  • Weekly highlights
  • New contributors
  • Top performers
  • Active bounties
  • Equity distribution
  • Goals for next week

post-to-twitter.js

Purpose: Twitter integration
Input: Contributor data
Output: Tweet posted

Features:

  • API v2 integration
  • Rate limit handling
  • Error recovery
  • Custom formatting

💾 Data Storage

github/EQUITY_TRACKING.json

Schema:

interface EquityTracking {
  total_equity_allocated: number;
  total_equity_available: number;
  bounties_completed: number;
  bounties_pending: number;
  last_updated: string; // ISO 8601
  contributors: Contributor[];
  active_bounties: Bounty[];
}

interface Contributor {
  github_username: string;
  bounty_completed: string;
  equity_earned: number;
  bounties_completed?: number;
  completion_date: string; // YYYY-MM-DD
  pr_link: string;
  status: 'completed' | 'pending';
  contributor_tier: string;
}

interface Bounty {
  bounty_id: number;
  title: string;
  equity_offer: number;
  assigned_to: string;
  status: 'available' | 'in-progress';
  issue_link: string;
}

Update Frequency: On every PR merge
Backup Strategy: Git history provides full audit trail
Validation: JSON schema validation in workflows

github/BOUNTY_CONFIG.json

Schema:

interface BountyConfig {
  payment_token: string;
  default_chain: string;
  payout_delay_hours: number;
  min_bounty_amount: number;
  max_bounty_amount: number;
  auto_assign_in_review: boolean;
  require_approval: boolean;
  reputation_thresholds: {
    [key: string]: number;
  };
}

Purpose: Configuration for bounty system
Update Frequency: Manual updates only
Validation: Schema validation on commit

.github/analytics/

Files:

  • analytics.json - Comprehensive metrics
  • analytics-report.md - Human-readable report
  • contributors.csv - Spreadsheet export
  • weekly-report.md - Weekly summary

Update Frequency: Every 12 hours
Retention: All historical data in Git


🎨 Frontend Components

dashboard.html

Structure:

<body>
  <header>
    <h1>GitForge Equity Dashboard</h1>
    <p>Last Updated: {timestamp}</p>
  </header>
  
  <section class="stats-grid">
    <!-- 4 metric cards -->
  </section>
  
  <section class="dashboard-grid">
    <div class="leaderboard">
      <!-- Top contributors -->
    </div>
    <div class="chart">
      <!-- Pie chart -->
    </div>
  </section>
  
  <section class="bounties">
    <!-- Active bounties list -->
  </section>
</body>

CSS Architecture:

  • CSS Variables for theming
  • Mobile-first responsive design
  • Flexbox/Grid layouts
  • Smooth animations
  • Dark mode support (optional)

JavaScript:

  • Chart.js initialization
  • Dynamic data loading
  • Real-time updates
  • Interactive elements

analytics.html

Structure:

<body>
  <nav class="tabs">
    <!-- Tab navigation -->
  </nav>
  
  <section id="overview" class="tab-content">
    <!-- Overview metrics -->
  </section>
  
  <section id="contributors" class="tab-content">
    <!-- Contributor table -->
  </section>
  
  <section id="velocity" class="tab-content">
    <!-- Velocity charts -->
  </section>
  
  <section id="distribution" class="tab-content">
    <!-- Distribution analysis -->
  </section>
  
  <section id="projections" class="tab-content">
    <!-- Future projections -->
  </section>
</body>

Features:

  • Multi-tab interface
  • Advanced filtering
  • Data export
  • Print-friendly
  • Shareable URLs

🔔 Notification System

Discord Integration

Webhook Format:

{
  "embeds": [{
    "title": "🎉 Bounty Completed!",
    "description": "**{title}**",
    "color": 5814783,
    "fields": [
      {"name": "Contributor", "value": "@{username}", "inline": true},
      {"name": "Equity", "value": "{equity}%", "inline": true},
      {"name": "PR", "value": "[#{number}]({url})", "inline": true}
    ],
    "footer": {"text": "GitForge Equity Tracker"},
    "timestamp": "{iso_timestamp}"
  }]
}

Rate Limits:

  • 30 requests per minute
  • Handled by workflow delays

Twitter Integration

Tweet Format:

🎉 Bounty Completed!

Congratulations to @{username} for completing: "{title}"

Another step forward in decentralized collaboration! 🚀

#GitForge #OpenSource #Web3 #DAO

{pr_url}

API Version: Twitter API v2
Rate Limits: 50 tweets per 24h (user context)
Authentication: OAuth 1.0a

Email Integration

SMTP Configuration:

  • Server: Configurable
  • Port: 587 (TLS) or 465 (SSL)
  • Authentication: Username/Password

Email Template:

  • HTML formatted
  • Responsive design
  • Plain text fallback
  • Unsubscribe link

📊 Analytics Engine

Metrics Calculated

Overview Metrics

{
  total_contributors: number,
  total_equity_allocated: number,
  total_equity_available: number,
  bounties_completed: number,
  bounties_pending: number,
  active_bounties: number
}

Velocity Metrics

{
  last_7_days: {
    contributors: number,
    equity_allocated: number
  },
  last_30_days: {
    contributors: number,
    equity_allocated: number
  },
  daily_average: {
    contributors: string,
    equity: string
  }
}

Distribution Analysis

{
  by_tier: {
    founding: number,    // ≥5% equity
    core: number,        // 3-5% equity
    active: number,      // 1-3% equity
    emerging: number     // <1% equity
  },
  statistics: {
    average: string,
    median: string,
    max: number,
    min: number
  }
}

Projections

{
  days_to_full_allocation: number,
  estimated_contributors_at_100: number,
  growth_rate: number,
  momentum_score: number
}

Calculation Algorithms

Median Calculation:

function calculateMedian(values) {
  const sorted = [...values].sort((a, b) => a - b);
  const mid = Math.floor(sorted.length / 2);
  return sorted.length % 2 === 0
    ? (sorted[mid - 1] + sorted[mid]) / 2
    : sorted[mid];
}

Velocity Calculation:

function calculateVelocity(equityData, days) {
  const cutoffDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
  const recentContributors = equityData.contributors.filter(c => 
    new Date(c.completion_date) >= cutoffDate
  );
  return {
    contributors: recentContributors.length,
    equity: recentContributors.reduce((sum, c) => sum + c.equity_earned, 0)
  };
}

Projection Calculation:

function calculateProjections(equityData) {
  const daysSinceStart = calculateDaysSinceStart(equityData);
  const equityPerDay = equityData.total_equity_allocated / daysSinceStart;
  const daysToFull = equityData.total_equity_available / equityPerDay;
  
  return {
    days_to_full_allocation: Math.round(daysToFull),
    estimated_contributors_at_100: Math.round(100 / avgEquity)
  };
}

🔐 Security Considerations

Secrets Management

  • All sensitive data in GitHub Secrets
  • Never commit API keys or tokens
  • Rotate secrets regularly
  • Use environment-specific secrets

Workflow Permissions

permissions:
  contents: write      # For committing updates
  issues: write        # For creating comments
  pull-requests: write # For PR interactions

Principle of Least Privilege: Only grant necessary permissions

Input Validation

// Validate equity amount
if (equity < 0 || equity > 100) {
  throw new Error('Invalid equity amount');
}

// Validate JSON structure
const schema = require('./equity-schema.json');
validate(equityData, schema);

Rate Limiting

  • Discord: 30 req/min
  • Twitter: 50 tweets/24h
  • GitHub API: 5000 req/hour

Handling:

  • Exponential backoff
  • Queue management
  • Error recovery

⚡ Performance Optimization

Workflow Optimization

  • Parallel job execution where possible
  • Caching of dependencies
  • Incremental updates only
  • Conditional execution

Dashboard Performance

  • Lazy loading of charts
  • Debounced interactions
  • Optimized CSS/JS
  • Minification in production

Data Storage

  • Efficient JSON structure
  • Indexed access patterns
  • Minimal redundancy
  • Compression for large datasets

🧪 Testing Strategy

Unit Tests

// Test equity calculation
test('calculates equity correctly', () => {
  const result = calculateEquity(contributor);
  expect(result).toBe(5);
});

Integration Tests

# Test workflow
- name: Test Equity Tracker
  run: |
    # Create test PR
    # Merge with bounty label
    # Verify equity updated

End-to-End Tests

  • Create bounty
  • Submit PR
  • Merge PR
  • Verify dashboard updates
  • Check notifications sent

📈 Monitoring & Observability

Workflow Monitoring

  • GitHub Actions logs
  • Execution time tracking
  • Failure rate monitoring
  • Success/failure notifications

Data Monitoring

  • JSON validation
  • Data consistency checks
  • Anomaly detection
  • Audit trail

Dashboard Monitoring

  • Page load times
  • Error tracking
  • User analytics (optional)
  • Uptime monitoring

🔄 Maintenance & Updates

Regular Maintenance

  • Weekly: Review analytics
  • Monthly: Update dependencies
  • Quarterly: Security audit
  • Yearly: Architecture review

Update Process

  1. Test in development branch
  2. Review changes
  3. Deploy to staging
  4. Monitor for issues
  5. Deploy to production

Backup Strategy

  • Git history (full audit trail)
  • Periodic JSON exports
  • Database backups (if using external DB)
  • Configuration backups

🚀 Scalability

Current Limits

  • Contributors: Unlimited
  • Bounties: Unlimited
  • Workflows: 20 concurrent
  • Storage: GitHub repo limits

Scaling Strategies

  • Pagination for large datasets
  • Archive old data
  • External database (optional)
  • CDN for static assets

🎯 Future Enhancements

Planned Features

  • Multi-token support
  • Advanced governance
  • Mobile app
  • API endpoints
  • Blockchain integration
  • AI-powered insights

Community Requests

  • Custom metrics
  • More integrations
  • Advanced filtering
  • Export formats
  • Localization

📚 Technical References

Dependencies

  • Node.js 20+
  • Chart.js 4.4+
  • @octokit/rest 20+
  • twitter-api-v2 1.15+

APIs Used

  • GitHub REST API v3
  • Discord Webhooks
  • Twitter API v2
  • SMTP (email)

Standards Followed

  • JSON Schema validation
  • Semantic versioning
  • RESTful principles
  • OAuth 2.0 / OAuth 1.0a

This system is production-ready and battle-tested! 🚀