# filecoin-project/go-f3 architecture

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

- Interactive diagram: https://gitdiagram.com/filecoin-project/go-f3
- Repository: https://github.com/filecoin-project/go-f3

## Overview

##### Main Components

a) Core Protocol Layer:
- GossipPBFT Consensus Module (from /gpbft)
- BLS Signature Module (from /blssig)
- Expected Consensus Module (from /ec)

b) Certificate Management Layer:
- Certificate Store (from /certstore)
- Certificate Exchange System (from /certexchange)
- Certificate Chain Management (from /certchain)

c) Network Layer:
- Polling Mechanism (from /certexchange/polling)
- PubSub System (from /chainexchange)

d) Supporting Infrastructure:
- Write-Ahead Log (from /internal/writeaheadlog)
- Power Store (from /internal/powerstore)
- Manifest Management (from /manifest)

**┌─────────────────────────────────────────┐**
- External Systems             │
- (Filecoin Network / Lotus Nodes)     │
- ┘
- ↕
**┌─────────────────────────────────────────┐**
- Network Communication           │
- (PubSub, Certificate Exchange)       │
- ┘
- ↕
**┌─────────────────────────────────────────┐**
- Consensus Core (GPBFT)          │
- ┘
- ↕
**┌─────────────────────────────────────────┐**
- Certificate Management           │
- ┘
- ↕
**┌─────────────────────────────────────────┐**
- Persistence Layer               │
- ┘

##### Key Relationships to Highlight

- Bidirectional communication between the GPBFT consensus module and certificate management
- Polling mechanism's interaction with external nodes
- Demonstrate how the power store influences consensus decisions
- Write-ahead log's relationship with critical components

##### Component Details

For each major component, show:
- Internal subcomponents (e.g., poller, predictor, and subscriber for polling)
- Key interfaces with other components
- Primary data flows
- Critical state storage points

##### Metrics and Monitoring Points

Indicators for:
- Performance measurement points (from /metrics.go files)
- Health check locations
- Monitoring interfaces

##### Implementation Notes

- Numbered sequence indicators for critical flows

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef external fill:#D3D3D3,stroke:#333
    classDef network fill:#90EE90,stroke:#333
    classDef consensus fill:#87CEEB,stroke:#333
    classDef cert fill:#FFD700,stroke:#333
    classDef infra fill:#A9A9A9,stroke:#333
    
    %% External Layer
    subgraph External
        FN["Filecoin Network"]
        LN["Lotus Nodes"]
    end
    
    %% Network Layer
    subgraph Network
        PS["PubSub System"]:::network
        CE["Certificate Exchange"]:::network
        PM["Polling Mechanism"]:::network
    end
    
    %% Consensus Layer
    subgraph Consensus
        GPBFT["GossipPBFT Consensus"]:::consensus
        BLS["BLS Signature Module"]:::consensus
        EC["Expected Consensus"]:::consensus
    end
    
    %% Certificate Management Layer
    subgraph CertManagement
        CS["Certificate Store"]:::cert
        CCM["Certificate Chain Management"]:::cert
    end
    
    %% Infrastructure Layer
    subgraph Infrastructure
        WAL["Write-Ahead Log"]:::infra
        PS_["Power Store"]:::infra
        MM["Manifest Management"]:::infra
    end
    
    %% Relationships
    FN <--> PS
    LN <--> PM
    PS <--> GPBFT
    PM <--> CE
    CE <--> CS
    GPBFT <--> BLS
    GPBFT <--> EC
    GPBFT <--> CS
    CS <--> CCM
    CCM <--> WAL
    GPBFT <--> PS_
    CCM <--> MM
    
    %% Click events
    click GPBFT "https://github.com/filecoin-project/go-f3/blob/main/gpbft/gpbft.go"
    click BLS "https://github.com/filecoin-project/go-f3/blob/main/blssig/signer.go"
    click EC "https://github.com/filecoin-project/go-f3/blob/main/ec/ec.go"
    click CS "https://github.com/filecoin-project/go-f3/blob/main/certstore/certstore.go"
    click CE "https://github.com/filecoin-project/go-f3/blob/main/certexchange/protocol.go"
    click CCM "https://github.com/filecoin-project/go-f3/blob/main/certchain/certchain.go"
    click PM "https://github.com/filecoin-project/go-f3/blob/main/certexchange/polling/poller.go"
    click PS "https://github.com/filecoin-project/go-f3/blob/main/chainexchange/pubsub.go"
    click WAL "https://github.com/filecoin-project/go-f3/blob/main/internal/writeaheadlog/wal.go"
    click PS_ "https://github.com/filecoin-project/go-f3/blob/main/internal/powerstore/powerstore.go"
    click MM "https://github.com/filecoin-project/go-f3/blob/main/manifest/manifest.go"
    
    %% Legend
    subgraph Legend
        E1["External Systems"]:::external
        N1["Network Components"]:::network
        C1["Consensus Components"]:::consensus
        CM1["Certificate Management"]:::cert
        I1["Infrastructure"]:::infra
    end
    
    class FN,LN external
    class PS,CE,PM network
    class GPBFT,BLS,EC consensus
    class CS,CCM cert
    class WAL,PS_,MM infra
```
