# datnguyen238/bartr architecture

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

- Interactive diagram: https://gitdiagram.com/datnguyen238/bartr
- Repository: https://github.com/datnguyen238/bartr

## Overview

Bartr is an AI-assisted bartering marketplace: members manage listings and preferences, discover compatible item bundles, then negotiate and confirm trades. The frontend calls a FastAPI marketplace API; its domain layer enforces identity, listing and trade rules over a selected repository. Storage can be DynamoDB or local JSON/memory, while image valuation and semantic discovery are optional provider-backed capabilities. README documents the major trade safeguards; unsampled route and service internals limit the edges shown here.

Main entry points: [`backend/app/api/marketplace.py`](https://github.com/datnguyen238/bartr/blob/main/backend/app/api/marketplace.py) (HTTP endpoints), [`backend/app/main.py`](https://github.com/datnguyen238/bartr/blob/main/backend/app/main.py) (Application setup), [`frontend/app/page.tsx`](https://github.com/datnguyen238/bartr/blob/main/frontend/app/page.tsx) (Marketplace pages), [`backend/app/services/search.py`](https://github.com/datnguyen238/bartr/blob/main/backend/app/services/search.py) (Semantic matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Member experience"]
  node_web["Marketplace pages<br/>[page.tsx]"]
  node_discovery["Bundle discovery<br/>[discovery.tsx]"]
  node_inventory["Inventory editing"]
  node_preferences["Preferences"]
  node_tradeui["Trade workspace"]
end

subgraph group_api["Marketplace API"]
  node_api["HTTP endpoints<br/>[marketplace.py]"]
  node_app["Application setup<br/>[main.py]"]
end

subgraph group_domain["Marketplace rules"]
  node_rules["Marketplace domain<br/>[domain.py]"]
end

subgraph group_services["AI and discovery"]
  node_semantic["Semantic matching<br/>[search.py]"]
  node_semanticstore["Semantic projections"]
  node_valuation["Image valuation<br/>[image_analysis.py]"]
end

subgraph group_storage["Persistence"]
  node_dynamo[("DynamoDB repository<br/>[dynamodb.py]")]
  node_state[("Local or Mongo state<br/>[state.py]")]
  node_images[("Image persistence<br/>[dynamodb_images.py]")]
end

node_member(("Member"))

node_member -->|"uses"| node_web
node_web -->|"requests API"| node_api
node_discovery -->|"loads matches"| node_api
node_inventory -.->|"manages listings"| node_api
node_preferences -.->|"saves preferences"| node_api
node_tradeui -.->|"manages offers"| node_api
node_app -->|"mounts routes"| node_api
node_app -->|"creates service"| node_rules
node_api -->|"invokes operations"| node_rules
node_app -->|"selects backend"| node_dynamo
node_app -->|"selects backend"| node_state
node_api -->|"analyzes image"| node_valuation
node_api -->|"indexes listings"| node_semantic
node_semantic -.->|"uses Dynamo variant"| node_semanticstore
node_dynamo -->|"inherits image storage"| node_images

click node_web "https://github.com/datnguyen238/bartr/blob/main/frontend/app/page.tsx"
click node_discovery "https://github.com/datnguyen238/bartr/blob/main/frontend/app/discover/_components/discovery.tsx"
click node_inventory "https://github.com/datnguyen238/bartr/blob/main/frontend/components/inventory/inventory-screen.tsx"
click node_preferences "https://github.com/datnguyen238/bartr/blob/main/frontend/components/profile/preferences-screen.tsx"
click node_tradeui "https://github.com/datnguyen238/bartr/blob/main/frontend/components/trade/trade-workspace.tsx"
click node_api "https://github.com/datnguyen238/bartr/blob/main/backend/app/api/marketplace.py"
click node_app "https://github.com/datnguyen238/bartr/blob/main/backend/app/main.py"
click node_rules "https://github.com/datnguyen238/bartr/blob/main/backend/app/domain.py"
click node_semantic "https://github.com/datnguyen238/bartr/blob/main/backend/app/services/search.py"
click node_semanticstore "https://github.com/datnguyen238/bartr/blob/main/backend/app/services/dynamodb_semantic.py"
click node_valuation "https://github.com/datnguyen238/bartr/blob/main/backend/app/services/image_analysis.py"
click node_dynamo "https://github.com/datnguyen238/bartr/blob/main/backend/app/storage/dynamodb.py"
click node_state "https://github.com/datnguyen238/bartr/blob/main/backend/app/storage/state.py"
click node_images "https://github.com/datnguyen238/bartr/blob/main/backend/app/storage/dynamodb_images.py"

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_web,node_discovery,node_inventory,node_preferences,node_tradeui toneBlue
class node_api,node_app toneAmber
class node_rules toneMint
class node_semantic,node_semanticstore,node_valuation toneRose
class node_dynamo,node_state,node_images,node_member toneIndigo
```

## Components

### Member experience

- [Marketplace pages](https://github.com/datnguyen238/bartr/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Bundle discovery](https://github.com/datnguyen238/bartr/blob/main/frontend/app/discover/_components/discovery.tsx): `frontend/app/discover/_components/discovery.tsx`
- [Inventory editing](https://github.com/datnguyen238/bartr/blob/main/frontend/components/inventory/inventory-screen.tsx): `frontend/components/inventory/inventory-screen.tsx`
- [Preferences](https://github.com/datnguyen238/bartr/blob/main/frontend/components/profile/preferences-screen.tsx): `frontend/components/profile/preferences-screen.tsx`
- [Trade workspace](https://github.com/datnguyen238/bartr/blob/main/frontend/components/trade/trade-workspace.tsx): `frontend/components/trade/trade-workspace.tsx`

### Marketplace API

- [HTTP endpoints](https://github.com/datnguyen238/bartr/blob/main/backend/app/api/marketplace.py): `backend/app/api/marketplace.py`
- [Application setup](https://github.com/datnguyen238/bartr/blob/main/backend/app/main.py): `backend/app/main.py`

### Marketplace rules

- [Marketplace domain](https://github.com/datnguyen238/bartr/blob/main/backend/app/domain.py): `backend/app/domain.py`

### AI and discovery

- [Semantic matching](https://github.com/datnguyen238/bartr/blob/main/backend/app/services/search.py): `backend/app/services/search.py`
- [Semantic projections](https://github.com/datnguyen238/bartr/blob/main/backend/app/services/dynamodb_semantic.py): `backend/app/services/dynamodb_semantic.py`
- [Image valuation](https://github.com/datnguyen238/bartr/blob/main/backend/app/services/image_analysis.py): `backend/app/services/image_analysis.py`

### Persistence

- [DynamoDB repository](https://github.com/datnguyen238/bartr/blob/main/backend/app/storage/dynamodb.py): `backend/app/storage/dynamodb.py`
- [Local or Mongo state](https://github.com/datnguyen238/bartr/blob/main/backend/app/storage/state.py): `backend/app/storage/state.py`
- [Image persistence](https://github.com/datnguyen238/bartr/blob/main/backend/app/storage/dynamodb_images.py): `backend/app/storage/dynamodb_images.py`

### Other components

- **Member**

## Connections

- Member → Marketplace pages: uses (evidence: `README.md`)
- Marketplace pages → HTTP endpoints: requests API (evidence: `README.md`)
- Bundle discovery → HTTP endpoints: loads matches (evidence: `frontend/app/discover/_components/discovery.tsx`)
- Inventory editing → HTTP endpoints: manages listings
- Preferences → HTTP endpoints: saves preferences
- Trade workspace → HTTP endpoints: manages offers
- Application setup → HTTP endpoints: mounts routes (evidence: `backend/app/main.py`)
- Application setup → Marketplace domain: creates service (evidence: `backend/app/main.py`)
- HTTP endpoints → Marketplace domain: invokes operations (evidence: `backend/app/api/marketplace.py`)
- Application setup → DynamoDB repository: selects backend (evidence: `backend/app/main.py`)
- Application setup → Local or Mongo state: selects backend (evidence: `backend/app/main.py`)
- HTTP endpoints → Image valuation: analyzes image (evidence: `README.md`)
- HTTP endpoints → Semantic matching: indexes listings (evidence: `backend/app/api/marketplace.py`)
- Semantic matching → Semantic projections: uses Dynamo variant
- DynamoDB repository → Image persistence: inherits image storage (evidence: `backend/app/storage/dynamodb.py`)
