# guacsec/guac architecture

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

- Interactive diagram: https://gitdiagram.com/guacsec/guac
- Repository: https://github.com/guacsec/guac

## Overview

##### Main Components Identification

a) Input Layer:
- Document Collectors (files, GCS, S3, OCI, GitHub)
- Supported Input Formats (CycloneDX, SPDX, SLSA, OpenVEX, etc.)
- Collection Subsystem (pkg/collectsub)

b) Processing Layer:
- Document Processors (pkg/handler/processor)
- Ingestor Component (pkg/ingestor)
- Parser System (pkg/ingestor/parser)
- Verification System (pkg/ingestor/verifier)

c) Storage Layer:
- Multiple Backend Support
- Key-value stores (Redis, TiKV)
- Graph databases (Neo4j, ArangoDB)
- SQL databases (PostgreSQL with Ent)
- Assembler Component (pkg/assembler)

d) API Layer:
- GraphQL API (pkg/assembler/graphql)
- REST API (pkg/guacrest)
- Client Libraries

##### Component Details

For each major component, include:
- Component name
- Primary function
- Supported formats/protocols
- Key interfaces

**[External Sources] → [Collectors] → [Document Processors]**
- ↓                    ↓              ↓
**[File Systems]    [Format Detection]  [Parser System]**

**[Ingestor] → [Parser] → [Verifier]**
- ↓          ↓           ↓
**[Document Processing Pipeline]**

**[Assembler] → [Backend Abstraction Layer]**
- ↓                ↓
**[GraphQL/REST] → [Multiple Backends]**

##### Additional Elements

Include:
- Version information
- Backend support status indicators
- Key integration points
- Security verification flows

##### Implementation Notes

- Maintain consistent spacing and alignment
- Clear labels and annotations
- Version information
- Document all external dependencies

Remember to indicate the experimental/supported status of different backends and include the security verification points throughout the system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef processing fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef storage fill:#FFA500,stroke:#333,stroke-width:2px
    classDef api fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Input Layer
    subgraph InputLayer["Input Layer"]
        ExtSrc["External Sources"]:::external
        Collectors["Document Collectors"]:::input
        DocFormats["Document Formats"]:::input
        CollectSub["Collection Subsystem"]:::input
    end

    %% Processing Layer
    subgraph ProcessingLayer["Processing Layer"]
        DocProc["Document Processors"]:::processing
        Ingestor["Ingestor Component"]:::processing
        Parser["Parser System"]:::processing
        Verifier["Verification System"]:::processing
    end

    %% Storage Layer
    subgraph StorageLayer["Storage Layer"]
        Assembler["Assembler Component"]:::storage
        Backend["Backend Support"]:::storage
        DB1["Key-value Stores<br/>(Redis, TiKV)"]:::storage
        DB2["Graph Databases<br/>(Neo4j, ArangoDB)"]:::storage
        DB3["SQL Databases<br/>(PostgreSQL/Ent)"]:::storage
    end

    %% API Layer
    subgraph APILayer["API Layer"]
        GraphQL["GraphQL API"]:::api
        REST["REST API"]:::api
        Clients["Client Libraries"]:::api
    end

    %% Relationships
    ExtSrc --> Collectors
    Collectors --> DocFormats
    DocFormats --> CollectSub
    CollectSub --> DocProc
    DocProc --> Ingestor
    Ingestor --> Parser
    Parser --> Verifier
    Verifier --> Assembler
    Assembler --> Backend
    Backend --> DB1
    Backend --> DB2
    Backend --> DB3
    Assembler --> GraphQL
    Assembler --> REST
    GraphQL --> Clients
    REST --> Clients

    %% Click Events
    click Collectors "https://github.com/guacsec/guac/tree/main/pkg/handler/collector/"
    click CollectSub "https://github.com/guacsec/guac/tree/main/pkg/collectsub/"
    click DocProc "https://github.com/guacsec/guac/tree/main/pkg/handler/processor/"
    click Ingestor "https://github.com/guacsec/guac/tree/main/pkg/ingestor/"
    click Parser "https://github.com/guacsec/guac/tree/main/pkg/ingestor/parser/"
    click Verifier "https://github.com/guacsec/guac/tree/main/pkg/ingestor/verifier/"
    click Backend "https://github.com/guacsec/guac/tree/main/pkg/assembler/backends/"
    click Assembler "https://github.com/guacsec/guac/tree/main/pkg/assembler/"
    click GraphQL "https://github.com/guacsec/guac/tree/main/pkg/assembler/graphql/"
    click REST "https://github.com/guacsec/guac/tree/main/pkg/guacrest/"
    click Clients "https://github.com/guacsec/guac/tree/main/pkg/assembler/clients/"

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Processing Components"]:::processing
        L3["Storage Components"]:::storage
        L4["API Components"]:::api
        L5["External Systems"]:::external
    end
```
