# btl-it3180/gearloop architecture

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

- Interactive diagram: https://gitdiagram.com/btl-it3180/gearloop
- Repository: https://github.com/btl-it3180/gearloop

## Overview

GearLoop is a student peer-to-peer equipment-rental web app. Its documented renter flow is to find an item available for chosen dates, place a booking with a deposit hold, and proceed through seller approval and pickup/return condition reports; disputes and deposit resolution extend that flow. The README also documents authentication, role-based administration, item management, and reviews. The checked-in tree is much smaller than that product description: sampled source confirms the health endpoint and shared API/error/database utilities, but not the advertised feature handlers or service/repository layers. Those capabilities are shown as documented subsystems, not verified implementations.

Main entry points: [`src/server/errors.ts`](https://github.com/btl-it3180/gearloop/blob/main/src/server/errors.ts) (Error handling), [`src/app/api`](https://github.com/btl-it3180/gearloop/tree/main/src/app/api) (Booking lifecycle), [`src/app/api/health/route.ts`](https://github.com/btl-it3180/gearloop/blob/main/src/app/api/health/route.ts) (Health endpoint), [`src/server/api/withApi.ts`](https://github.com/btl-it3180/gearloop/blob/main/src/server/api/withApi.ts) (API response wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web["GearLoop interface<br/>[page.tsx]"]
end

subgraph group_rental["Rental lifecycle"]
  node_items["Equipment listings"]
  node_availability["Date availability"]
  node_bookings["Booking lifecycle"]
  node_deposits[("Deposit ledger<br/>[schema.prisma]")]
  node_condition["Condition reports"]
  node_claims["Damage claims"]
  node_reviews["Rental reviews"]
end

subgraph group_operations["Platform operations"]
  node_auth["Accounts and sessions"]
  node_admin["Admin operations"]
  node_health["Health endpoint<br/>[route.ts]"]
end

subgraph group_foundation["Runtime foundation"]
  node_dbclient["Prisma client<br/>[client.ts]"]
  node_validation["Input validation<br/>[validation.ts]"]
  node_rolecheck["Role guard<br/>[requireRole.ts]"]
  node_errors["Error handling<br/>[errors.ts]"]
  node_catalog["Error catalog<br/>[error-catalog.ts]"]
  node_apiwrapper["API response wrapper<br/>[withApi.ts]"]
  node_responses["Response types<br/>[api-response.ts]"]
  node_postgres[("PostgreSQL data<br/>[schema.prisma]")]
end

node_users(("Renters and sellers"))

node_users -->|"use"| node_web
node_users -.->|"browse listings"| node_items
node_users -.->|"check dates"| node_availability
node_users -.->|"request rental"| node_bookings
node_bookings -.->|"hold deposit"| node_deposits
node_bookings -.->|"record handoff"| node_condition
node_users -.->|"file claim"| node_claims
node_users -.->|"submit review"| node_reviews
node_users -.->|"authenticate"| node_auth
node_users -.->|"administer"| node_admin
node_health -->|"queries"| node_dbclient
node_dbclient -.->|"connects"| node_postgres
node_apiwrapper -->|"formats"| node_responses
node_apiwrapper -->|"catches"| node_errors
node_errors -->|"reads messages"| node_catalog
node_validation -->|"throws"| node_errors
node_rolecheck -->|"throws"| node_errors
node_health -->|"checks connection"| node_postgres

click node_web "https://github.com/btl-it3180/gearloop/blob/main/src/app/page.tsx"
click node_auth "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_items "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_availability "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_bookings "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_deposits "https://github.com/btl-it3180/gearloop/blob/main/prisma/schema.prisma"
click node_condition "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_claims "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_reviews "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_admin "https://github.com/btl-it3180/gearloop/tree/main/src/app/api"
click node_health "https://github.com/btl-it3180/gearloop/blob/main/src/app/api/health/route.ts"
click node_dbclient "https://github.com/btl-it3180/gearloop/blob/main/src/server/db/client.ts"
click node_validation "https://github.com/btl-it3180/gearloop/blob/main/src/server/utils/validation.ts"
click node_rolecheck "https://github.com/btl-it3180/gearloop/blob/main/src/server/middleware/requireRole.ts"
click node_errors "https://github.com/btl-it3180/gearloop/blob/main/src/server/errors.ts"
click node_catalog "https://github.com/btl-it3180/gearloop/blob/main/src/lib/error-catalog.ts"
click node_apiwrapper "https://github.com/btl-it3180/gearloop/blob/main/src/server/api/withApi.ts"
click node_responses "https://github.com/btl-it3180/gearloop/blob/main/src/lib/api-response.ts"
click node_postgres "https://github.com/btl-it3180/gearloop/blob/main/prisma/schema.prisma"

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 toneBlue
class node_items,node_availability,node_bookings,node_deposits,node_condition,node_claims,node_reviews toneAmber
class node_auth,node_admin,node_health toneMint
class node_dbclient,node_validation,node_rolecheck,node_errors,node_catalog,node_apiwrapper,node_responses,node_postgres toneRose
class node_users toneIndigo
```

## Components

### Web experience

- [GearLoop interface](https://github.com/btl-it3180/gearloop/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Rental lifecycle

- [Equipment listings](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Date availability](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Booking lifecycle](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Deposit ledger](https://github.com/btl-it3180/gearloop/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Condition reports](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Damage claims](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Rental reviews](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`

### Platform operations

- [Accounts and sessions](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Admin operations](https://github.com/btl-it3180/gearloop/tree/main/src/app/api): `src/app/api`
- [Health endpoint](https://github.com/btl-it3180/gearloop/blob/main/src/app/api/health/route.ts): `src/app/api/health/route.ts`

### Runtime foundation

- [Prisma client](https://github.com/btl-it3180/gearloop/blob/main/src/server/db/client.ts): `src/server/db/client.ts`
- [Input validation](https://github.com/btl-it3180/gearloop/blob/main/src/server/utils/validation.ts): `src/server/utils/validation.ts`
- [Role guard](https://github.com/btl-it3180/gearloop/blob/main/src/server/middleware/requireRole.ts): `src/server/middleware/requireRole.ts`
- [Error handling](https://github.com/btl-it3180/gearloop/blob/main/src/server/errors.ts): `src/server/errors.ts`
- [Error catalog](https://github.com/btl-it3180/gearloop/blob/main/src/lib/error-catalog.ts): `src/lib/error-catalog.ts`
- [API response wrapper](https://github.com/btl-it3180/gearloop/blob/main/src/server/api/withApi.ts): `src/server/api/withApi.ts`
- [Response types](https://github.com/btl-it3180/gearloop/blob/main/src/lib/api-response.ts): `src/lib/api-response.ts`
- [PostgreSQL data](https://github.com/btl-it3180/gearloop/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Other components

- **Renters and sellers**

## Connections

- Renters and sellers → GearLoop interface: use (evidence: `README.md`)
- Renters and sellers → Equipment listings: browse listings (evidence: `README.md`)
- Renters and sellers → Date availability: check dates (evidence: `README.md`)
- Renters and sellers → Booking lifecycle: request rental (evidence: `README.md`)
- Booking lifecycle → Deposit ledger: hold deposit (evidence: `README.md`)
- Booking lifecycle → Condition reports: record handoff (evidence: `README.md`)
- Renters and sellers → Damage claims: file claim (evidence: `README.md`)
- Renters and sellers → Rental reviews: submit review (evidence: `README.md`)
- Renters and sellers → Accounts and sessions: authenticate (evidence: `README.md`)
- Renters and sellers → Admin operations: administer (evidence: `README.md`)
- Health endpoint → Prisma client: queries (evidence: `src/app/api/health/route.ts`)
- Prisma client → PostgreSQL data: connects
- API response wrapper → Response types: formats (evidence: `src/server/api/withApi.ts`)
- API response wrapper → Error handling: catches (evidence: `src/server/api/withApi.ts`)
- Error handling → Error catalog: reads messages (evidence: `src/server/errors.ts`)
- Input validation → Error handling: throws (evidence: `src/server/utils/validation.ts`)
- Role guard → Error handling: throws (evidence: `src/server/middleware/requireRole.ts`)
- Health endpoint → PostgreSQL data: checks connection (evidence: `src/app/api/health/route.ts`)
