# kiranz/just-api architecture

> Architecture diagram of the GitHub repository kiranz/just-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kiranz/just-api
- Repository: https://github.com/kiranz/just-api

## Overview

##### Main Components

a. Core Engine Components:
- Test Suite Parser
- Request Builder
- Response Validator
- Test Runner
- Reporter System

b. External Interfaces:
- REST API Endpoints
- GraphQL API Endpoints
- File System (YAML Specs)

**┌─────────────────────────────────────────────────────────────┐**
- CLI Interface Layer                      │
- ┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- Core Engine Layer                        │
- ┬───────────────┬────────────────┬───────────┤
- YAML Parser   │ Test Runner   │ Request Builder│ Validator │
- ┴───────────────┴────────────────┴───────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- Extension Layer                          │
- ┬───────────────┬────────────────┬───────────┤
- Custom JS     │ Hooks System  │ Suite Config   │ Reporters │
- ┴───────────────┴────────────────┴───────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- External Interface Layer                 │
- ┬───────────────┬────────────────┬───────────┤
- REST APIs     │ GraphQL APIs  │ File System    │ Console   │
- ┴───────────────┴────────────────┴───────────┘

##### Component Relationships

- CLI → YAML Parser (test suite input)
- YAML Parser → Test Runner (parsed specifications)
- Test Runner → Request Builder (test execution)
- Request Builder → External APIs (HTTP requests)
- External APIs → Validator (responses)
- Validator → Reporters (results)

##### Implementation Details

Directories and their roles:
**lib/**
- schema/     # YAML validation schemas
- reporters/  # Output formatting
- core/       # Main engine components

**test/**
- cli/        # Test specifications

##### Additional Elements

Callouts for:
- Configuration options
- Support for various HTTP methods
- File upload capabilities
- JSON schema validation
- Retry mechanisms
- Test context sharing

##### The flexible reporting system

This system design should capture both the high-level architecture and the important implementation details while maintaining clarity and readability.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef cli fill:#808080,stroke:#000,color:white
    classDef core fill:#3498db,stroke:#000,color:white
    classDef extension fill:#2ecc71,stroke:#000,color:white
    classDef external fill:#e67e22,stroke:#000,color:white
    
    %% CLI Layer
    subgraph CLI
        cli["CLI Interface"]
    end
    click cli "https://github.com/kiranz/just-api/tree/master/bin/just-api"
    
    %% Core Engine Layer
    subgraph CoreEngine
        yaml["YAML Parser/Loader"]:::core
        runner["Test Runner"]:::core
        builder["Request Builder"]:::core
        validator["Response Validator"]:::core
        schema["Schema Validator"]:::core
        core["Core Engine"]:::core
    end
    click yaml "https://github.com/kiranz/just-api/blob/master/lib/schema/yaml/loader.js"
    click runner "https://github.com/kiranz/just-api/blob/master/lib/launcher.js"
    click builder "https://github.com/kiranz/just-api/blob/master/lib/request.js"
    click validator "https://github.com/kiranz/just-api/blob/master/lib/response.js"
    click schema "https://github.com/kiranz/just-api/blob/master/lib/schema/validator.js"
    click core "https://github.com/kiranz/just-api/blob/master/lib/just-api.js"
    
    %% Extension Layer
    subgraph Extensions
        customJS["Custom JS Functions"]:::extension
        hooks["Hooks System"]:::extension
        config["Suite Config"]:::extension
        reporters["Reporter System"]:::extension
        suiteHandler["Suite Handler"]:::extension
        suiteDeps["Suite Dependencies"]:::extension
        specHandler["Spec Handler"]:::extension
    end
    click reporters "https://github.com/kiranz/just-api/blob/master/lib/reporters/base.js"
    click suiteHandler "https://github.com/kiranz/just-api/blob/master/lib/suite.js"
    click suiteDeps "https://github.com/kiranz/just-api/blob/master/lib/suite-dependency.js"
    click specHandler "https://github.com/kiranz/just-api/blob/master/lib/spec.js"
    
    %% External Interface Layer
    subgraph External
        rest["REST APIs"]:::external
        graphql["GraphQL APIs"]:::external
        fs["File System"]:::external
        console["Console Output"]:::external
    end
    
    %% Relationships
    cli --> yaml
    yaml --> runner
    runner --> builder
    builder --> rest
    builder --> graphql
    rest --> validator
    graphql --> validator
    validator --> reporters
    reporters --> console
    yaml --> fs
    
    %% Additional Components
    subgraph ReporterTypes
        htmlReporter["HTML Reporter"]:::extension
        jsonReporter["JSON Reporter"]:::extension
    end
    click htmlReporter "https://github.com/kiranz/just-api/blob/master/lib/reporters/html.js"
    click jsonReporter "https://github.com/kiranz/just-api/blob/master/lib/reporters/json.js"
    
    reporters --> htmlReporter
    reporters --> jsonReporter
    
    %% Legend
    subgraph Legend
        cliLegend["CLI Components"]:::cli
        coreLegend["Core Components"]:::core
        extLegend["Extension Components"]:::extension
        extIntLegend["External Interfaces"]:::external
    end
```
