# atharmohammad/solana-file-sharing-system architecture

> Architecture diagram of the GitHub repository atharmohammad/solana-file-sharing-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atharmohammad/solana-file-sharing-system
- Repository: https://github.com/atharmohammad/solana-file-sharing-system

## Overview

##### Project Type and Purpose
- This is a full-stack decentralized application (dApp) that enables anonymous, verifiable file sharing by combining:
- A React-based web frontend (“app” directory)
- An IPFS client frontend (“ipfs” directory)
- A Solana on-chain program written with Anchor (“programs/solana_file_sharing_system”)
- Deployment scripts/migrations (in “migrations”)
- End-to-end tests (“tests”)

##### High-Level Architecture Components
- Frontend (React)
- UI for file upload, wallet connection, file listing
- Uses Solana wallet adapter and Anchor-generated IDL
- Communicates with IPFS and Solana RPC
- IPFS Client (React)
- Standalone interface demonstrating plain IPFS integration
- Solana Program (On-chain)
- Rust/Anchor smart contract for tracking file metadata (hash, owner, timestamp) on Solana ledger
- IPFS Network (External Service)
- Distributed file storage; returns content-addressed CIDs for uploaded files
- Solana RPC Node (External Service)
- Provides JSON RPC API for reading/writing program accounts on Solana devnet/mainnet
- Migrations & Testing
- “migrations/deploy.js” orchestrates Anchor deploy
- “tests/solana_file_sharing_system.js” runs automated integration tests

##### Relationships & Data Flows
- User loads Web App → connects wallet via Solana wallet adapter
- On Upload:
1. Frontend sends file bytes to IPFS node → receives content CID
2. Frontend calls Solana program method (e.g., “add_file”) passing CID & metadata → transaction sent to Solana RPC
3. Solana program stores metadata in on-chain account
- On List/Read:
1. Frontend queries Solana accounts for stored file list
2. Retrieves each CID → fetches file from IPFS public gateway
- Tests: simulate above flows using Anchor & local test validator

##### Architectural Patterns & Design Principles
- Separation of concerns: UI, storage layer (IPFS), ledger layer (Solana program)
- Content addressing for immutability (IPFS)
- Transactional consistency and cryptographic verification (Solana)
- Modular code generation: Anchor IDL generates client bindings in React

##### Technologies & Frameworks
- React, TypeScript (app/)
- JavaScript (ipfs/)
- Anchor framework, Rust (programs/)
- IPFS client library (js-ipfs or related)
- Solana CLI & Anchor CLI for builds/deployments
- Netlify (or static host) for app deployment

- UI (blue), External services (green), On-chain components (orange), Dev tooling (gray)

## Diagram (Mermaid)

```mermaid
graph TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        User["Web Browser (User)"]:::ui
        Wallet["Solana Wallet Adapter"]:::ui
        ReactApp["React App"]:::ui
    end

    %% Storage Layer
    subgraph "Storage Layer"
        direction TB
        IPFSNetwork["IPFS Network"]:::external
    end

    %% Blockchain Layer
    subgraph "Blockchain Layer"
        direction TB
        SolanaRPC["Solana RPC Node"]:::external
        OnChainProgram["Solana On-chain Program"]:::onchain
        SolanaAccounts["Solana Accounts (Metadata)"]:::onchain
    end

    %% Dev Tooling
    subgraph "Dev Tooling"
        direction TB
        Migrations["Migrations / Deploy Script"]:::dev
        Tests["End-to-End Tests"]:::dev
        AnchorConfig["Anchor Configuration"]:::dev
    end

    %% Interactions
    User -->|"connect"| Wallet
    Wallet -->|"wallet auth"| ReactApp
    ReactApp -->|"POST /api/v0/add"| IPFSNetwork
    IPFSNetwork -->|"CID"| ReactApp
    ReactApp -->|"sendTransaction(add_file)"| SolanaRPC
    SolanaRPC -->|"invoke"| OnChainProgram
    OnChainProgram -->|"store metadata"| SolanaAccounts
    ReactApp -->|"JSON-RPC query"| SolanaRPC
    SolanaRPC -->|"accounts data"| ReactApp

    %% Dev Flows
    Migrations -->|"anchor deploy"| SolanaRPC
    Tests -->|"run test flows"| OnChainProgram
    Tests -->|"local validator"| SolanaRPC
    AnchorConfig -.-> ReactApp

    %% Click Events
    click ReactApp "https://github.com/atharmohammad/solana-file-sharing-system/tree/master/app/"
    click IPFSNetwork "https://github.com/atharmohammad/solana-file-sharing-system/tree/master/ipfs/"
    click OnChainProgram "https://github.com/atharmohammad/solana-file-sharing-system/tree/master/programs/solana_file_sharing_system/"
    click Migrations "https://github.com/atharmohammad/solana-file-sharing-system/blob/master/migrations/deploy.js"
    click Tests "https://github.com/atharmohammad/solana-file-sharing-system/blob/master/tests/solana_file_sharing_system.js"
    click AnchorConfig "https://github.com/atharmohammad/solana-file-sharing-system/blob/master/Anchor.toml"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6,color:#000
    classDef external fill:#DFFFE0,stroke:#22863a,color:#000
    classDef onchain fill:#FFE6B3,stroke:#d18616,color:#000
    classDef dev fill:#E0E0E0,stroke:#6a737d,color:#000
```
