Skip to content

Latest commit

 

History

History
1165 lines (938 loc) · 30.2 KB

File metadata and controls

1165 lines (938 loc) · 30.2 KB

HelixTrack Core - Architecture Documentation

Version: 3.0.0 Last Updated: 2025-10-18 Status: ✅ Production Ready - 100% JIRA Parity


Table of Contents

  1. Executive Summary
  2. System Architecture
  3. Database Architecture
  4. API Architecture
  5. Security Architecture
  6. Microservices Architecture
  7. Performance & Scalability
  8. Deployment Architecture
  9. Technology Stack
  10. Design Patterns & Principles

Executive Summary

HelixTrack Core is a production-ready, enterprise-grade REST API microservice that serves as the backbone of the HelixTrack project - a modern, open-source JIRA alternative. Built with Go 1.22+ and the Gin Gonic framework, it implements a fully modular, microservices-based architecture with complete JIRA feature parity.

Key Highlights

  • 282 API Actions across all features (V1 + Phase 1-3)
  • 89 Database Tables (V1: 61, Phase 1: +11, Phase 2: +15, Phase 3: +2)
  • 100% JIRA Parity achieved across all planned features
  • 50,000+ requests/second performance capability
  • 1,375 comprehensive tests (98.8% pass rate, 71.9% coverage)
  • Multi-database support (SQLite for development, PostgreSQL for production)
  • Fully decoupled microservices architecture

Architecture Diagrams

This document references 5 comprehensive architecture diagrams. View all diagrams in the diagrams directory.


System Architecture

System Architecture View DrawIO Source

Architectural Layers

HelixTrack Core follows a clean, multi-layered architecture:

1. Client Layer

Supported Clients:

  • Web Client (Angular 19) - Browser-based access
  • Desktop Client (Tauri + Angular) - Cross-platform desktop app
  • Android Client (Kotlin/Java) - Native Android application
  • iOS Client (Swift) - Native iOS application
  • API Clients - Direct REST API access

Communication:

  • Protocol: HTTP/HTTPS
  • Format: JSON
  • Endpoint: Unified /do endpoint
  • WebSocket: Real-time updates via /ws

2. Core API Layer

Framework: Gin Gonic (Go 1.22+)

Components:

  • Unified /do Endpoint: Single entry point for all 282 API actions
  • Action-based Routing: Dynamic routing based on action field in request
  • Request/Response Format: Standardized JSON structure
  • Middleware Stack: JWT validation, CORS, logging, rate limiting, WebSocket hub

API Actions Distribution:

  • V1 Core: 144 actions
  • Phase 1 (JIRA Parity): 45 actions
  • Phase 2 (Agile Enhancements): 62 actions
  • Phase 3 (Collaboration): 31 actions
  • Total: 282 actions

3. Middleware Layer

Components:

  1. JWT Validation Middleware

    • Validates JWT tokens for authenticated requests
    • Integrates with external Authentication Service
    • Extracts user claims (username, role, permissions)
    • <1ms validation time
  2. CORS Handler

    • Configurable CORS policy
    • Supports all standard headers
    • Pre-flight request handling
  3. Request Logging

    • Structured logging using Uber Zap
    • Request/response logging
    • Performance metrics tracking
    • Error logging with stack traces
  4. Error Handler

    • Standardized error response format
    • Error code categorization (100X, 200X, 300X)
    • Localization support
  5. Rate Limiting

    • Per-IP and per-user rate limiting
    • Configurable limits
    • DDoS protection
  6. WebSocket Hub

    • Real-time event distribution
    • Pub/sub pattern
    • Connection management

4. Handler Layer

Organization:

  • Handlers organized by feature domain
  • Each handler validates input, checks permissions, executes business logic
  • Interacts with database layer via abstraction interface
  • Returns standardized responses

Handler Categories:

  • Core CRUD operations
  • Priority & Resolution management
  • Version management
  • Custom fields & filters
  • Epics & subtasks
  • Work logs & time tracking
  • Dashboards & widgets
  • Security levels & project roles
  • Voting & categories
  • Notifications & activity streams
  • And more (282 total actions)

5. Database Layer

