Skip to main content

Sparki API System Requirements Specification

:::info readme This document outlines the System Requirements Specification (SRS) for the Sparki API, the core backend service that powers framework detection, pipeline management, deployment orchestration, and CI/CD automation for the Sparki platform. It defines the functional and non-functional requirements necessary to meet developer needs and business objectives. As the primary interface between CLI clients, terminal UI, and backend services, the Sparki API is designed to be ultra-high performance, intelligent, and developer-friendly. This SRS serves as a foundational reference for architects, developers, and quality assurance personnel involved in the design, implementation, and maintenance of the API. ::: :::success takeaways Key takeaways of this document include:
  • Understanding core API functionalities for framework detection and pipeline management
  • Comprehending the system architecture and Go Fiber-based technology stack
  • Identifying functional requirements for CI/CD operations and deployment automation
  • Recognizing non-functional requirements for performance, scalability, and reliability
  • Establishing traceability between business requirements and API specifications
  • Facilitating communication among cross-functional teams
::: Version: 1.0
Date: December 3, 2025
Repository: sparki-api
Service Type: Core Backend API (Go Fiber)
Framework: Fiber v2 with high-performance async runtime

1. Introduction

1.1 Purpose

This document communicates the user needs and technical requirements of the Sparki API to all stakeholders, providing a comprehensive overview of expected system functions and capabilities. It identifies functional requirements, constraints, assumptions, and enables development of user stories and use cases.

1.2 Concepts

The operational concepts and support strategies in this document are based on:
  1. Developer expected use of the system (from CLI, TUI, and external integrations)
  2. Functionality and performance for normal operation with 1M+ concurrent developers
  3. Robustness requirements for production workload support
  4. Operational boundaries and practical deployment constraints
  5. Technical architecture decisions and performance targets

1.3 Scope

The Sparki API is a Fiber-based RESTful service with WebSocket support that provides:
  • Project framework autodetection and analysis
  • CI/CD pipeline generation and management
  • Pipeline execution orchestration
  • Build, test, and lint automation
  • Deployment workflow management
  • Real-time pipeline status and logs
  • User workspace and team management
  • Third-party cloud platform integration
  • Metrics, telemetry, and observability

1.4 Definitions

PropertyValue
ProjectGit repository with detected framework/language
WorkspaceTeam’s organizational container
PipelineCI/CD workflow (build, test, deploy steps)
BuildSingle pipeline execution instance
FrameworkDetected development framework (Django, Next.js)
AdapterFramework-specific handler plugin
DeploymentRelease of code to cloud platform
WebSocket SessionReal-time connection for streaming logs/status

1.5 Document Conventions

  • SHALL: Mandatory requirement
  • SHOULD: Recommended requirement
  • MAY: Optional requirement
  • WILL: External dependency or future intention

2. System Overview

2.1 System Context

The Sparki API serves as the orchestration layer between CLI/TUI clients and backend services, implementing intelligent CI/CD automation with framework-aware pipeline generation and deployment management. It coordinates:
  • Project Analysis: Framework detection with AST analysis and dependency scanning
  • Pipeline Generation: Intelligent CI/CD pipeline synthesis for detected frameworks
  • Build Orchestration: Container-based build execution with real-time streaming
  • Test Automation: Framework-agnostic test discovery and execution
  • Deployment Management: Multi-stage deployment orchestration via Loco engine
  • Real-Time Communication: WebSocket streaming of logs, status, and metrics
  • User Management: Workspace, team, and permission management
  • Cloud Integration: Railway, Render, Fly.io, Vercel native API integration
  • Observability: Structured logging, Prometheus metrics, distributed tracing
  • Security: JWT token validation, RBAC, audit logging

2.2 System Objectives

  1. Sub-50ms API Response Times: 95th percentile response <50ms through Fiber optimization and caching
  2. Instant Framework Detection: <2 seconds project analysis with high accuracy (>99%)
  3. Universal Framework Support: Support 50+ languages/frameworks with intelligent detection
  4. Massive Scalability: Support 1M+ developers with 100K+ concurrent pipeline executions
  5. Real-Time Observability: <100ms log streaming and status updates via WebSocket
  6. Zero Configuration: Generate working pipelines without user input for 95%+ of projects
  7. Intelligent Adaptability: Learn from framework patterns and customize pipelines
  8. High Availability: 99.95% uptime SLA with graceful degradation
  9. Developer Experience: Intuitive REST API matching developer expectations
  10. Extensibility: Plugin system for custom framework adapters and build strategies

