mrapids 0.1.31

Your OpenAPI, but executable
Documentation
# MicroRapid Requirements Document

## Executive Summary

MicroRapid is a universal API execution engine that makes existing API specifications directly executable without conversion. Built on the core insight that "APIs should be executable, not just documented," MicroRapid eliminates the need for multiple tools by providing a single CLI that can execute OpenAPI specs, GraphQL schemas, and cURL commands directly.

**Tagline:** "Your OpenAPI, but executable"

## Product Vision & Positioning

### Core Vision Statement
Transform API specifications from static documentation into executable runtime environments, enabling developers to test, validate, and interact with APIs using their existing specification files.

### Market Position
- **Not:** Another API testing tool or format converter
- **But:** The missing execution layer for existing API specifications
- **Differentiator:** Direct execution without intermediate file generation

### Target Problem
Developers have API specifications (OpenAPI, GraphQL schemas) but need separate tools to actually test and interact with these APIs, leading to maintenance of multiple formats and sync drift.

## Core Value Propositions

### Primary Value
- **Zero Learning Curve** - Uses existing OpenAPI/GraphQL knowledge
- **No Format Conversion** - Execute specs directly, no intermediate files
- **Always In Sync** - No drift between specs and tests
- **Universal Support** - One tool for multiple API formats

### Developer Benefits
- **Faster Development** - Instant API testing from specs
- **Reduced Maintenance** - Single source of truth
- **CI/CD Ready** - Built-in automation support
- **Cross-Platform** - Works everywhere Rust runs

## Target Users

### Primary Users
- **API Developers** - Building and maintaining REST/GraphQL APIs
- **Frontend Developers** - Consuming APIs, need quick testing
- **DevOps Engineers** - Automating API testing in CI/CD pipelines
- **QA Engineers** - API testing and validation

### User Personas

#### Backend Developer (Primary)
- Has OpenAPI specs for their APIs
- Needs quick way to test endpoints during development
- Wants CI/CD integration for automated testing
- Values speed and simplicity

#### Frontend Developer (Secondary)
- Consumes APIs documented with OpenAPI
- Needs to quickly test API endpoints
- Wants to verify API behavior matches specification
- Often works with GraphQL APIs

## Functional Requirements

### Core Features (MVP)

#### 1. OpenAPI Direct Execution
```bash
# Execute OpenAPI operations directly
mrapids run openapi.yaml --operation getUserById --data user.json
mrapids run openapi.yaml --operation createUser --data '{"name":"John"}'
mrapids test openapi.yaml --all-operations
```

**Acceptance Criteria:**
- Parse OpenAPI 3.0/3.1 specifications
- Execute GET, POST, PUT, DELETE operations
- Support path parameters, query parameters, request bodies
- Handle authentication (Bearer, API Key, Basic Auth)
- Validate responses against OpenAPI schemas
- Support environment variables and data injection

#### 2. GraphQL Schema Execution
```bash
# Execute GraphQL queries from schema
mrapids run schema.graphql --query getUserById --variables user.json
mrapids run schema.graphql --mutation createUser --variables '{"name":"John"}'
```

**Acceptance Criteria:**
- Parse GraphQL schema definition files (.graphql, .gql)
- Execute queries, mutations, and subscriptions
- Support variable injection
- Validate queries against schema
- Handle GraphQL-specific authentication

#### 3. cURL Command Execution
```bash
# Execute cURL commands with organization
mrapids run commands.curl --batch
mrapids run commands.curl --filter auth-endpoints
```

**Acceptance Criteria:**
- Parse cURL command syntax
- Support major cURL flags and options
- Handle environment variable substitution
- Batch execution capabilities

### Enhanced Features (Post-MVP)

#### 4. Watch Mode & Live Reload
```bash
# Watch for spec changes and re-run tests
mrapids watch openapi.yaml --operation getUserById
mrapids watch schema.graphql --auto-test
```

#### 5. Data Generation & Testing
```bash
# Generate test data from schemas
mrapids generate data --from openapi.yaml --output test-data.json
mrapids test openapi.yaml --with-generated-data
```

#### 6. Performance Testing
```bash
# Load testing from specifications
mrapids perf openapi.yaml --operation getUserById --concurrent 100
mrapids perf schema.graphql --query allUsers --duration 60s
```

#### 7. Contract Validation
```bash
# Verify API implementation matches specification
mrapids verify openapi.yaml --against https://api.example.com
mrapids diff openapi-v1.yaml openapi-v2.yaml
```

## Technical Requirements

### Architecture

#### Core Technology Stack
- **Language:** Rust (for performance and cross-platform support)
- **CLI Framework:** clap-rs for command-line interface
- **HTTP Client:** reqwest for HTTP requests
- **JSON/YAML Parsing:** serde with serde_json/serde_yaml
- **GraphQL:** graphql-parser for schema parsing
- **OpenAPI:** openapiv3 crate for specification parsing

#### Modular Architecture
```
mcp_core/
├── parsers/           // OpenAPI, GraphQL, cURL parsers
├── executors/         // HTTP, GraphQL execution engines  
├── validators/        // Response validation
├── auth/             // Authentication handlers
├── data/             // Test data generation
└── cli/              // Command-line interface
```

