# bincry/borrow-hub architecture

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

- Interactive diagram: https://gitdiagram.com/bincry/borrow-hub
- Repository: https://github.com/bincry/borrow-hub

## Overview

Borrow Hub is a peer-to-peer rental product with an Expo mobile client and NestJS API. The user journey is discovering rentable assets, requesting a rental, completing payment and handover, then reviewing the transaction; the API also supports messaging and operational workflows such as disputes, KYC, and administration. The graph preserves these documented product areas and highlights the sampled mobile API clients, API services, and persistence/storage layer. Several feature paths are documented but unsampled, so their internal call relationships are omitted or marked unverified.

Main entry points: [`apps/api/src/reviews/reviews.service.ts`](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/reviews/reviews.service.ts) (Reviews), [`apps/api/src/disputes/disputes.service.ts`](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/disputes/disputes.service.ts) (Disputes), [`apps/mobile/src/services/api/client.ts`](https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/api/client.ts) (HTTP client), [`apps/api/src/storage/storage.service.ts`](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/storage.service.ts) (File storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_routes["App screens"]
  node_mobile_rentals["Rental client<br/>[rentals.service.ts]"]
  node_admin_mobile["Admin client<br/>[admin.service.ts]"]
  node_api_client["HTTP client<br/>[client.ts]"]
  node_auth_store["Auth state<br/>[authStore.ts]"]
end

subgraph group_marketplace["Marketplace and rentals"]
  node_users["User accounts<br/>[users.service.ts]"]
  node_categories["Categories"]
  node_assets["Asset listings"]
  node_rentals["Rental lifecycle<br/>[rentals.service.ts]"]
  node_payments["Payments"]
end

subgraph group_trust["Trust and communication"]
  node_chat["Chat"]
  node_notifications["Notifications"]
  node_reviews["Reviews<br/>[reviews.service.ts]"]
  node_trust_score["Trust score"]
  node_kyc["KYC verification"]
end

subgraph group_operations["Operations"]
  node_finance["Finance"]
  node_disputes["Disputes"]
  node_admin["Admin operations<br/>[admin.service.ts]"]
  node_analytics["Analytics"]
  node_audit["Audit logs<br/>[audit.service.ts]"]
end

subgraph group_platform["API platform"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_storage_service["File storage<br/>[storage.service.ts]"]
  node_local_storage["Local provider"]
  node_minio_storage["MinIO provider"]
  node_database[("PostgreSQL<br/>[prisma.service.ts]")]
end

node_renter(("Renter / owner"))

node_renter -.->|"uses"| node_mobile_routes
node_mobile_routes -.->|"requests rentals"| node_mobile_rentals
node_mobile_rentals -->|"sends requests"| node_api_client
node_admin_mobile -->|"sends requests"| node_api_client
node_api_client -->|"reads tokens"| node_auth_store
node_api_client -->|"updates auth"| node_auth_store
node_mobile_rentals -.->|"calls API"| node_rentals
node_admin_mobile -.->|"calls API"| node_admin
node_rentals -.->|"persists rental data"| node_database
node_admin -->|"reads and writes"| node_database
node_admin -->|"records actions"| node_audit
node_rentals -.->|"coordinates payment"| node_payments
node_payments -.->|"supports finance"| node_finance
node_reviews -->|"recalculates score"| node_trust_score
node_disputes -->|"uses trust score"| node_trust_score
node_disputes -->|"notifies users"| node_notifications
node_disputes -->|"records events"| node_analytics
node_disputes -->|"records actions"| node_audit
node_reviews -->|"notifies users"| node_notifications
node_reviews -->|"records events"| node_analytics
node_reviews -->|"records moderation"| node_audit
node_storage_service -->|"delegates to"| node_local_storage
node_storage_service -->|"selects provider"| node_minio_storage
node_auth -->|"reads and writes"| node_database
node_auth -->|"records events"| node_analytics
node_kyc -.->|"stores documents"| node_storage_service
node_assets -.->|"stores listing images"| node_storage_service

click node_mobile_routes "https://github.com/bincry/borrow-hub/tree/main/apps/mobile/src/app"
click node_mobile_rentals "https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/rentals/rentals.service.ts"
click node_admin_mobile "https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/admin/admin.service.ts"
click node_api_client "https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/api/client.ts"
click node_auth_store "https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/store/authStore.ts"
click node_auth "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/auth/auth.service.ts"
click node_users "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/users/users.service.ts"
click node_categories "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/categories/categories.service.ts"
click node_assets "https://github.com/bincry/borrow-hub/tree/main/apps/api/src"
click node_rentals "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/rentals/rentals.service.ts"
click node_payments "https://github.com/bincry/borrow-hub/tree/main/apps/api/src/payment"
click node_finance "https://github.com/bincry/borrow-hub/tree/main/apps/api/src/finance"
click node_chat "https://github.com/bincry/borrow-hub/tree/main/apps/api/src/chat"
click node_notifications "https://github.com/bincry/borrow-hub/tree/main/apps/api/src/notifications"
click node_reviews "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/reviews/reviews.service.ts"
click node_trust_score "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/trust-score/trust-score.service.ts"
click node_kyc "https://github.com/bincry/borrow-hub/tree/main/apps/api/src/kyc"
click node_disputes "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/disputes/disputes.service.ts"
click node_admin "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/admin/admin.service.ts"
click node_analytics "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/analytics/analytics.service.ts"
click node_audit "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/audit/audit.service.ts"
click node_storage_service "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/storage.service.ts"
click node_local_storage "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/providers/local-storage.provider.ts"
click node_minio_storage "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/providers/minio-storage.provider.ts"
click node_database "https://github.com/bincry/borrow-hub/blob/main/apps/api/src/database/prisma.service.ts"

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_mobile_routes,node_mobile_rentals,node_admin_mobile,node_api_client,node_auth_store toneBlue
class node_users,node_categories,node_assets,node_rentals,node_payments toneAmber
class node_chat,node_notifications,node_reviews,node_trust_score,node_kyc toneMint
class node_finance,node_disputes,node_admin,node_analytics,node_audit toneRose
class node_auth,node_storage_service,node_local_storage,node_minio_storage,node_database,node_renter toneIndigo
```

## Components

### Mobile app

- [App screens](https://github.com/bincry/borrow-hub/tree/main/apps/mobile/src/app): `apps/mobile/src/app`
- [Rental client](https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/rentals/rentals.service.ts): `apps/mobile/src/services/rentals/rentals.service.ts`
- [Admin client](https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/admin/admin.service.ts): `apps/mobile/src/services/admin/admin.service.ts`
- [HTTP client](https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/services/api/client.ts): `apps/mobile/src/services/api/client.ts`
- [Auth state](https://github.com/bincry/borrow-hub/blob/main/apps/mobile/src/store/authStore.ts): `apps/mobile/src/store/authStore.ts`

### Marketplace and rentals

- [User accounts](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/users/users.service.ts): `apps/api/src/users/users.service.ts`
- [Categories](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/categories/categories.service.ts): `apps/api/src/categories/categories.service.ts`
- [Asset listings](https://github.com/bincry/borrow-hub/tree/main/apps/api/src): `apps/api/src`
- [Rental lifecycle](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/rentals/rentals.service.ts): `apps/api/src/rentals/rentals.service.ts`
- [Payments](https://github.com/bincry/borrow-hub/tree/main/apps/api/src/payment): `apps/api/src/payment`

### Trust and communication

- [Chat](https://github.com/bincry/borrow-hub/tree/main/apps/api/src/chat): `apps/api/src/chat`
- [Notifications](https://github.com/bincry/borrow-hub/tree/main/apps/api/src/notifications): `apps/api/src/notifications`
- [Reviews](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/reviews/reviews.service.ts): `apps/api/src/reviews/reviews.service.ts`
- [Trust score](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/trust-score/trust-score.service.ts): `apps/api/src/trust-score/trust-score.service.ts`
- [KYC verification](https://github.com/bincry/borrow-hub/tree/main/apps/api/src/kyc): `apps/api/src/kyc`

### Operations

- [Finance](https://github.com/bincry/borrow-hub/tree/main/apps/api/src/finance): `apps/api/src/finance`
- [Disputes](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/disputes/disputes.service.ts): `apps/api/src/disputes/disputes.service.ts`
- [Admin operations](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/admin/admin.service.ts): `apps/api/src/admin/admin.service.ts`
- [Analytics](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/analytics/analytics.service.ts): `apps/api/src/analytics/analytics.service.ts`
- [Audit logs](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/audit/audit.service.ts): `apps/api/src/audit/audit.service.ts`

### API platform

- [Authentication](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/auth/auth.service.ts): `apps/api/src/auth/auth.service.ts`
- [File storage](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/storage.service.ts): `apps/api/src/storage/storage.service.ts`
- [Local provider](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/providers/local-storage.provider.ts): `apps/api/src/storage/providers/local-storage.provider.ts`
- [MinIO provider](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/storage/providers/minio-storage.provider.ts): `apps/api/src/storage/providers/minio-storage.provider.ts`
- [PostgreSQL](https://github.com/bincry/borrow-hub/blob/main/apps/api/src/database/prisma.service.ts): `apps/api/src/database/prisma.service.ts`

### Other components

- **Renter / owner**

## Connections

- Renter / owner → App screens: uses
- App screens → Rental client: requests rentals
- Rental client → HTTP client: sends requests (evidence: `apps/mobile/src/services/rentals/rentals.service.ts`)
- Admin client → HTTP client: sends requests (evidence: `apps/mobile/src/services/admin/admin.service.ts`)
- HTTP client → Auth state: reads tokens (evidence: `apps/mobile/src/services/api/client.ts`)
- HTTP client → Auth state: updates auth (evidence: `apps/mobile/src/services/api/client.ts`)
- Rental client → Rental lifecycle: calls API
- Admin client → Admin operations: calls API
- Rental lifecycle → PostgreSQL: persists rental data
- Admin operations → PostgreSQL: reads and writes (evidence: `apps/api/src/admin/admin.service.ts`)
- Admin operations → Audit logs: records actions (evidence: `apps/api/src/admin/admin.service.ts`)
- Rental lifecycle → Payments: coordinates payment
- Payments → Finance: supports finance
- Reviews → Trust score: recalculates score (evidence: `apps/api/src/reviews/reviews.service.ts`)
- Disputes → Trust score: uses trust score (evidence: `apps/api/src/disputes/disputes.service.ts`)
- Disputes → Notifications: notifies users (evidence: `apps/api/src/disputes/disputes.service.ts`)
- Disputes → Analytics: records events (evidence: `apps/api/src/disputes/disputes.service.ts`)
- Disputes → Audit logs: records actions (evidence: `apps/api/src/disputes/disputes.service.ts`)
- Reviews → Notifications: notifies users (evidence: `apps/api/src/reviews/reviews.service.ts`)
- Reviews → Analytics: records events (evidence: `apps/api/src/reviews/reviews.service.ts`)
- Reviews → Audit logs: records moderation (evidence: `apps/api/src/reviews/reviews.service.ts`)
- File storage → Local provider: delegates to (evidence: `apps/api/src/storage/storage.service.ts`)
- File storage → MinIO provider: selects provider (evidence: `apps/api/src/storage/storage.service.ts`)
- Authentication → PostgreSQL: reads and writes (evidence: `apps/api/src/auth/auth.service.ts`)
- Authentication → Analytics: records events (evidence: `apps/api/src/auth/auth.service.ts`)
- KYC verification → File storage: stores documents
- Asset listings → File storage: stores listing images (evidence: `apps/api/src/storage/storage.module.ts`)
