# ayushpal-abes/soda-vending-machine architecture

> Architecture diagram of the GitHub repository ayushpal-abes/soda-vending-machine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushpal-abes/soda-vending-machine
- Repository: https://github.com/ayushpal-abes/soda-vending-machine

## Overview

This is a React/Ethers dapp for operating a soda vending machine on Sepolia. A user connects a MetaMask wallet, views price and stock, then submits a purchase; owners can replenish stock, change the price, and withdraw funds. The frontend talks to separate vending-machine and price contracts, while generated TypeChain bindings provide a typed contract interface. Contract implementation details and some frontend calls were not sampled, so those capability links rely on the README rather than inspected call sites.

Main entry points: [`frontend/src/main.jsx`](https://github.com/ayushpal-abes/soda-vending-machine/blob/main/frontend/src/main.jsx) (Vending interface), [`contracts/vendingMachine.sol`](https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/vendingMachine.sol) (Vending machine), [`types/ethers-contracts`](https://github.com/ayushpal-abes/soda-vending-machine/tree/main/types/ethers-contracts) (Typed contract interfaces), [`types/ethers-contracts/factories`](https://github.com/ayushpal-abes/soda-vending-machine/tree/main/types/ethers-contracts/factories) (Contract factories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dapp interface"]
  node_frontend["Vending interface<br/>[main.jsx]"]
end

subgraph group_chain["Smart contracts"]
  node_machine["Vending machine<br/>[vendingMachine.sol]"]
  node_vendor["Soda pricing<br/>[sodaVendor.sol]"]
  node_oracle["Price oracle interface<br/>[IoraclePrice.sol]"]
end

subgraph group_bindings["Contract bindings"]
  node_typed["Typed contract interfaces"]
  node_factories["Contract factories"]
end

node_user(("Dapp user"))
node_wallet["MetaMask wallet"]
node_sepolia[("Sepolia network")]

node_user -->|"uses"| node_frontend
node_frontend -->|"connects wallet"| node_wallet
node_frontend -->|"reads machine state"| node_machine
node_frontend -->|"reads price"| node_vendor
node_frontend -.->|"purchases, stocks, withdraws"| node_machine
node_frontend -->|"sets price"| node_vendor
node_wallet -->|"signs transactions"| node_sepolia
node_frontend -->|"targets network"| node_sepolia
node_machine -.->|"uses price interface"| node_oracle
node_typed -->|"exports factories"| node_factories
node_factories -->|"builds contract interfaces"| node_typed

click node_frontend "https://github.com/ayushpal-abes/soda-vending-machine/blob/main/frontend/src/main.jsx"
click node_machine "https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/vendingMachine.sol"
click node_vendor "https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/sodaVendor.sol"
click node_oracle "https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/IoraclePrice.sol"
click node_typed "https://github.com/ayushpal-abes/soda-vending-machine/tree/main/types/ethers-contracts"
click node_factories "https://github.com/ayushpal-abes/soda-vending-machine/tree/main/types/ethers-contracts/factories"

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_frontend,node_user toneBlue
class node_machine,node_vendor,node_oracle,node_sepolia toneAmber
class node_typed,node_factories toneMint
class node_wallet toneIndigo
```

## Components

### Dapp interface

- [Vending interface](https://github.com/ayushpal-abes/soda-vending-machine/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Smart contracts

- [Vending machine](https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/vendingMachine.sol): `contracts/vendingMachine.sol`
- [Soda pricing](https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/sodaVendor.sol): `contracts/sodaVendor.sol`
- [Price oracle interface](https://github.com/ayushpal-abes/soda-vending-machine/blob/main/contracts/IoraclePrice.sol): `contracts/IoraclePrice.sol`

### Contract bindings

- [Typed contract interfaces](https://github.com/ayushpal-abes/soda-vending-machine/tree/main/types/ethers-contracts): `types/ethers-contracts`
- [Contract factories](https://github.com/ayushpal-abes/soda-vending-machine/tree/main/types/ethers-contracts/factories): `types/ethers-contracts/factories`

### Other components

- **Dapp user**
- **MetaMask wallet**
- **Sepolia network**

## Connections

- Dapp user → Vending interface: uses (evidence: `README.md`)
- Vending interface → MetaMask wallet: connects wallet (evidence: `frontend/src/main.jsx`)
- Vending interface → Vending machine: reads machine state (evidence: `frontend/src/main.jsx`)
- Vending interface → Soda pricing: reads price (evidence: `frontend/src/main.jsx`)
- Vending interface → Vending machine: purchases, stocks, withdraws
- Vending interface → Soda pricing: sets price (evidence: `frontend/src/main.jsx`)
- MetaMask wallet → Sepolia network: signs transactions (evidence: `README.md`)
- Vending interface → Sepolia network: targets network (evidence: `frontend/src/main.jsx`)
- Vending machine → Price oracle interface: uses price interface
- Typed contract interfaces → Contract factories: exports factories (evidence: `types/ethers-contracts/index.ts`)
- Contract factories → Typed contract interfaces: builds contract interfaces (evidence: `types/ethers-contracts/factories/VendingMachine__factory.ts`)
