# tj7181857-lab/trustfix-blockchain-based architecture

> Architecture diagram of the GitHub repository tj7181857-lab/trustfix-blockchain-based, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tj7181857-lab/trustfix-blockchain-based
- Repository: https://github.com/tj7181857-lab/trustfix-blockchain-based

## Overview

TrustTix is a multi-event NFT ticketing application: attendees connect a wallet, browse events, purchase tickets on-chain, and present tickets for gate verification; organizers create/manage events and monitor sales and heuristic risk signals. The graph distinguishes wallet and contract interaction, backend log indexing and analytics, and the separate buyer, organizer, and gate experiences. Relationships are grounded in the excerpts and README; a few live/API links are documented at a high level rather than shown end-to-end in sampled code.

Main entry points: [`client/src/App.jsx`](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/App.jsx) (Role-based app), [`server/index.js`](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/index.js) (API and socket server), [`contracts/TrustTixMultiEvent.sol`](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/contracts/TrustTixMultiEvent.sol) (Multi-event NFT contract), [`client/src/views/BuyerView.jsx`](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/BuyerView.jsx) (Event browsing and purchase)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_app["Role-based app<br/>[App.jsx]"]
  node_buyer["Event browsing and purchase<br/>[BuyerView.jsx]"]
  node_organizer_view["Organizer dashboard<br/>[OrganizerView.jsx]"]
  node_gate_view["Gate verification<br/>[GateView.jsx]"]
end

subgraph group_wallet["Wallet and chain access"]
  node_wallet_hook["Wallet connection<br/>[useWallet.js]"]
  node_contract_hook["Contract access<br/>[useContract.js]"]
  node_socket_hook["Live updates<br/>[useSocket.js]"]
end

subgraph group_ticketing["On-chain ticketing"]
  node_contract["Multi-event NFT contract"]
  node_chain[("Hardhat chain")]
end

subgraph group_monitoring["Monitoring backend"]
  node_api["API and socket server<br/>[index.js]"]
  node_listener["Purchase log indexer<br/>[chainListener.js]"]
end

subgraph group_insights["Analytics and risk"]
  node_risk["Heuristic risk engine<br/>[riskEngine.js]"]
  node_analytics["Event analytics<br/>[analytics.js]"]
end

node_attendee(("Attendee"))
node_organizer(("Organizer"))
node_gate_staff(("Gate staff"))

node_attendee -->|"uses"| node_app
node_organizer -->|"uses"| node_app
node_gate_staff -->|"verifies tickets"| node_app
node_app -->|"connects wallet"| node_wallet_hook
node_app -->|"subscribes updates"| node_socket_hook
node_app -->|"creates reader"| node_contract_hook
node_app -->|"routes attendees"| node_buyer
node_app -->|"routes organizers"| node_organizer_view
node_app -->|"routes gate"| node_gate_view
node_wallet_hook -->|"connects via MetaMask"| node_chain
node_buyer -->|"creates contract access"| node_contract_hook
node_buyer -->|"reads and buys tickets"| node_contract
node_organizer_view -->|"creates contract access"| node_contract_hook
node_gate_view -->|"checks and uses tickets"| node_contract
node_contract -->|"stores ticket state"| node_chain
node_api -->|"reads event state"| node_contract
node_api -.->|"starts indexer"| node_listener
node_listener -->|"replays purchase logs"| node_contract
node_listener -->|"records purchases"| node_risk
node_api -->|"builds analytics response"| node_analytics
node_api -->|"reads risk results"| node_risk
node_organizer_view -->|"requests analytics"| node_api
node_buyer -.->|"loads event data"| node_api
node_socket_hook -.->|"receives live events"| node_api
node_api -.->|"pushes updates"| node_socket_hook

