# duraki/frida-cycript architecture

> Architecture diagram of the GitHub repository duraki/frida-cycript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/duraki/frida-cycript
- Repository: https://github.com/duraki/frida-cycript

## Overview

##### Main Components

a. Core Components:
- Compiler System (cylang to JavaScript)
- Mjølner Runtime (Frida-powered)
- Console Interface
- Node.js Bindings

b. Supporting Components:
- Parser Components (Bison/Flex)
- Bridge System
- Analysis Engine
- External Dependencies (Frida, readline)

**┌─────────────────────────────────────────┐**
- User Interface               │
- (Console/REPL, Node.js Bindings)      │
- ┤
- Compiler Layer               │
- (Parser, Scanner, Syntax Analysis)     │
- ┤
- Runtime Layer                │
- (Mjølner/Frida Runtime, Bridge)       │
- ┤
- Target Application             │
- (iOS/Android/macOS/Windows Process)   │
- ┘

##### Component Details

- Rectangles: Main components
- Hexagons: External dependencies

##### Key Relationships

a. Input Flow:
- User input → Console Interface
- Console → Compiler (cylang code)
- Compiler → JavaScript output

b. Runtime Flow:
- JavaScript → Mjølner Runtime
- Runtime → Target Process
- Bridge → Native Functions

##### Technical Details to Highlight

- Parser components (src/Parser.ypp.in, Scanner.lpp.in)
- Bridge system (src/Bridge.*)
- Analysis components (src/Analysis.cpp, Analyze.cpp)
- Multiple language support (ObjectiveC, Java folders)

##### Notes for Implementation

- Keep the main flow clear and centered
- Related components visually
- Use consistent spacing and alignment
- Version information
- Notes about platform-specific behaviors

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#e1f5fe,stroke:#01579b
    classDef compiler fill:#fff3e0,stroke:#e65100
    classDef runtime fill:#e8f5e9,stroke:#1b5e20
    classDef target fill:#fce4ec,stroke:#880e4f
    classDef external fill:#f3e5f5,stroke:#4a148c
    classDef bridge fill:#fff8e1,stroke:#ff6f00
    classDef analysis fill:#f1f8e9,stroke:#33691e
    classDef parser fill:#e0f2f1,stroke:#004d40

    %% User Interface Layer
    subgraph UI
        Console["Console Interface"]:::ui
        NodeBindings["Node.js Bindings"]:::ui
    end

    %% Compiler Layer
    subgraph CompilerSystem
        Parser["Parser (Bison)"]:::parser
        Scanner["Scanner (Flex)"]:::parser
        SyntaxAnalysis["Syntax Analysis"]:::compiler
        Driver["Driver"]:::compiler
        ErrorHandler["Error Handler"]:::compiler
        Output["Output Processor"]:::compiler
    end

    %% Runtime Layer
    subgraph RuntimeSystem
        MjolnerRuntime["Mjølner Runtime"]:::runtime
        Bridge["Bridge System"]:::bridge
        Analysis["Analysis Engine"]:::analysis
        Execute["Core Executor"]:::runtime
    end

    %% Language Support
    subgraph LanguageSupport
        ObjC["Objective-C Support"]:::runtime
        Java["Java Support"]:::runtime
    end

    %% Target Layer
    subgraph TargetSystem
        iOS["iOS Process"]:::target
        Android["Android Process"]:::target
        Desktop["Desktop Process"]:::target
    end

    %% External Dependencies
    Frida["Frida"]:::external
    Readline["readline"]:::external

    %% Relationships
    Console --> Parser
    NodeBindings --> Parser
    Parser --> Scanner
    Scanner --> SyntaxAnalysis
    SyntaxAnalysis --> Driver
    Driver --> ErrorHandler
    Driver --> Output
    Output --> MjolnerRuntime
    MjolnerRuntime --> Bridge
    Bridge --> Analysis
    Analysis --> Execute
    Execute --> |iOS| iOS
    Execute --> |Android| Android
    Execute --> |Desktop| Desktop
    MjolnerRuntime --> Frida
    Console --> Readline
    Bridge --> ObjC
    Bridge --> Java

    %% Click Events
    click Parser "https://github.com/duraki/frida-cycript/blob/master/src/Parser.ypp.in"
    click Scanner "https://github.com/duraki/frida-cycript/blob/master/src/Scanner.lpp.in"
    click Bridge "https://github.com/duraki/frida-cycript/blob/master/src/Bridge.cpp"
    click Analysis "https://github.com/duraki/frida-cycript/blob/master/src/Analysis.cpp"
    click Console "https://github.com/duraki/frida-cycript/blob/master/src/Console.cpp"
    click NodeBindings "https://github.com/duraki/frida-cycript/tree/master/bindings/node/cylang"
    click MjolnerRuntime "https://github.com/duraki/frida-cycript/tree/master/src/Agent"
    click ObjC "https://github.com/duraki/frida-cycript/tree/master/src/ObjectiveC"
    click Java "https://github.com/duraki/frida-cycript/tree/master/src/Java"
    click Execute "https://github.com/duraki/frida-cycript/blob/master/src/Execute.cpp"
    click ErrorHandler "https://github.com/duraki/frida-cycript/blob/master/src/Error.cpp"
    click SyntaxAnalysis "https://github.com/duraki/frida-cycript/blob/master/src/Syntax.cpp"
    click Output "https://github.com/duraki/frida-cycript/blob/master/src/Output.cpp"
    click Driver "https://github.com/duraki/frida-cycript/blob/master/src/Driver.cpp"
```
