# anyproto/any-sync-filenode architecture

> Architecture diagram of the GitHub repository anyproto/any-sync-filenode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anyproto/any-sync-filenode
- Repository: https://github.com/anyproto/any-sync-filenode

## Overview

##### Project type and purpose
- This is a Go-based microservice implementing a “file node” as part of the Any-Sync protocol.
- It provides an RPC interface for storing, retrieving, indexing, and deleting file data, backed by S3-compatible storage and Redis.

##### File structure
- Top-level entrypoints under `cmd/` produce executables:
- `filenode` – main service
- `store` / `store_dev` – direct store utilities
- Core packages:
- `config` – configuration loading (YAML)
- `filenode` – RPC handler and orchestration
- `index` – metadata indexing (with protobufs, pub/sub, migration)
- `store` – storage adapters (S3, file-dev, mock)
- `redisprovider` – pub/sub via Redis
- `deletelog` – write-ahead log of deletions
- `account` – identity / access control stubs
- `stat` – usage metrics
- Testing and mocks live alongside each package.
- Deployment bits: `etc/any-sync-filenode.yml`, GitHub Actions workflows, Makefile.

##### README
- Specifies external dependencies: S3-compatible object storage and Redis.
- Describes CLI options, configuration.

##### Detailed capture of essential elements
- Your config loader as the entrypoint feeding parameters to all modules.
- Test and mock packages only if illustrating extensibility or testing structure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CLI Binaries"
        CLI_Filenode["filenode CLI"]:::cli
        CLI_Store["store utility"]:::cli
        CLI_StoreDev["store_dev utility"]:::cli
    end

    subgraph "Configuration"
        ConfigLoader["Configuration Loader"]:::config
    end

    subgraph "File Node Service"
        CoreService["File Node Service"]:::service
        RPCHandler["RPC Handler"]:::service
    end

    subgraph "Business Logic"
        AuthService["Account/Auth Service"]:::service
        StatCollector["Statistics Collector"]:::service
        DeleteLog["Deletion Log Manager"]:::service
        IndexEngine["Index Engine"]:::service
    end

    subgraph "Persistence Adapters"
        StoreInterface["Store Interface"]:::adapter
        S3Store["S3 Store Adapter"]:::adapter
        FileDevStore["FileDev Store Adapter"]:::adapter
        MockStore["Mock Store Adapter"]:::adapter
        RedisProvider["Redis Pub/Sub Provider"]:::adapter
    end

    subgraph "External Systems"
        S3["S3-Compatible Storage"]:::external
        Redis["Redis"]:::external
    end

    CLI_Filenode -->|starts| ConfigLoader
    CLI_Store -->|starts| ConfigLoader
    CLI_StoreDev -->|starts| ConfigLoader

    ConfigLoader -->|provides config| CoreService
    ConfigLoader -->|provides config| RPCHandler
    ConfigLoader -->|provides config| StoreInterface
    ConfigLoader -->|provides config| IndexEngine
    ConfigLoader -->|provides config| RedisProvider
    ConfigLoader -->|provides config| DeleteLog
    ConfigLoader -->|provides config| AuthService
    ConfigLoader -->|provides config| StatCollector

    CoreService -->|orchestrates| RPCHandler

    RPCHandler -->|auth check| AuthService
    RPCHandler -->|read/write| StoreInterface
    RPCHandler -->|register/update| IndexEngine
    RPCHandler -->|record delete| DeleteLog
    RPCHandler -->|collect metrics| StatCollector

    StoreInterface -->|adapter| S3Store
    StoreInterface -->|adapter| FileDevStore
    StoreInterface -->|adapter| MockStore

    S3Store -->|S3 API| S3
    FileDevStore -->|local FS| S3
    MockStore -->|in-memory| S3

    IndexEngine -->|pub/sub| RedisProvider
    RedisProvider -->|Redis Pub/Sub| Redis

    click CLI_Filenode "https://github.com/anyproto/any-sync-filenode/blob/main/cmd/filenode.go"
    click CLI_Store "https://github.com/anyproto/any-sync-filenode/blob/main/cmd/store.go"
    click CLI_StoreDev "https://github.com/anyproto/any-sync-filenode/blob/main/cmd/store_dev.go"
    click ConfigLoader "https://github.com/anyproto/any-sync-filenode/blob/main/config/config.go"
    click CoreService "https://github.com/anyproto/any-sync-filenode/blob/main/filenode/filenode.go"
    click RPCHandler "https://github.com/anyproto/any-sync-filenode/blob/main/filenode/rpchandler.go"
    click StoreInterface "https://github.com/anyproto/any-sync-filenode/blob/main/store/store.go"
    click S3Store "https://github.com/anyproto/any-sync-filenode/blob/main/store/s3store/s3store.go"
    click FileDevStore "https://github.com/anyproto/any-sync-filenode/blob/main/store/filedevstore/filedevstore.go"
    click MockStore "https://github.com/anyproto/any-sync-filenode/blob/main/store/mock_store/mock_store.go"
    click IndexEngine "https://github.com/anyproto/any-sync-filenode/blob/main/index/index.go"
    click RedisProvider "https://github.com/anyproto/any-sync-filenode/blob/main/redisprovider/redisprovider.go"
    click DeleteLog "https://github.com/anyproto/any-sync-filenode/blob/main/deletelog/deletelog.go"
    click AuthService "https://github.com/anyproto/any-sync-filenode/blob/main/account/service.go"
    click StatCollector "https://github.com/anyproto/any-sync-filenode/blob/main/stat/stat.go"

    classDef cli fill:#FFD700,stroke:#333,stroke-width:1px
    classDef config fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef service fill:#98FB98,stroke:#333,stroke-width:1px
    classDef adapter fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
