# dappforce/subsocial architecture

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

- Interactive diagram: https://gitdiagram.com/dappforce/subsocial
- Repository: https://github.com/dappforce/subsocial

## Overview

##### Main Components

a) Blockchain Layer
- Substrate-based Node
- Social networking modules/pallets
- Core blockchain functionality

b) Off-chain Storage Layer
- IPFS integration for content storage
- PostgreSQL database for feeds/notifications
- ElasticSearch for full-text search

c) Client Layer
- Web UI (React-based frontend)
- Mobile responsive interface
- JavaScript SDK

d) Integration Layer
- API interfaces
- Polkadot API libraries
- SDK connections

e) Infrastructure Layer
- Docker containerization
- Deployment services

**[Client Layer]**
- ↕
**[Integration Layer]**
- ↕
**[Blockchain Layer] ←→ [Off-chain Storage Layer]**
- ↕
**[Infrastructure Layer]**

##### Specific Component Relationships

- Data flow between Web UI and Blockchain Node
- Content storage flow to IPFS
- Search queries to ElasticSearch
- Feed generation flow through PostgreSQL
- SDK interactions with various components

##### Key Technical Elements to Highlight

- Substrate Framework integration
- IPFS distributed storage
- PostgreSQL for social features
- ElasticSearch for search functionality
- React/TypeScript frontend
- Docker containerization

##### Additional Details

Annotations for:
- Web3 Foundation integration points
- Social networking features (blogs, posts, comments, etc.)
- Search and indexing mechanisms
- Feed generation and notification systems

##### Implementation Notes

- Decentralized nature of the system
- Separation of concerns between on-chain and off-chain storage
- Scalability considerations
- Mobile-first approach in UI layer

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef blockchain fill:#a8d1f0,stroke:#333
    classDef storage fill:#90EE90,stroke:#333
    classDef client fill:#FFB347,stroke:#333
    classDef integration fill:#DDA0DD,stroke:#333
    classDef infrastructure fill:#D3D3D3,stroke:#333

    %% Client Layer
    subgraph ClientLayer
        WebUI["Web UI (React/TypeScript)"]
        MobileUI["Mobile Responsive Interface"]
        JSSDK["JavaScript SDK"]
    end

    %% Integration Layer
    subgraph IntegrationLayer
        API["API Interfaces"]
        PolkadotLib["Polkadot API Libraries"]
        SDKConn["SDK Connections"]
    end

    %% Blockchain Layer
    subgraph BlockchainLayer
        SubstrateNode["Substrate Node"]
        SocialModules["Social Networking Pallets"]
        CoreBC["Core Blockchain"]
    end

    %% Off-chain Storage Layer
    subgraph StorageLayer
        IPFS["IPFS Storage"]
        PostgreSQL["PostgreSQL Database"]
        ElasticSearch["ElasticSearch"]
    end

    %% Infrastructure Layer
    subgraph InfrastructureLayer
        Docker["Docker Containers"]
        Deployment["Deployment Services"]
    end

    %% Relationships
    WebUI --> API
    MobileUI --> API
    JSSDK --> API
    API --> PolkadotLib
    PolkadotLib --> SubstrateNode
    SDKConn --> SubstrateNode
    SubstrateNode --> SocialModules
    SocialModules --> CoreBC
    SubstrateNode --> IPFS
    SubstrateNode --> PostgreSQL
    PostgreSQL --> ElasticSearch
    Docker --> SubstrateNode
    Docker --> IPFS
    Docker --> PostgreSQL
    Docker --> ElasticSearch
    Deployment --> Docker

    %% Style Applications
    class SubstrateNode,SocialModules,CoreBC blockchain
    class IPFS,PostgreSQL,ElasticSearch storage
    class WebUI,MobileUI,JSSDK client
    class API,PolkadotLib,SDKConn integration
    class Docker,Deployment infrastructure

    %% Legend
    subgraph Legend
        L1["Blockchain Components"]:::blockchain
        L2["Storage Components"]:::storage
        L3["Client Components"]:::client
        L4["Integration Components"]:::integration
        L5["Infrastructure Components"]:::infrastructure
    end
```