3. Functional Requirements

3.1 Project Detection & Analysis

REQ-API-DETECT-001: Framework Auto-Detection

PropertyValue
IDREQ-API-DETECT-001
RequirementThe API SHALL support automatic framework detection via POST /api/v1/projects/analyze endpoint analyzing git repository and generating framework report.
RationaleZero-configuration onboarding requires accurate framework detection without user input. Enables core Sparki value proposition.
Inputs{git_url, branch, commit_hash} or local path
OutputsFramework detection report with confidence scores and recommended pipeline template
Verify MethodTest
Acceptance Criteria:
  • Detect 50+ frameworks with >99% accuracy
  • Analysis completes in <2 seconds
  • Return confidence scores for detected frameworks
  • Identify primary language
  • Report dependency tree and versions
  • Suggest 3+ pipeline templates
Implementation Details:
Analysis Pipeline:
1. Clone/fetch repository (max 100MB)
2. Scan directory structure and file signatures
3. Parse dependency files (package.json, go.mod, requirements.txt, etc.)
4. AST analysis for language-specific patterns
5. Heuristic detection for framework markers
6. Return ranked framework candidates with confidence
Supported Frameworks by Language:
  • Python: Django, FastAPI, Flask, Pyramid, Tornado
  • Node.js: Express, Next.js, Remix, Nuxt, NestJS, Svelte
  • Go: Gin, Echo, Fiber, GORM, Beego
  • Rust: Axum, Actix-Web, Rocket, Yew
  • Java: Spring Boot, Quarkus, Micronaut, Dropwizard
  • .NET: ASP.NET Core, Minimal APIs, Entity Framework
  • Ruby: Rails, Sinatra, Hanami, Roda
  • PHP: Laravel, Symfony, Slim, Zend

REQ-API-DETECT-002: Dependency Analysis

PropertyValue
IDREQ-API-DETECT-002
RequirementThe API SHALL parse and analyze project dependencies, versions, and transitive dependencies for security and compatibility verification.
RationaleUnderstand project dependencies enables intelligent build strategy selection and vulnerability scanning recommendations.
InputsProject path, dependency files (package.json, go.mod, requirements.txt, pom.xml, Cargo.toml)
OutputsDependency graph with versions, security alerts, and compatibility warnings
Verify MethodTest
Acceptance Criteria:
  • Parse all major dependency manifests
  • Build transitive dependency graph
  • Identify security vulnerabilities
  • Report version conflicts
  • Suggest dependency updates

REQ-API-DETECT-003: Build System Detection

PropertyValue
IDREQ-API-DETECT-003
RequirementThe API SHALL auto-detect project build systems and provide appropriate build commands for pipeline generation.
RationaleIntelligent build orchestration requires understanding project build tooling to generate correct build steps.
InputsProject root directory and framework context
OutputsDetected build system with recommended build commands and configuration
Verify MethodTest
Acceptance Criteria:
  • Detect all major build systems (npm, yarn, cargo, go build, maven, etc.)
  • Identify build config files
  • Suggest build commands
  • Report build parallelization options

3.2 Pipeline Management

REQ-API-PIPELINE-001: Intelligent Pipeline Generation

PropertyValue
IDREQ-API-PIPELINE-001
RequirementThe API SHALL generate production-grade CI/CD pipelines via POST /api/v1/pipelines based on framework detection with zero user configuration.
RationaleAutomatic pipeline generation is core Sparki value proposition—eliminates YAML configuration complexity.
InputsProject ID, framework context from detection analysis
OutputsComplete CI/CD pipeline with build, test, lint, and deployment stages
Verify MethodTest + Demonstration
Acceptance Criteria:
  • Generate complete pipeline for 95%+ of detected projects
  • Pipeline should pass build tests without modification
  • Include linting, testing, security checks
  • Support multi-stage builds
  • Enable parallel job execution
