# syeo66/ship-my-stuff architecture

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

- Interactive diagram: https://gitdiagram.com/syeo66/ship-my-stuff
- Repository: https://github.com/syeo66/ship-my-stuff

## Overview

##### Main Components

A. Frontend Layer:
- React/JavaScript application (evident from the src/lib/components structure)
- Web3 connector interface
- IPFS integration for data storage
- User interface components (forms, lists, messages)

B. Smart Contract Layer:
- Registry Contract (manages contract versions)
- TransportMarket Contract (main business logic)
- Supporting Contracts (Ownable, Mortal, Haltable, etc.)

C. External Services:
- Ethereum Network (Rinkeby/Ropsten)
- IPFS Network
- MetaMask/Web3 Provider

##### Component Relationships

**User Interface ←→ Web3 Connector ←→ Smart Contracts ←→ Blockchain**
- ↓
- IPFS

##### Detailed Component Breakdown

Frontend Layer:

- User Interface     |
- ParcelList         |
- CreateParcelForm   |
- ReceivedParcelForm |
- AccountData        |
- NetworkIndicator   |

- ↓

- Web3 Connector     |

Smart Contract Layer:

- Registry Contract    |
- (Version Control)   |

- ↓

- TransportMarket        |
- Parcel Management   |
- Payment Handling    |
- State Management    |

External Services Layer:

- Ethereum Network     |

- ↕

- IPFS Storage       |

##### Key Flows to Highlight

- User interactions with the frontend
- Data flow between frontend and smart contracts
- Storage of parcel details in IPFS
- Contract interactions with the blockchain
- Payment flows

##### Additional Elements

Annotations for:
- Smart contract inheritance (Ownable, Mortal, etc.)
- Security measures
- IPFS hash storage mechanism
- Contract deprecation flow

##### Technical Details to Note

- Web3 integration points
- MetaMask connection
- IPFS integration points
- Contract upgrade paths through Registry

Remember to include notes about:
- CORS requirements for IPFS
- MetaMask integration
- Contract versioning through Registry
- Security considerations

This will provide a comprehensive view of the system while maintaining clarity about the key architectural decisions and components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef contract fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        UI["User Interface"]
        PL["Parcel List"]
        CPF["Create Parcel Form"]
        RPF["Receive Parcel Form"]
        AD["Account Data"]
        NI["Network Indicator"]
        MSG["Message Dialog"]
        APP["Main App"]
        W3C["Web3 Connector"]
    end

    %% Smart Contract Layer
    subgraph Contracts
        REG["Registry Contract"]
        TM["TransportMarket"]
        OWN["Ownable"]
        MOR["Mortal"]
        HAL["Haltable"]
    end

    %% External Services Layer
    subgraph External
        ETH["Ethereum Network"]
        IPFS["IPFS Storage"]
        META["MetaMask"]
    end

    %% Relationships
    UI --> PL & CPF & RPF & AD & NI
    PL & CPF & RPF & AD & NI --> APP
    APP --> W3C
    APP --> MSG
    W3C --> REG
    REG --> TM
    TM --> OWN & MOR & HAL
    W3C --> META
    META --> ETH
    W3C --> IPFS

    %% Component Styling
    class UI,PL,CPF,RPF,AD,NI,MSG,APP,W3C frontend
    class REG,TM,OWN,MOR,HAL contract
    class ETH,IPFS,META external

    %% Click Events
    click W3C "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/web3connector.js"
    click PL "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/components/parcel_list.js"
    click CPF "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/components/create_parcel_form.js"
    click RPF "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/components/received_parcel_form.js"
    click AD "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/components/account_data.js"
    click NI "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/components/network_indicator.js"
    click MSG "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/message_dialog.js"
    click APP "https://github.com/syeo66/ship-my-stuff/blob/master/src/lib/app.js"
    click REG "https://github.com/syeo66/ship-my-stuff/blob/master/build/contracts/Registry.json"
    click TM "https://github.com/syeo66/ship-my-stuff/blob/master/build/contracts/TransportMarket.json"
    click OWN "https://github.com/syeo66/ship-my-stuff/blob/master/build/contracts/Ownable.json"
    click MOR "https://github.com/syeo66/ship-my-stuff/blob/master/build/contracts/Mortal.json"
    click HAL "https://github.com/syeo66/ship-my-stuff/blob/master/build/contracts/Haltable.json"
```