click node_app "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/App.jsx"
click node_buyer "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/BuyerView.jsx"
click node_organizer_view "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/OrganizerView.jsx"
click node_gate_view "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/GateView.jsx"
click node_wallet_hook "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/hooks/useWallet.js"
click node_contract_hook "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/hooks/useContract.js"
click node_socket_hook "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/hooks/useSocket.js"
click node_contract "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/contracts/TrustTixMultiEvent.sol"
click node_api "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/index.js"
click node_listener "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/chainListener.js"
click node_risk "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/riskEngine.js"
click node_analytics "https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/analytics.js"

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_app,node_buyer,node_organizer_view,node_gate_view toneBlue
class node_wallet_hook,node_contract_hook,node_socket_hook toneAmber
class node_contract,node_chain toneMint
class node_api,node_listener toneRose
class node_risk,node_analytics,node_attendee,node_organizer,node_gate_staff toneIndigo
```

## Components

### Web experience

- [Role-based app](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Event browsing and purchase](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/BuyerView.jsx): `client/src/views/BuyerView.jsx`
- [Organizer dashboard](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/OrganizerView.jsx): `client/src/views/OrganizerView.jsx`
- [Gate verification](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/views/GateView.jsx): `client/src/views/GateView.jsx`

### Wallet and chain access

- [Wallet connection](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/hooks/useWallet.js): `client/src/hooks/useWallet.js`
- [Contract access](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/hooks/useContract.js): `client/src/hooks/useContract.js`
- [Live updates](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/client/src/hooks/useSocket.js): `client/src/hooks/useSocket.js`

### On-chain ticketing

- [Multi-event NFT contract](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/contracts/TrustTixMultiEvent.sol): `contracts/TrustTixMultiEvent.sol`
- **Hardhat chain**

### Monitoring backend

- [API and socket server](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/index.js): `server/index.js`
- [Purchase log indexer](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/chainListener.js): `server/chainListener.js`

### Analytics and risk

- [Heuristic risk engine](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/riskEngine.js): `server/riskEngine.js`
- [Event analytics](https://github.com/tj7181857-lab/trustfix-blockchain-based/blob/main/server/analytics.js): `server/analytics.js`

### Other components

- **Attendee**
- **Organizer**
- **Gate staff**

## Connections

- Attendee → Role-based app: uses (evidence: `README.md`)
- Organizer → Role-based app: uses (evidence: `README.md`)
- Gate staff → Role-based app: verifies tickets (evidence: `README.md`)
- Role-based app → Wallet connection: connects wallet (evidence: `client/src/App.jsx`)
- Role-based app → Live updates: subscribes updates (evidence: `client/src/App.jsx`)
- Role-based app → Contract access: creates reader (evidence: `client/src/App.jsx`)
- Role-based app → Event browsing and purchase: routes attendees (evidence: `client/src/App.jsx`)
- Role-based app → Organizer dashboard: routes organizers (evidence: `client/src/App.jsx`)
- Role-based app → Gate verification: routes gate (evidence: `client/src/App.jsx`)
- Wallet connection → Hardhat chain: connects via MetaMask (evidence: `client/src/hooks/useWallet.js`)
- Event browsing and purchase → Contract access: creates contract access (evidence: `client/src/views/BuyerView.jsx`)
- Event browsing and purchase → Multi-event NFT contract: reads and buys tickets (evidence: `client/src/views/BuyerView.jsx`)
- Organizer dashboard → Contract access: creates contract access (evidence: `client/src/views/OrganizerView.jsx`)
- Gate verification → Multi-event NFT contract: checks and uses tickets (evidence: `README.md`)
- Multi-event NFT contract → Hardhat chain: stores ticket state (evidence: `README.md`)
- API and socket server → Multi-event NFT contract: reads event state (evidence: `server/index.js`)
- API and socket server → Purchase log indexer: starts indexer (evidence: `server/index.js`)
- Purchase log indexer → Multi-event NFT contract: replays purchase logs (evidence: `server/chainListener.js`)
- Purchase log indexer → Heuristic risk engine: records purchases (evidence: `server/chainListener.js`)
- API and socket server → Event analytics: builds analytics response (evidence: `server/index.js`)
- API and socket server → Heuristic risk engine: reads risk results (evidence: `server/index.js`)
- Organizer dashboard → API and socket server: requests analytics (evidence: `client/src/views/OrganizerView.jsx`)
- Event browsing and purchase → API and socket server: loads event data
- Live updates → API and socket server: receives live events
- API and socket server → Live updates: pushes updates