Default Pipeline Stages:
1. Build
   - Install dependencies
   - Compile/build artifacts
   - Cache layer optimization

2. Test
   - Run unit tests
   - Run integration tests
   - Generate coverage reports

3. Lint & Security
   - Code linting (ESLint, Pylint, etc.)
   - Security scanning (SAST)
   - Dependency vulnerability scan

4. Deploy (optional)
   - Pre-deployment validation
   - Staged deployment strategy
   - Health checks and monitoring

REQ-API-PIPELINE-002: Pipeline Customization & Override

PropertyValue
IDREQ-API-PIPELINE-002
RequirementThe API SHALL support pipeline customization via YAML configuration file (.sparki.yml) while maintaining zero-configuration default behavior.
RationaleTeams need customization flexibility for complex workflows while maintaining Sparki’s zero-configuration promise.
Inputs.sparki.yml configuration file in project root
OutputsMerged pipeline combining auto-generated and custom configuration
Verify MethodTest
Acceptance Criteria:
  • Parse and validate YAML configuration
  • Merge custom config with auto-generated pipeline
  • Support stage overrides and additions
  • Enable conditional steps based on branch/tag
Example .sparki.yml:
version: 1
pipelines:
    main:
        stages:
            build:
                commands:
                    - npm install
                    - npm run build:prod
            test:
                commands:
                    - npm test -- --coverage
            deploy:
                stages:
                    - staging
                    - production
                requires_approval: true

REQ-API-PIPELINE-003: Multi-Pipeline Management

PropertyValue
IDREQ-API-PIPELINE-003
RequirementThe API SHALL support multiple named pipelines per project via POST /api/v1/pipelines/{name}/execute for different workflows.
RationaleComplex projects need separate pipelines for different branches, purposes (nightly builds, release builds, etc.).
InputsPipeline name, trigger parameters
OutputsPipeline execution instance
Verify MethodTest
Acceptance Criteria:
  • Support naming multiple pipelines per project
  • Enable branch-specific pipeline routing
  • Support scheduled/manual triggers
  • Manage pipeline versioning

3.3 Pipeline Execution & Orchestration

REQ-API-EXEC-001: Build Execution

PropertyValue
IDREQ-API-EXEC-001
RequirementThe API SHALL orchestrate build execution via POST /api/v1/builds with container isolation and real-time log streaming.
RationaleContainer-based builds provide isolation, repeatability, and security essential for production CI/CD.
InputsPipeline definition, git commit reference, environment variables
OutputsBuild execution context with build ID and WebSocket log stream endpoint
Verify MethodTest + Demonstration
Acceptance Criteria:
  • Execute build in isolated container
  • Stream logs in real-time via WebSocket
  • Support parallel job execution
  • Enable job-level timeout enforcement
  • Cache layer optimization for dependencies

REQ-API-EXEC-002: Test Execution & Reporting

PropertyValue
IDREQ-API-EXEC-002
RequirementThe API SHALL auto-discover and execute tests via POST /api/v1/builds/{id}/tests with framework-agnostic test execution and result aggregation.
RationaleAutomatic test discovery and execution enables zero-configuration test orchestration across diverse frameworks.
InputsProject framework, test framework detection results
OutputsTest results with pass/fail status, coverage reports, and performance metrics
Verify MethodTest
Acceptance Criteria:
  • Auto-detect test frameworks (pytest, jest, go test, cargo test, etc.)
  • Discover test files and suites
  • Execute tests in parallel
  • Aggregate results across test runners
  • Generate coverage reports

REQ-API-EXEC-003: Linting & Security Scanning

PropertyValue
IDREQ-API-EXEC-003
RequirementThe API SHALL execute linting and security scanning via POST /api/v1/builds/{id}/lint with framework-appropriate linters and SAST tools.
RationaleAutomated code quality and security scanning prevents defects and vulnerabilities from reaching production.
InputsProject code, framework context, linting configuration
OutputsLinting results with violations, security findings, and quality metrics
Verify MethodTest
Acceptance Criteria:
  • Execute linters for detected language (ESLint, Pylint, golangci-lint, etc.)
  • Run SAST security scanning
  • Perform dependency vulnerability scan
  • Aggregate results with severity classification