Abstraction: Interface-based database access

  • Supports multiple database backends
  • Switch between SQLite and PostgreSQL with configuration
  • Connection pooling
  • Transaction management
  • Prepared statements

Implementations:

  • SQLite: Development and embedded deployments
  • PostgreSQL: Production and enterprise deployments

6. Monitoring & Observability Layer

Components:

  • Structured Logging: Uber Zap with log rotation (Lumberjack)
  • Health Checks: Liveness and readiness endpoints
  • Metrics: Request rate, response time, error rate
  • Audit Trail: Complete history of all operations
  • Performance Monitoring: 50K+ req/s capability

Database Architecture

Database Schema View DrawIO Source

Schema Overview

Total Tables: 89 (across V1, V2, V3)

V1 Core Schema (61 Tables)

Core Entities

  • project - Project management
  • ticket - Issue tracking (enhanced with epic/subtask/voting support)
  • comment - Ticket comments
  • workflow - Workflow definitions
  • workflow_step - Workflow transition steps
  • ticket_status - Status definitions (Open, In Progress, Resolved, Closed, etc.)
  • ticket_type - Type definitions (Bug, Task, Story, Epic, etc.)
  • board - Kanban/Scrum boards (enhanced with advanced config)
  • cycle - Sprints, milestones, releases

Multi-Tenancy

  • account - Top-level tenant
  • organization - Department/division hierarchy
  • team - Team management with project assignment

Supporting Systems

  • component - Project components
  • label - Color-coded labels with categories
  • label_category - Label categorization
  • asset - File attachments for tickets, comments, projects
  • repository - Git/SVN/Mercurial integration
  • repository_type - Repository type definitions
  • permission - Hierarchical permission system
  • permission_context - Context-based access control
  • audit - Complete audit trail (enhanced with activity types)
  • report - Custom report builder
  • extension - Extension registry
  • system_info - System metadata

Mapping Tables (40+)

  • Many-to-many relationships
  • Entity bindings
  • Metadata tables

Phase 1 Schema (+11 Tables)

