# nakkaya/ferret architecture

> Architecture diagram of the GitHub repository nakkaya/ferret, 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/nakkaya/ferret
- Repository: https://github.com/nakkaya/ferret

## Overview

##### Main Components

a) Input Processing Layer
- Lisp source code input handler
- Parser for Lisp syntax

b) Compilation Core
- AST (Abstract Syntax Tree) generator
- Semantic analyzer
- C++11 code generator

c) Output Generation Layer
- C++11 code emitter
- Build system integration

##### Important Elements to Highlight

- Blue: Input processing
- Green: Core compilation stages
- Orange: Output generation
- Gray: External tools (like g++)

- Rectangles: Processing stages
- Diamonds: Decision points

##### Relationships

- Data flow direction
- Dependency relationships
- Compilation pipeline stages

##### Technical Details

Annotations for:
- C++11 compliance requirements
- Threading support (-pthread)
- Memory constraints (2KB RAM capability)
- OS/Platform independence

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        LispSource[".clj Source File"]
        Parser["Parser"]
    end

    subgraph CompilationCore
        AST["AST Generator"]
        SemanticAnalyzer["Semantic Analyzer"]
        Optimizer["Optimizer"]
        CodeGen["C++11 Code Generator"]
    end

    subgraph OutputGeneration
        CPPOutput["Generated C++11 Code"]
        BuildSystem["Build System"]:::build
        GCC["G++ Compiler"]
        Binary["Final Executable"]
    end

    subgraph BuildTools
        Travis["Travis CI"]:::ci
        GitLab["GitLab CI"]:::ci
        Documentation["Documentation"]:::docs
    end

    %% Main Flow
    LispSource --> Parser
    Parser --> AST
    AST --> SemanticAnalyzer
    SemanticAnalyzer --> Optimizer
    Optimizer --> CodeGen
    CodeGen --> CPPOutput
    CPPOutput --> BuildSystem
    BuildSystem --> GCC
    GCC --> Binary

    %% Build and CI Integration
    BuildSystem -.-> Travis
    BuildSystem -.-> GitLab
    Documentation -.-> BuildSystem

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef build fill:#d9edf7,stroke:#31708f
    classDef ci fill:#dff0d8,stroke:#3c763d
    classDef docs fill:#fcf8e3,stroke:#8a6d3b

    %% Click Events
    click BuildSystem "https://github.com/nakkaya/ferret/tree/master/Makefile"
    click Travis "https://github.com/nakkaya/ferret/blob/master/.travis.yml"
    click GitLab "https://github.com/nakkaya/ferret/blob/master/.gitlab-ci.yml"
    click Documentation "https://github.com/nakkaya/ferret/blob/master/readme.md"
    click Documentation "https://github.com/nakkaya/ferret/blob/master/ferret.org"

    %% Legend
    subgraph Legend
        L1["Process"]:::default
        L2["Build Tools"]:::build
        L3["CI/CD"]:::ci
        L4["Documentation"]:::docs
    end
```