3.4 Build & Pipeline Status

REQ-API-STATUS-001: Real-Time Log Streaming

PropertyValue
IDREQ-API-STATUS-001
RequirementThe API SHALL stream build logs in real-time via WebSocket connection at /api/v1/builds/{id}/logs with structured JSON format.
RationaleReal-time log streaming enables developers to monitor builds and debug failures instantly without polling.
InputsBuild ID, WebSocket connection
OutputsContinuous stream of log entries with timestamps and severity levels
Verify MethodTest + Demonstration
Acceptance Criteria:
  • Stream logs with <100ms latency
  • Support log filtering and search
  • Include severity levels (DEBUG, INFO, WARN, ERROR)
  • Support connection recovery with backlog replay
Log Entry Format:
{
    "timestamp": "2025-12-03T10:30:45.123Z",
    "level": "INFO",
    "stage": "build",
    "job": "install-dependencies",
    "message": "Installing npm dependencies...",
    "metadata": {
        "duration_ms": 1234,
        "lines": 42
    }
}

REQ-API-STATUS-002: Build Status & Metrics

PropertyValue
IDREQ-API-STATUS-002
RequirementThe API SHALL provide build status and metrics via GET /api/v1/builds/{id} and /api/v1/projects/{id}/status.
RationaleDevelopers need quick access to build status for awareness and decision-making.
InputsBuild ID or Project ID
OutputsBuild/project status with metrics (duration, stage durations, resource usage)
Verify MethodTest
Acceptance Criteria:
  • Return current build status with stage progression
  • Show historical build metrics (duration, success rate)
  • Display resource usage (CPU, memory)
  • Support querying multiple builds

3.5 Deployment Management

REQ-API-DEPLOY-001: Deployment Configuration

PropertyValue
IDREQ-API-DEPLOY-001
RequirementThe API SHALL support deployment configuration via POST /api/v1/projects/{id}/deployments/configure for cloud platform targets.
RationaleDevelopers need to configure deployment targets (Railway, Render, Fly.io) with API credentials and deployment parameters.
InputsDeployment platform, credentials, deployment parameters
OutputsDeployment configuration stored and validated
Verify MethodTest
Acceptance Criteria:
  • Support Railway, Render, Fly.io, Vercel configurations
  • Validate platform credentials
  • Store encrypted credentials securely
  • Enable deployment strategy selection (blue-green, canary, rolling)

REQ-API-DEPLOY-002: Deployment Orchestration (via Loco)

PropertyValue
IDREQ-API-DEPLOY-002
RequirementThe API SHALL orchestrate deployments via Loco engine through POST /api/v1/builds/{id}/deploy with staged deployment support.
RationaleLoco engine provides intelligent deployment orchestration with pre-deployment validation and rollback capability.
InputsBuild ID, deployment target, deployment parameters
OutputsDeployment execution instance with status tracking
Verify MethodTest + Demonstration
Acceptance Criteria:
  • Execute pre-deployment validation checks
  • Support staged deployments (staging → production)
  • Enable approval gates
  • Provide instant rollback capability
  • Stream deployment logs

REQ-API-DEPLOY-003: Rollback & Deployment History

PropertyValue
IDREQ-API-DEPLOY-003
RequirementThe API SHALL support instant rollback via POST /api/v1/deployments/{id}/rollback with complete deployment history tracking.
RationaleInstant rollback capability critical for production incident response. History enables post-incident analysis and audit compliance.
InputsDeployment ID, optional target version
OutputsRollback execution with status and completion confirmation
Verify MethodTest + Demonstration
Acceptance Criteria:
  • Complete rollback in <30 seconds
  • Maintain complete deployment history
  • Support rollback to any previous deployment
  • Log all rollback operations

3.6 User & Workspace Management

REQ-API-USER-001: User Account Management

PropertyValue
IDREQ-API-USER-001
RequirementThe API SHALL support user account operations via /api/v1/users endpoints (create, retrieve, update) with proper authentication.
RationaleUser account management essential for identity and access control across platform.
InputsUser information (email, name, password, preferences)
OutputsUser object with generated user ID and authentication tokens
Verify MethodTest
Acceptance Criteria:
  • Support user registration, profile updates, password reset
  • Enforce password complexity requirements
  • Enable email verification