### Performance Requirements
- **Startup Time:** < 100ms for most operations
- **Memory Usage:** < 50MB for typical use cases
- **Request Latency:** Minimal overhead over raw HTTP requests
- **Concurrent Requests:** Support 100+ concurrent operations

### Platform Support
- **Primary:** Linux, macOS, Windows
- **Architectures:** x86_64, ARM64
- **Distribution:** Single binary, no dependencies
- **Package Managers:** brew, apt, cargo, npm (as optional wrapper)

## Non-Functional Requirements

### Usability
- **Zero Configuration:** Works with standard OpenAPI/GraphQL files
- **Intuitive CLI:** Self-documenting commands with helpful error messages
- **IDE Integration:** Works well with VS Code, terminal environments
- **Documentation:** Comprehensive examples and use cases

### Reliability
- **Error Handling:** Graceful failure with actionable error messages
- **Schema Validation:** Validate input specifications before execution
- **Timeout Handling:** Configurable timeouts for HTTP requests
- **Retry Logic:** Built-in retry mechanisms for failed requests

### Security
- **Credential Management:** Secure handling of API keys and tokens
- **Environment Variables:** Support for sensitive data via env vars
- **No Data Persistence:** Don't store sensitive information locally
- **HTTPS:** Enforce secure connections where appropriate

### Extensibility
- **Plugin Architecture:** Support for custom authentication methods
- **Configuration Files:** Support for project-level configuration
- **Output Formats:** JSON, YAML, table, and custom formats
- **Integration:** Easy integration with CI/CD systems

## User Experience Requirements

### Command-Line Interface

#### Primary Commands
```bash
# Core operations
mrapids run <spec-file> [options]
mrapids test <spec-file> [options]  
mrapids watch <spec-file> [options]
mrapids generate <type> --from <spec-file>

# Utility commands
mrapids validate <spec-file>
mrapids docs <spec-file>
mrapids version
mrapids help
```

#### Common Flags
```bash
--operation, -o    # Specific operation to execute
--data, -d         # Input data (JSON string or file path)
--env, -e          # Environment file
--auth, -a         # Authentication method
--output, -O       # Output format (json, yaml, table)
--verbose, -v      # Verbose output
--quiet, -q        # Quiet mode
--config, -c       # Configuration file
```

### Output Format
- **Default:** Human-readable colored output
- **JSON:** Machine-readable for scripts
- **Table:** Structured data display
- **Raw:** Direct HTTP response output

### Error Messages
- **Actionable:** Tell user exactly what to fix
- **Contextual:** Show relevant line numbers/sections
- **Helpful:** Suggest corrections or alternatives
- **Non-Technical:** Accessible to all skill levels

## Success Metrics

### Adoption Metrics
- **Downloads:** Track CLI downloads across platforms
- **GitHub Stars:** Community interest indicator
- **Usage Analytics:** Command usage patterns (opt-in)
- **Community Contributions:** PRs, issues, discussions

### Performance Metrics
- **Startup Time:** < 100ms consistently
- **Memory Usage:** Baseline and growth patterns
- **Success Rate:** API execution success percentage
- **User Retention:** Weekly/monthly active usage

### Quality Metrics
- **Bug Reports:** Issues per release
- **User Satisfaction:** Survey responses
- **Documentation Completeness:** Coverage metrics
- **Test Coverage:** Code coverage percentage

## Implementation Phases

### Phase 1: Core MVP (Months 1-2)
- [x] Basic OpenAPI 3.0 parsing and execution
- [x] Simple HTTP operations (GET, POST, PUT, DELETE)
- [x] Command-line interface with core commands
- [x] Basic authentication support (Bearer, API Key)
- [x] JSON/YAML output formats
- [x] Error handling and validation

### Phase 2: Enhanced Features (Months 3-4)
- [ ] GraphQL schema parsing and execution
- [ ] cURL command parsing and execution
- [ ] Watch mode and live reload
- [ ] Environment variable support
- [ ] Configuration file support
- [ ] Advanced authentication methods

### Phase 3: Advanced Capabilities (Months 5-6)
- [ ] Test data generation from schemas
- [ ] Performance testing capabilities
- [ ] Contract validation and verification
- [ ] Plugin architecture for extensibility
- [ ] IDE integration and language server
- [ ] Comprehensive documentation and examples

### Phase 4: Ecosystem Integration (Months 7+)
- [ ] CI/CD pipeline integrations
- [ ] Package manager distributions
- [ ] Community templates and examples
- [ ] Advanced reporting and analytics
- [ ] Enterprise features and support
- [ ] MCP adapter integration

## Definition of Done

### For Each Feature
- [x] Implementation complete with error handling
- [x] Unit tests with >90% coverage
- [x] Integration tests with real API specs
- [x] Documentation with examples
- [x] Performance benchmarks within requirements
- [x] Cross-platform compatibility verified

### For Each Release
- [x] All tests passing on CI/CD
- [x] Release notes and changelog updated
- [x] Binary builds for all platforms
- [x] Package manager releases published
- [x] Documentation website updated
- [x] Community notification sent