# aadyatalreja/shipment-service architecture

> Architecture diagram of the GitHub repository aadyatalreja/shipment-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aadyatalreja/shipment-service
- Repository: https://github.com/aadyatalreja/shipment-service

## Overview

1. This repository is a two-part DApp: a Solidity smart-contract backend and a React frontend. The core business state lives on Ethereum, while the browser app is only a client that reads chain data and submits transactions.

2. The on-chain subsystem is under `solidity/`. It contains the shipment-order contract implementation, Hardhat configuration, a deployment module, and test scaffolding. This is the authoritative layer for order lifecycle logic such as creation, shipping, acceptance, cancellation, and stage-based queries.

3. Deployment is handled through Hardhat Ignition in `solidity/ignition/modules/ShipmentService.js`. The presence of deployment artifacts under `solidity/ignition/deployments/chain-11155111/` shows the contract has been deployed to Sepolia, and the repo retains the resulting addresses and build metadata.

4. The Solidity project also includes compiled/generated outputs in `artifacts/`, `cache/`, and `dist/`. These are build-time boundaries rather than application logic, and they support local compilation, testing, and redeployment.

5. The frontend subsystem lives in `frontend/` and is a standard React app. `frontend/src/App.js` is the main UI entry point, with `public/` providing the static shell and `src/index.js` bootstrapping the application into the browser.

6. Frontend-to-chain integration is the key data flow boundary. The README indicates `App.js` contains the deployed contract address, and `frontend/src/utils/ShipmentService.json` holds the contract artifact/ABI copied from the Solidity build. That file is what lets the React app encode contract calls and decode returned data.

7. The runtime interaction pattern is: user action in the React UI -> web3 call from the browser -> transaction or read against the Ethereum network -> contract state change or query -> updated shipment/order information returned to the UI. Because the logic is on-chain, persistence, authorization, and state transitions are not duplicated in the frontend.

8. Contract ownership is an important architectural boundary. The README says the contract owner can mark shipments as shipped and inspect packages by stage, while customers can create orders, accept deliveries with OTPs, and cancel only while processing. That implies role-sensitive access control is enforced in Solidity, not in UI code.

9. The repository is designed around Sepolia as the primary external network. Environment variables in `solidity/.env` and the Hardhat instructions show deployment depends on an RPC provider key and a private key, so the blockchain network is an external infrastructure dependency.

10. Testing is split by layer. `solidity/test/` covers smart-contract behavior with Hardhat tests, while `frontend/src/App.test.js` and `setupTests.js` provide basic React-side testing. This separation matches the architecture: contract correctness is validated independently of the browser client.

11. `documentation/` contains presentation and report assets rather than runtime components. Those files are useful for understanding intended system behavior, but they do not participate in execution.

12. In diagram terms, the main boundaries are: browser UI, contract integration layer, Ethereum/Sepolia network, and the deployment/tooling layer. The only persistent source of truth is the smart contract state on-chain; the React app and generated JSON artifacts are supporting clients and build-time bridges.