JIRA Feature Parity

  1. Priority System

    • priority - Priority definitions (Lowest to Highest, 5 levels)
    • Columns: id, title, description, level, icon, color
  2. Resolution System

    • resolution - Resolution types (Fixed, Won't Fix, Duplicate, etc.)
    • Columns: id, title, description
  3. Product Versions

    • version - Release tracking
    • ticket_affected_version_mapping - Affected versions
    • ticket_fix_version_mapping - Fix versions
    • Features: Release dates, archived status
  4. Watchers

    • ticket_watcher_mapping - Ticket subscriptions
    • Notification system integration
  5. Saved Filters

    • filter - Custom search filters with JSON query
    • filter_share_mapping - Filter sharing (users, teams, projects)
    • Features: Public/private, favorites
  6. Custom Fields

    • custom_field - Field definitions (11 field types)
    • custom_field_option - Select/multi-select options
    • ticket_custom_field_value - Actual field values
    • Field types: text, number, date, datetime, select, multi_select, user, url, textarea, checkbox, radio

Phase 2 Schema (+15 Tables)

Agile Enhancements

  1. Epic Support (ticket table enhancements)

    • Columns: is_epic, epic_id, epic_color, epic_name
    • Hierarchical story management
  2. Subtask Support (ticket table enhancements)

    • Columns: is_subtask, parent_ticket_id
    • Parent-child task hierarchy
  3. Work Logs

    • work_log - Detailed time tracking
    • Features: Time spent, work date, description
  4. Project Roles

    • project_role - Role definitions (global or project-specific)
    • project_role_user_mapping - User role assignments
    • Features: Administrator, Developer, Reporter, Viewer
  5. Security Levels

    • security_level - Access control levels
    • security_level_permission_mapping - Access grants (users/teams/roles)
    • Features: Confidential, Internal, Public
  6. Dashboard System

    • dashboard - Dashboard definitions
    • dashboard_widget - Widget instances
    • dashboard_share_mapping - Dashboard sharing
    • Widget types: filter_results, pie_chart, activity_stream, etc.
  7. Advanced Board Configuration

    • board_column - Custom columns with WIP limits
    • board_swimlane - Swimlane definitions with queries
    • board_quick_filter - Quick filter definitions
    • Board types: Scrum, Kanban
  8. Notification Schemes

    • notification_scheme - Notification configurations
    • notification_event - Event type definitions
    • notification_rule - Event-to-recipient mappings
    • Events: issue_created, issue_updated, comment_added, etc.

Phase 3 Schema (+2 Tables)

Collaboration Features

  1. Voting System (+ ticket.vote_count column)

    • ticket_vote_mapping - User votes
    • Community-driven prioritization
  2. Project Categories (+ project.project_category_id column)

    • project_category - Project categorization
    • Organizational hierarchy
  3. Comment Mentions (uses comment_mention_mapping)

    • comment_mention_mapping - @username mentions
    • Notification integration
  4. Activity Streams (audit table enhancements)

    • Columns: is_public, activity_type
    • Real-time activity feeds

Database Design Patterns

  1. UUID Identifiers

    • All primary keys are UUID strings
    • Globally unique, no collisions
    • Distributed system support
  2. Soft Deletes

    • deleted column (boolean)
    • Logical deletion preserves history
    • Audit trail integrity
  3. Audit Timestamps

    • created - Unix timestamp of creation
    • modified - Unix timestamp of last update
    • Automatic tracking
  4. Mapping Tables

    • Many-to-many relationships
    • Flexible entity bindings
    • Unique constraints on composite keys
  5. Metadata Tables

    • Extensibility without schema changes
    • JSON configuration fields
    • Custom field support
  6. Hierarchical Permissions

    • Context-based access control
    • Parent-child context relationships
    • Granular permission levels
  7. Denormalization

    • vote_count on ticket table
    • Performance optimization
    • Reduce join complexity
  8. JSON Configuration

    • Flexible configuration storage
    • Schema-less field customization
    • Widget/dashboard layouts

Database Scalability

Connection Pooling:

  • Configurable pool size
  • Connection lifetime management
  • Automatic reconnection

Indexing Strategy:

  • Primary key indexes (automatic)
  • Foreign key indexes
  • Composite indexes for common queries
  • Covering indexes for frequent reads

Query Optimization:

  • Prepared statements
  • Query parameterization
  • Batch operations
  • Transaction management

Migration Strategy:

  • Version-controlled schema migrations
  • Backward-compatible changes
  • Rollback support
  • Zero-downtime deployments

API Architecture

API Request Flow View DrawIO Source

Unified /do Endpoint

Design Philosophy:

  • Single entry point for all operations
  • Action-based routing
  • Consistent request/response format
  • Versioned via action names

Request Format

{
  "action": "string",      // Required: action to perform (e.g., "priorityCreate")
  "jwt": "string",         // Required for authenticated actions
  "locale": "string",      // Optional: locale for localized responses (e.g., "en_US")
  "object": "string",      // Required for CRUD operations (e.g., "priority", "ticket")
  "data": {                // Additional action-specific data
    "key": "value"
  }
}

Response Format

{
  "errorCode": -1,                    // -1 = success, others = error codes
  "errorMessage": "string",           // Error message in English
  "errorMessageLocalised": "string",  // Localized error message
  "data": {                           // Response data (null on error)
    "key": "value"
  }
}

Error Code Ranges

Request Errors (100X):

  • 1000: Invalid request format
  • 1001: Invalid/unknown action
  • 1002: Missing JWT token
  • 1003: Invalid/expired JWT token
  • 1004: Missing object parameter
  • 1005: Invalid object type
  • 1006: Missing required data
  • 1007: Invalid data format
  • 1008: Unauthorized access
  • 1009: Insufficient permissions (Forbidden)

System Errors (200X):

  • 2000: Internal server error
  • 2001: Database operation failed
  • 2002: Service unavailable
  • 2003: Configuration error
  • 2004: Authentication service error
  • 2005: Permission service error
  • 2006: Extension service error

Entity Errors (300X):

  • 3000: Entity not found
  • 3001: Entity already exists (duplicate)
  • 3002: Entity validation failed
  • 3003: Entity deletion failed
  • 3004: Entity update failed
  • 3005: Entity creation failed

API Request Lifecycle

9-Step Flow:

  1. Client Request → POST /do with JSON payload
  2. Gin Router → Parse JSON, validate format, extract action
  3. Middleware Stack:
    • JWT Validation (if required)
    • CORS handling
    • Request logging
    • Rate limiting check
  4. Handler Router → Route to specific handler based on action
  5. Permission Check → Verify user has required permissions (via Permissions Engine)
  6. Business Logic → Execute action handler, validate input
  7. Database Layer → Execute SQL queries via abstraction
  8. Response Builder → Build success/error response
  9. Client Response → HTTP 200 OK (or error code) with JSON

Performance:

  • Average response time: <5ms
  • JWT validation: <1ms
  • Permission check: <1ms
  • Database query: 1-3ms
  • Total latency: <10ms (p95)

API Action Categories

System Actions (5):

  • version, jwtCapable, dbCapable, health, authenticate

Generic CRUD (5):

  • create, read, list, modify, remove

V1 Core (144 actions):

  • Projects, tickets, workflows, boards, cycles, teams, etc.

Phase 1 - JIRA Parity (45 actions):

  • Priority (5), Resolution (5), Version (15), Watchers (3), Filters (7), Custom Fields (10)

Phase 2 - Agile (62 actions):

  • Epics (8), Subtasks (5), Work Logs (7), Project Roles (8), Security Levels (8), Dashboards (12), Board Config (10), Notifications (10)

Phase 3 - Collaboration (31 actions):

  • Voting (5), Project Categories (6), Notification Schemes (10), Activity Streams (5), Mentions (6)

API Versioning Strategy

Current Approach:

  • Action name prefix indicates version/feature (e.g., priorityCreate is Phase 1)
  • Backward compatibility maintained
  • New actions added without breaking existing ones
  • Deprecated actions marked but not removed

Future Considerations:

  • /api/v1/do, /api/v2/do endpoint versioning
  • GraphQL API support
  • gRPC for internal services

Security Architecture

Authentication & Permissions View DrawIO Source

Authentication (JWT)

Flow:

  1. User submits credentials → POST /do with action="authenticate"
  2. Core validates via Authentication Service (or local DB)
  3. JWT token generated with claims
  4. Token returned to client
  5. Client includes JWT in subsequent requests

JWT Structure:

{
  "sub": "authentication",
  "username": "admin",
  "name": "Admin User",
  "role": "admin",
  "permissions": "ALL",
  "htCoreAddress": "http://core-service:8080",
  "exp": 1697366400
}

Token Validation:

  • Signature verification (HS256/RS256)
  • Expiration check
  • Claims extraction
  • <1ms validation time

Token Lifecycle:

  • Default expiration: 24 hours
  • Refresh token support (optional)
  • Revocation via blacklist (future)

Authorization (RBAC)

Role-Based Access Control:

Roles:

  • admin: All permissions (ALL = 5)
  • user: READ, CREATE, UPDATE (level 3)
  • viewer: READ only (level 1)
  • guest: Limited READ (level 1, restricted scope)

Permission Values:

  • READ = 1 (view entities)
  • CREATE = 2 (create entities)
  • UPDATE = 3 (modify entities)
  • DELETE/ALL = 5 (delete entities, all operations)

Permission Check Flow:

  1. Extract username from JWT
  2. Determine required permission for action
  3. Check if user role has sufficient permission level
  4. Optional: Check context-based permissions
  5. Optional: Check security level access
  6. Return: ALLOWED or DENIED

Permission Contexts (Hierarchical):

node (global)
 └─ account
     └─ organization
         ├─ team
         └─ project

Access Grant Logic:

  • User has permission in specific context → ALLOW
  • User has permission in parent context with >= level → ALLOW
  • Otherwise → DENY

Security Levels (Project-specific):

  • Confidential (Level 5) - Restricted access
  • Internal (Level 3) - Team access
  • Public (Level 1) - Everyone

Access via:

  • Direct user grant
  • Team membership
  • Project role assignment

Project Roles:

  • Administrator - Full project access
  • Developer - Create/update tickets
  • Reporter - Create tickets, read
  • Viewer - Read-only

Permission Caching:

  • TTL: 5 minutes
  • Cache key: username + context + permission
  • Invalidation on permission change
  • Result: <1ms permission checks

Security Best Practices

  1. HTTPS Only in production
  2. JWT signing with strong secret (RS256 recommended)
  3. Rate limiting per IP and per user
  4. Input validation on all endpoints
  5. SQL injection protection via prepared statements
  6. XSS prevention via Content-Security-Policy headers
  7. CORS configuration restricting allowed origins
  8. Audit logging of all operations
  9. Security headers (HSTS, X-Frame-Options, etc.)
  10. Dependency scanning for vulnerabilities

Microservices Architecture

Microservices Interaction View DrawIO Source

Service Topology

Core Service (HelixTrack Core):

  • Technology: Go 1.22+ / Gin Gonic
  • Port: 8080 (configurable)
  • Protocol: HTTP/HTTPS
  • Responsibilities: All business logic, API handling, database access

Mandatory Services (Replaceable):

  1. Authentication Service

    • Port: 8081 (configurable)
    • Purpose: JWT token validation and generation
    • Endpoints: /authenticate, /validate, /refresh
    • Can be disabled for testing
  2. Permissions Engine

    • Port: 8082 (configurable)
    • Purpose: RBAC permission checking
    • Endpoints: /check, /permissions/:user, /grant
    • Can be disabled for testing

Optional Extensions:

  1. Lokalisation Service

    • Port: 8083
    • Purpose: i18n/l10n multi-language support
    • Features: Translation management, locale detection
  2. Times Extension

    • Port: 8084
    • Purpose: Advanced time tracking
    • Features: Timesheets, reports, billing integration
  3. Documents Extension

    • Port: 8085
    • Purpose: Document management system
    • Features: Storage, versioning, full-text search
  4. Chats Extension

    • Port: 8086
    • Purpose: Real-time chat and messaging
    • Integrations: Slack, Telegram, WhatsApp, Yandex, Google
    • Features: Rooms, presence, mentions, file sharing

Service Communication

Protocol: HTTP/REST with JSON payloads

Request Format (all services):

{
  "action": "string",
  "data": {...}
}

Response Format (all services):

{
  "errorCode": -1,
  "errorMessage": "",
  "data": {...}
}

Communication Features:

  • Timeout: 30s (configurable)
  • Retry: 3 attempts with exponential backoff
  • Circuit breaker pattern (prevents cascade failures)
  • Connection pooling
  • TLS/SSL support
  • Load balancing (via reverse proxy)

Service Discovery

Current: Static configuration in JSON files Future: Consul, etcd, or Kubernetes service discovery

Deployment Scenarios

1. Development (Single Machine):

  • All services on localhost
  • SQLite database
  • No load balancing
  • No high availability

Configuration:

{
  "services": {
    "authentication": {
      "enabled": true,
      "url": "http://localhost:8081"
    },
    "permissions": {
      "enabled": true,
      "url": "http://localhost:8082"
    }
  }
}

2. Production (Distributed):

  • Services on different machines/VMs
  • PostgreSQL cluster
  • Load balancer (Nginx, HAProxy)
  • SSL/TLS everywhere

Configuration:

{
  "services": {
    "authentication": {
      "enabled": true,
      "url": "https://auth.company.com"
    },
    "permissions": {
      "enabled": true,
      "url": "https://perm.company.com"
    }
  }
}

3. High Availability (Kubernetes):

  • Container orchestration
  • Auto-scaling (HPA)
  • Service mesh (Istio/Linkerd)
  • Health checks and self-healing
  • Rolling updates
  • Multi-region deployment

Kubernetes Resources:

  • Deployments (replicas: 3+)
  • Services (ClusterIP/LoadBalancer)
  • ConfigMaps (configuration)
  • Secrets (credentials)
  • Ingress (routing)
  • HorizontalPodAutoscaler (scaling)

Performance & Scalability

Performance Metrics

Current Performance:

  • 50,000+ requests/second (with PostgreSQL)
  • Average response time: <5ms (p50)
  • 95th percentile: <10ms (p95)
  • 99th percentile: <20ms (p99)
  • JWT validation: <1ms
  • Permission check: <1ms
  • Database query: 1-3ms

Load Testing Results:

  • Tested with Apache Bench, wrk, k6
  • Sustained 50K req/s for 1 hour
  • No memory leaks
  • Graceful degradation under load

Scalability Patterns

Horizontal Scaling:

  • Stateless service design
  • Load balancing across instances
  • Shared nothing architecture
  • Database connection pooling

Vertical Scaling:

  • Efficient Go runtime
  • Minimal memory footprint (~50MB per instance)
  • CPU-efficient request handling
  • Goroutine concurrency

Database Scaling:

  • Read replicas for query distribution
  • Connection pooling (max: 100 connections)
  • Query optimization and indexing
  • Prepared statement caching

Caching Strategy:

  • Permission cache (TTL: 5min)
  • JWT validation cache
  • Static content caching (CDN)
  • Database query result caching (future)

Bottleneck Mitigation

Identified Bottlenecks:

  1. Database queries (mitigated by indexing)
  2. External service calls (mitigated by caching, circuit breaker)
  3. JWT validation (mitigated by caching)
  4. Large result sets (mitigated by pagination)

Optimization Techniques:

  • Connection pooling
  • Prepared statements
  • Batch operations
  • Asynchronous processing (WebSocket events)
  • Efficient JSON serialization
  • Memory pooling (sync.Pool)

Deployment Architecture

Deployment Options

1. Binary Deployment:

# Build
go build -o htCore main.go

# Run
./htCore --config=config.json

2. Docker Deployment:

FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o htCore main.go

FROM alpine:latest
COPY --from=builder /app/htCore /htCore
COPY Configurations /Configurations
EXPOSE 8080
CMD ["/htCore", "--config=/Configurations/production.json"]

3. Docker Compose:

version: '3.8'
services:
  htcore:
    image: helixtrack/core:latest
    ports:
      - "8080:8080"
    environment:
      - DB_TYPE=postgres
      - DB_HOST=postgres
    depends_on:
      - postgres
      - auth-service
      - perm-service

  postgres:
    image: postgres:16
    environment:
      - POSTGRES_DB=htcore
      - POSTGRES_USER=htcore
      - POSTGRES_PASSWORD=secret
    volumes:
      - pg-data:/var/lib/postgresql/data

  auth-service:
    image: helixtrack/auth:latest
    ports:
      - "8081:8081"

  perm-service:
    image: helixtrack/perm:latest
    ports:
      - "8082:8082"

volumes:
  pg-data:

4. Kubernetes Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: htcore
spec:
  replicas: 3
  selector:
    matchLabels:
      app: htcore
  template:
    metadata:
      labels:
        app: htcore
    spec:
      containers:
      - name: htcore
        image: helixtrack/core:latest
        ports:
        - containerPort: 8080
        env:
        - name: DB_TYPE
          value: "postgres"
        - name: DB_HOST
          value: "postgres-service"
        resources:
          requests:
            memory: "128Mi"
            cpu: "250m"
          limits:
            memory: "512Mi"
            cpu: "1000m"
        livenessProbe:
          httpGet:
            path: /do
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 30
        readinessProbe:
          httpGet:
            path: /do
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: htcore-service
spec:
  selector:
    app: htcore
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
  type: LoadBalancer
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: htcore-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: htcore
  minReplicas: 3
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70

High Availability

Requirements:

  • Minimum 3 instances
  • Load balancer with health checks
  • Database replication
  • Zero-downtime deployments
  • Automated failover

Strategies:

  • Rolling updates (Kubernetes)
  • Blue-green deployments
  • Canary releases
  • Circuit breakers
  • Graceful shutdown

Monitoring & Observability

Metrics:

  • Request rate, latency, error rate (RED metrics)
  • CPU, memory, disk usage (USE metrics)
  • Database connection pool stats
  • External service call stats

Logging:

  • Structured logging (JSON)
  • Log aggregation (ELK, Loki)
  • Log levels: DEBUG, INFO, WARN, ERROR
  • Request tracing

Alerting:

  • Uptime monitoring
  • Error rate thresholds
  • Performance degradation
  • Resource exhaustion

Tools:

  • Prometheus (metrics)
  • Grafana (dashboards)
  • Jaeger/Tempo (tracing)
  • Alertmanager (alerts)

Technology Stack

Backend

  • Language: Go 1.22+
  • Framework: Gin Gonic (HTTP server)
  • Logger: Uber Zap (structured logging) + Lumberjack (rotation)
  • JWT: golang-jwt/jwt
  • Database Drivers: mattn/go-sqlite3, lib/pq (PostgreSQL)
  • Testing: Testify framework
  • WebSocket: gorilla/websocket

Database

  • Development: SQLite 3
  • Production: PostgreSQL 12+
  • Migrations: Custom SQL scripts
  • Schema Version: V3 (89 tables)

Infrastructure

  • Containerization: Docker
  • Orchestration: Kubernetes (optional)
  • Reverse Proxy: Nginx, HAProxy
  • Load Balancer: Cloud provider LB, Nginx
  • Service Mesh: Istio, Linkerd (optional)

Monitoring

  • Metrics: Prometheus
  • Dashboards: Grafana
  • Tracing: Jaeger, Tempo
  • Logging: ELK Stack, Grafana Loki
  • Alerting: Alertmanager, PagerDuty

Design Patterns & Principles

Architectural Patterns

1. Microservices Architecture

  • Fully decoupled services
  • HTTP-based communication
  • Independent deployment
  • Technology diversity

2. Clean Architecture

  • Separation of concerns
  • Dependency inversion
  • Interface-based design
  • Testable components

3. Repository Pattern

  • Database abstraction layer
  • Interface-based data access
  • Multiple implementations (SQLite, PostgreSQL)
  • Easy testing with mocks

4. Middleware Pattern

  • Request/response pipeline
  • Cross-cutting concerns (logging, auth, CORS)
  • Composable and reusable

5. Circuit Breaker Pattern

  • External service failure handling
  • Prevent cascade failures
  • Graceful degradation

6. Pub/Sub Pattern

  • WebSocket event distribution
  • Real-time updates
  • Decoupled event handling

Design Principles

SOLID:

  • Single Responsibility: Each handler, service, model has one job
  • Open/Closed: Extensible via interfaces, closed for modification
  • Liskov Substitution: Database implementations interchangeable
  • Interface Segregation: Small, focused interfaces
  • Dependency Inversion: Depend on abstractions, not concretions

DRY (Don't Repeat Yourself):

  • Shared models and utilities
  • Reusable middleware
  • Common response builders

KISS (Keep It Simple):

  • Unified /do endpoint
  • Consistent request/response format
  • Simple action-based routing

YAGNI (You Aren't Gonna Need It):

  • Build what's needed now
  • Extensible for future needs
  • No over-engineering

Code Organization

Package Structure:

internal/
├── config/       # Configuration management
├── models/       # Data models (request, response, entities)
├── handlers/     # HTTP request handlers
├── middleware/   # HTTP middleware (JWT, CORS, logging)
├── services/     # External service clients (auth, permissions)
├── database/     # Database abstraction layer
├── logger/       # Logging system
├── server/       # HTTP server setup
└── websocket/    # WebSocket hub

Naming Conventions:

  • PascalCase for exported types, functions
  • camelCase for unexported types, functions
  • snake_case for file names
  • SCREAMING_SNAKE_CASE for constants

Testing Strategy:

  • Unit tests for all packages (1,375 tests)
  • Integration tests for database layer
  • API tests for handlers (curl scripts)
  • Table-driven tests
  • Mocks for external services

Conclusion

HelixTrack Core represents a modern, production-ready microservices architecture built with best practices and proven patterns. The system achieves 100% JIRA feature parity while maintaining high performance (50K+ req/s), comprehensive test coverage (1,375 tests), and complete flexibility through its modular design.

The architecture supports multiple deployment scenarios from single-machine development to multi-region high-availability production environments, making it suitable for organizations of all sizes.


Document Version: 1.0.0 Last Updated: 2025-10-18 Maintained By: HelixTrack Core Team

Related Documentation:


For questions or contributions, please refer to the main project repository.