REQ-API-USER-002: Workspace Management

PropertyValue
IDREQ-API-USER-002
RequirementThe API SHALL support workspace operations via /api/v1/workspaces (create, list, manage members, configure settings).
RationaleWorkspaces provide organizational boundaries for teams and projects with distinct settings and permissions.
InputsWorkspace name, members, configuration settings
OutputsWorkspace object with generated workspace ID
Verify MethodTest
Acceptance Criteria:
  • Create and manage workspaces
  • Add/remove workspace members
  • Configure workspace-level settings
  • Support workspace invitations

REQ-API-USER-003: Role-Based Access Control (RBAC)

PropertyValue
IDREQ-API-USER-003
RequirementThe API SHALL enforce role-based access control via role definitions (owner, admin, developer, viewer) with fine-grained permissions.
RationaleRBAC enables secure delegation of responsibilities while maintaining control over sensitive operations.
InputsUser, role, resource context
OutputsAccess decision (allow/deny) based on role and permissions
Verify MethodTest
Acceptance Criteria:
  • Define standard roles (owner, admin, developer, viewer)
  • Support custom roles
  • Enforce permissions consistently across API
  • Log access decisions

3.7 Cloud Platform Integration

REQ-API-INTEGRATION-001: Railway Integration

PropertyValue
IDREQ-API-INTEGRATION-001
RequirementThe API SHALL integrate with Railway platform via POST /api/v1/integrations/railway for seamless deployment orchestration.
RationaleRailway is primary deployment target for Sparki platform requiring native integration.
InputsRailway project ID, API token, deployment parameters
OutputsRailway deployment execution with status tracking
Verify MethodTest + Demonstration
Acceptance Criteria:
  • Support Railway API authentication
  • Deploy to Railway projects
  • Stream deployment logs
  • Support health checks

REQ-API-INTEGRATION-002: Multi-Platform Support (Render, Fly.io, Vercel)

PropertyValue
IDREQ-API-INTEGRATION-002
RequirementThe API SHALL support multiple deployment platforms via pluggable adapter system.
RationaleDeveloper choice of deployment platform requires unified deployment interface abstraction.
InputsPlatform-specific credentials and deployment parameters
OutputsPlatform-agnostic deployment execution instance
Verify MethodTest
Acceptance Criteria:
  • Support Render, Fly.io, Vercel platforms
  • Enable pluggable adapter system for future platforms
  • Abstract platform differences

3.8 Observability & Metrics

REQ-API-OBS-001: Prometheus Metrics

PropertyValue
IDREQ-API-OBS-001
RequirementThe API SHALL export Prometheus metrics via /metrics endpoint with sparki.* namespace and standardized labels.
RationalePrometheus metrics enable comprehensive observability and integration with monitoring systems.
InputsAPI operations and performance data
OutputsPrometheus metrics in standardized format
Verify MethodTest
Acceptance Criteria:
  • Export HTTP metrics (latency, request count, error rate)
  • Export build metrics (duration, success rate)
  • Export deployment metrics
Key Metrics:
sparki_api_request_duration_seconds (histogram)
sparki_api_request_errors_total (counter)
sparki_build_duration_seconds (histogram)
sparki_build_success_total (counter)
sparki_deployment_duration_seconds (histogram)
sparki_pipeline_execution_total (counter)

REQ-API-OBS-002: Structured Logging

PropertyValue
IDREQ-API-OBS-002
RequirementThe API SHALL produce structured JSON logs with correlation IDs and standardized field naming.
RationaleStructured logging enables efficient log aggregation, searching, and analysis.
InputsLog events from API operations
OutputsJSON-formatted log entries with standardized structure
Verify MethodTest
Acceptance Criteria:
  • Log all API requests with correlation IDs
  • Include trace context in all logs
  • Use consistent field naming
  • Log errors with stack traces

4. Non-Functional Requirements

4.1 Performance Requirements