Main entry points: [`solidity/contracts`](https://github.com/aadyatalreja/shipment-service/tree/main/solidity/contracts) (Shipment contract), [`frontend/src/App.js`](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/App.js) (App UI), [`frontend/src/utils/ShipmentService.json`](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/utils/ShipmentService.json) (Contract ABI), [`solidity/ignition/modules/ShipmentService.js`](https://github.com/aadyatalreja/shipment-service/blob/main/solidity/ignition/modules/ShipmentService.js) (Ignition module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_ui["App UI<br/>React entry<br/>[App.js]"]
  node_bootstrap["Bootstrap<br/>React start<br/>[index.js]"]
  node_contractabi["Contract ABI<br/>artifact JSON"]
  node_publicshell["Public shell<br/>static assets<br/>[index.html]"]
  node_reacttests["UI tests<br/>React tests<br/>[App.test.js]"]
end

subgraph group_solidity["Solidity"]
  node_contract[("Shipment contract<br/>Solidity state")]
  node_hardhat["Hardhat config<br/>tooling<br/>[hardhat.config.js]"]
  node_module["Ignition module<br/>deploy module<br/>[ShipmentService.js]"]
  node_deployments["Sepolia deploy<br/>deployment state"]
  node_artifacts["Build artifacts<br/>compiled output"]
  node_cache["Compiler cache<br/>build cache"]
  node_bundle["Bundle<br/>built output<br/>[bundle.js]"]
  node_tests["Contract tests<br/>Hardhat tests<br/>[Lock.js]"]
  node_env["Env config<br/>secrets config<br/>[.env]"]
end

subgraph group_network["Network"]
  node_sepolia(("Sepolia<br/>Ethereum network"))
end

subgraph group_docs["Docs"]
  node_docs["Reports<br/>presentation assets"]
end

node_bootstrap -->|"loads"| node_ui
node_publicshell -->|"hosts"| node_bootstrap
node_ui -->|"uses"| node_contractabi
node_ui -->|"reads/writes"| node_sepolia
node_contractabi -->|"encodes"| node_contract
node_contract -->|"stores state"| node_sepolia
node_hardhat -->|"compiles"| node_contract
node_module -->|"deploys"| node_contract
node_module -->|"uses"| node_env
node_env -->|"targets"| node_sepolia
node_deployments -->|"records"| node_sepolia
node_artifacts -->|"feeds"| node_contractabi
node_cache -->|"supports"| node_artifacts
node_bundle -->|"builds from"| node_contract
node_tests -->|"verifies"| node_contract
node_reacttests -->|"verifies"| node_ui
node_docs -.->|"describes"| node_contract

click node_ui "https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/App.js"
click node_bootstrap "https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/index.js"
click node_contractabi "https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/utils/ShipmentService.json"
click node_publicshell "https://github.com/aadyatalreja/shipment-service/blob/main/frontend/public/index.html"
click node_contract "https://github.com/aadyatalreja/shipment-service/tree/main/solidity/contracts"
click node_hardhat "https://github.com/aadyatalreja/shipment-service/blob/main/solidity/hardhat.config.js"
click node_module "https://github.com/aadyatalreja/shipment-service/blob/main/solidity/ignition/modules/ShipmentService.js"
click node_deployments "https://github.com/aadyatalreja/shipment-service/tree/main/solidity/ignition/deployments/chain-11155111"
click node_artifacts "https://github.com/aadyatalreja/shipment-service/tree/main/solidity/artifacts"
click node_cache "https://github.com/aadyatalreja/shipment-service/tree/main/solidity/cache"
click node_bundle "https://github.com/aadyatalreja/shipment-service/blob/main/solidity/dist/bundle.js"
click node_tests "https://github.com/aadyatalreja/shipment-service/blob/main/solidity/test/Lock.js"
click node_env "https://github.com/aadyatalreja/shipment-service/blob/main/solidity/.env"
click node_reacttests "https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/App.test.js"
click node_docs "https://github.com/aadyatalreja/shipment-service/tree/main/documentation"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_bootstrap,node_contractabi,node_publicshell,node_reacttests toneBlue
class node_contract,node_hardhat,node_module,node_deployments,node_artifacts,node_cache,node_bundle,node_tests,node_env toneAmber
class node_sepolia toneMint
class node_docs toneRose
```

## Components

### Frontend

React browser client and UI-side integration

- [App UI](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/App.js): React entry · Main browser interface and user actions · `frontend/src/App.js`
- [Bootstrap](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/index.js): React start · Mounts the app into the browser · `frontend/src/index.js`
- [Contract ABI](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/utils/ShipmentService.json): artifact JSON · Frontend copy of contract artifact used for calls · `frontend/src/utils/ShipmentService.json`
- [Public shell](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/public/index.html): static assets · HTML and static browser shell · `frontend/public/index.html`
- [UI tests](https://github.com/aadyatalreja/shipment-service/blob/main/frontend/src/App.test.js): React tests · Browser-side component and setup tests · `frontend/src/App.test.js`

### Solidity

On-chain contract, deployment, and build tooling

- [Shipment contract](https://github.com/aadyatalreja/shipment-service/tree/main/solidity/contracts): Solidity state · Authoritative shipment and order lifecycle logic · `solidity/contracts`
- [Hardhat config](https://github.com/aadyatalreja/shipment-service/blob/main/solidity/hardhat.config.js): tooling · Project config for compile, test, and deploy workflows · `solidity/hardhat.config.js`
- [Ignition module](https://github.com/aadyatalreja/shipment-service/blob/main/solidity/ignition/modules/ShipmentService.js): deploy module · Deploys the shipment service contract · `solidity/ignition/modules/ShipmentService.js`
- [Sepolia deploy](https://github.com/aadyatalreja/shipment-service/tree/main/solidity/ignition/deployments/chain-11155111): deployment state · Recorded deployed addresses and build metadata · `solidity/ignition/deployments/chain-11155111`
- [Build artifacts](https://github.com/aadyatalreja/shipment-service/tree/main/solidity/artifacts): compiled output · Compiled contract metadata for local tooling · `solidity/artifacts`
- [Compiler cache](https://github.com/aadyatalreja/shipment-service/tree/main/solidity/cache): build cache · Solidity compilation cache and file tracking · `solidity/cache`
- [Bundle](https://github.com/aadyatalreja/shipment-service/blob/main/solidity/dist/bundle.js): built output · Generated Solidity-side bundle output · `solidity/dist/bundle.js`
- [Contract tests](https://github.com/aadyatalreja/shipment-service/blob/main/solidity/test/Lock.js): Hardhat tests · Smart-contract behavior and lifecycle validation · `solidity/test/Lock.js`
- [Env config](https://github.com/aadyatalreja/shipment-service/blob/main/solidity/.env): secrets config · RPC and private-key settings for deployment · `solidity/.env`

### Network

External Ethereum/Sepolia dependency

- **Sepolia**: Ethereum network · External chain where contract state and transactions live

### Docs

Presentation and report assets

- [Reports](https://github.com/aadyatalreja/shipment-service/tree/main/documentation): presentation assets · Non-runtime documentation and presentation materials · `documentation`

## Connections

- Bootstrap → App UI: loads · Bootstraps the main React UI
- Public shell → Bootstrap: hosts · Provides the static browser shell
- App UI → Contract ABI: uses · Reads contract ABI and deployment details for web3 calls
- App UI → Sepolia: reads/writes · Submits transactions and queries on-chain state
- Contract ABI → Shipment contract: encodes · Matches the deployed contract interface
- Shipment contract → Sepolia: stores state · Shipment and order state live on chain
- Hardhat config → Shipment contract: compiles · Defines the Solidity build and project configuration
- Ignition module → Shipment contract: deploys · Deploys the shipment service implementation
- Ignition module → Env config: uses · Depends on deployment credentials and RPC settings
- Env config → Sepolia: targets · Configures deployment against the Sepolia network
- Sepolia deploy → Sepolia: records · Persists deployed contract addresses for Sepolia
- Build artifacts → Contract ABI: feeds · Provides generated ABI and build metadata to the frontend copy
- Compiler cache → Build artifacts: supports · Compilation cache supports generated outputs
- Bundle → Shipment contract: builds from · Generated bundle is derived from contract sources
- Contract tests → Shipment contract: verifies · Checks lifecycle behavior and access rules
- UI tests → App UI: verifies · Checks browser-side rendering and interactions
- Reports → Shipment contract: describes · Documents the intended shipment service behavior
