# brightify/cuckoo architecture

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

- Interactive diagram: https://gitdiagram.com/brightify/cuckoo
- Repository: https://github.com/brightify/cuckoo

## Overview

##### Main Components Overview

a) Generator (Cuckoonator):
- Input processor for Swift source files
- Syntax analyzer
- Mock code generator
- File output manager

b) Runtime:
- Mock implementation
- Stubbing system
- Verification system
- Matching system
- OCMock integration

##### Detailed Component Breakdown

Generator Component:
**┌─────────────── Generator ───────────────┐**

- ┌─────────┐    ┌────────┐   ┌───────┐ │
- Input  │    │ Syntax │   │ Token │ │
- Crawler │───▶│Parser  │──▶│Parser │ │
- ┘    └────────┘   └───────┘ │
- ▲                         │      │
- ▼      │
- ┌─────────┐    ┌────────────────────┐ │
- File   │    │     Templates      │ │
- Handler │◀───│  - Mock           │ │
- ┘    │  - Stub           │ │
- Verification    │ │
- ┘ │
- ┘

Runtime Component:
**┌─────────────── Runtime ────────────────┐**

- ┌─────────┐    ┌────────┐   ┌───────┐ │
- Mock   │    │ Stub   │   │Verify │ │
- Manager  │───▶│System  │──▶│System │ │
- ┘    └────────┘   └───────┘ │
- ▲                         ▲      │

- ┌─────────┐    ┌────────┐      │      │
- Matcher │    │OCMock  │      │      │
- System  │────│Bridge  │──────┘      │
- ┘    └────────┘             │
- ┘

##### Data Flow and Interactions

**┌─────────┐     ┌──────────┐     ┌─────────┐**
- Swift  │     │Generator │     │Generated │
- Files  │────▶│ Process  │────▶│  Mocks  │
- ┘     └──────────┘     └─────────┘

- ▼
**┌─────────┐     ┌──────────┐     ┌─────────┐**
- Test   │     │ Runtime  │     │  Mock   │
- Cases  │◀───▶│ System   │◀────│ Classes │
- ┘     └──────────┘     └─────────┘

##### The integration with external systems (OCMock, build system)

This system design captures the complexity of Cuckoo while making it clear how the different parts work together to provide a complete mocking solution for Swift.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Generator
        Input["Input Processor"]
        Syntax["Syntax Analyzer"]
        Token["Token Parser"]
        FileH["File Handler"]
        Templates["Template System"]
        TypeInf["Type Inference"]
        
        Input --> Syntax
        Syntax --> Token
        Token --> Templates
        Templates --> FileH
        TypeInf --> Templates
    end
    
    subgraph Runtime
        MockMgr["Mock Manager"]
        StubSys["Stubbing System"]
        VerifySys["Verification System"]
        MatchSys["Matching System"]
        OCMock["OCMock Bridge"]
        DefVal["Default Value Registry"]
        MockBuild["Mock Builder"]
        ParamMatch["Parameter Matcher"]
        VerifProxy["Verification Proxy"]
        
        MockMgr --> StubSys
        MockMgr --> VerifySys
        MatchSys --> VerifySys
        OCMock --> VerifySys
        MockBuild --> MockMgr
        ParamMatch --> MatchSys
        VerifProxy --> VerifySys
    end
    
    SwiftFiles["Swift Source Files"] --> Input
    FileH --> GeneratedMocks["Generated Mock Classes"]
    GeneratedMocks --> MockMgr
    TestCases["Test Cases"] --> MockMgr
    
    classDef generator fill:#a8d1f0
    classDef runtime fill:#90EE90
    classDef external fill:#FFE4B5
    classDef support fill:#D3D3D3
    
    class Input,Syntax,Token,FileH,Templates,TypeInf generator
    class MockMgr,StubSys,VerifySys,MatchSys,OCMock,DefVal,MockBuild,ParamMatch,VerifProxy runtime
    class SwiftFiles,TestCases,GeneratedMocks external
    
    click Input "https://github.com/Brightify/Cuckoo/blob/master/Generator/Sources/CLI/Generator.swift"
    click Syntax "https://github.com/Brightify/Cuckoo/blob/master/Generator/Sources/Internal/Crawlers/Crawler.swift"
    click Token "https://github.com/Brightify/Cuckoo/tree/master/Generator/Sources/Internal/Tokens/"
    click FileH "https://github.com/Brightify/Cuckoo/blob/master/Generator/Sources/Internal/FileHeaderHandler.swift"
    click Templates "https://github.com/Brightify/Cuckoo/blob/master/Generator/Sources/Internal/Templates/Templates.swift"
    click TypeInf "https://github.com/Brightify/Cuckoo/blob/master/Generator/Sources/Internal/TypeGuesser.swift"
    click MockMgr "https://github.com/Brightify/Cuckoo/blob/master/Source/MockManager.swift"
    click StubSys "https://github.com/Brightify/Cuckoo/tree/master/Source/Stubbing/"
    click VerifySys "https://github.com/Brightify/Cuckoo/tree/master/Source/Verification/"
    click MatchSys "https://github.com/Brightify/Cuckoo/tree/master/Source/Matching/"
    click OCMock "https://github.com/Brightify/Cuckoo/tree/master/OCMock/"
    click DefVal "https://github.com/Brightify/Cuckoo/blob/master/Source/DefaultValueRegistry.swift"
    click MockBuild "https://github.com/Brightify/Cuckoo/blob/master/Source/Initialization/MockBuilder.swift"
    click ParamMatch "https://github.com/Brightify/Cuckoo/blob/master/Source/Matching/ParameterMatcher.swift"
    click VerifProxy "https://github.com/Brightify/Cuckoo/blob/master/Source/Mock/VerificationProxy.swift"
```