RequirementTargetMeasurement MethodRationale
API Response Time (P95)<50msPrometheus histogramsExceptional developer experience
Framework Detection<2 secondsBuild metricsInstant project analysis
Pipeline Generation<500msAPI latency trackingSeamless workflow
Log Query Performance<200msQuery latency metricsInstant troubleshooting
WebSocket Connection Latency<100msConnection metricsReal-time feedback experience
TUI Responsiveness<200msCLI metricsSnappy terminal experience

4.2 Scalability Requirements

RequirementTargetMeasurement MethodRationale
Concurrent Developers1M+Load testingGlobal developer market scale
Concurrent API Requests100K+/secLoad testingPeak traffic handling
Concurrent Build Executions10K+Pipeline metricsMassive deployment concurrency
Projects per Workspace10K+Database scalingLarge engineering organizations
Deployments per Project per Day1K+Deployment trackingContinuous deployment support

4.3 Reliability Requirements

RequirementTargetMeasurement MethodRationale
Availability SLA99.95%Uptime monitoringEnterprise-grade mission-critical workload
Build Execution Success Rate>99%Build success metricsReliable build automation
Data Durability99.999%Storage durabilityEnterprise data protection standard
Recovery Time Objective (RTO)<15 minutesIncident trackingMinimal service disruption
Recovery Point Objective (RPO)<5 minutesBackup verificationMinimal data loss

4.4 Security Requirements

RequirementTargetMeasurement MethodRationale
Authentication StandardOAuth 2.0/JWTSecurity auditIndustry-standard authentication
Data Encryption (In Transit)TLS 1.3Security scanningEncrypted communication
Data Encryption (At Rest)AES-256Encryption auditSecure data storage
Access ControlRBACPermission testingFine-grained access control
Audit Logging100% coverageLog auditCompliance and forensics
Rate LimitingAdaptiveTraffic analysisDoS protection

5. Integration Patterns

5.1 External Service Integration

┌─────────────┐
│  Sparki API │
├─────────────┤
│  Fiber Core │
├──────┬──────┴──────┬──────────┬────────────┐
│      │             │          │            │
├──────▼────┐  ┌─────▼────┐  ┌─▼───────┐  ┌─▼──────────┐
│ PostgreSQL │  │  Redis   │  │ S3/Blob │  │ Cloud APIs │
│ Database   │  │  Cache   │  │ Storage │  │ (Railway)  │
└────────────┘  └──────────┘  └─────────┘  └────────────┘

5.2 Cloud Platform Adapters

  • Railway: Native API integration for projects and deployments
  • Render: Blueprint and environment variable configuration
  • Fly.io: App deployment and scaling configuration
  • Vercel: Project and environment detection

6. API Response Formats

6.1 Standard Response Structure

{
  "success": true,
  "data": {
    "id": "proj_123",
    "name": "my-project",
    "framework": "next.js",
    ...
  },
  "meta": {
    "timestamp": "2025-12-03T10:30:45Z",
    "correlation_id": "req_xyz789"
  }
}

6.2 Error Response Structure

{
    "success": false,
    "error": {
        "code": "PROJECT_NOT_FOUND",
        "message": "Project with ID 'proj_123' not found",
        "details": {
            "project_id": "proj_123"
        }
    },
    "meta": {
        "timestamp": "2025-12-03T10:30:45Z",
        "correlation_id": "req_xyz789"
    }
}

7. Technology Stack

ComponentTechnologyRationale
HTTP FrameworkGo FiberUltra-fast, minimal allocations
DatabasePostgreSQLACID compliance, scaling support
CachingRedis/ValkeySub-millisecond operations
Object StorageS3/MinIO/Azure BlobScalable artifact storage
ObservabilityPrometheus/ELK/JaegerIndustry-standard open-source stack
ContainerizationDockerUniversal deployment format
OrchestrationKubernetesEnterprise deployment standard

8. Success Metrics

MetricYear 1 TargetMeasurement Method
API Response Time (P95)<50msPrometheus monitoring
Framework Detection Accuracy>99%Test suite coverage
Build Success Rate>99%Build metrics
Platform Uptime99.95%+Uptime monitoring
Developer Adoption100K+Active user tracking

Document History:
VersionDateAuthorChanges
1.02025-12-03Sparki EngineeringInitial API SRS creation