Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,106 @@ webserver/
- **Styling:** Tailwind CSS v4
- **TypeScript:** v5

## Architecture Diagram

```mermaid
flowchart TD
User["User Browser"] --> UI["Next.js App Router UI"]

UI --> AuthAPI["/api/auth/* (NextAuth)"]
UI --> UserAPI["/api/user"]
UI --> PointsAPI["/api/points"]
UI --> RequestsAPI["/api/requests"]
UI --> GetAPI["/api/get/*"]
UI --> InboxAPI["/api/notifications"]

AuthAPI --> AuthCore["auth.ts + auth.config.ts"]
UserAPI --> AuthCore
PointsAPI --> AuthCore
RequestsAPI --> AuthCore
GetAPI --> AuthCore
InboxAPI --> AuthCore

AuthCore --> PrismaClient["lib/prisma.ts"]
PointsAPI --> PrismaClient
RequestsAPI --> PrismaClient
UserAPI --> PrismaClient
InboxAPI --> PrismaClient

GetAPI --> GetLib["lib/get/* Adapter Layer"]
GetLib --> ExternalGET["GET External Services"]

PrismaClient --> DB[("PostgreSQL + Prisma")]
```

## GET Workflow Diagrams

### 1) Account Linking

```mermaid
sequenceDiagram
participant User
participant FE as Frontend
participant API
participant GET as GET Service
participant Store as Credential Store

User->>FE: Submit validated URL/token
FE->>API: Connect request
API->>API: Extract session identifier
API->>GET: create device credentials
API->>GET: authenticate with device+PIN
API->>Store: Save encrypted device+PIN
API-->>FE: Connected
```

### 2) Barcode Refresh

```mermaid
sequenceDiagram
participant FE as Frontend
participant API
participant Cache as Session Cache
participant GET as GET Service

loop Every N seconds
FE->>API: fetch barcode payload
API->>Cache: read session
alt cache miss/expired
API->>GET: authenticate
API->>Cache: write session
Comment on lines +203 to +206
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align barcode-refresh diagram with actual session handling

The diagram currently shows a "Session Cache" read/write path, but /api/get/barcode does not use a cache layer: it calls getActiveGetSessionForUser, which re-authenticates via authenticatePin on each request (lib/get/server.ts) before fetching the barcode (app/api/get/barcode/route.ts). This mismatch can mislead maintainers/integrators into expecting cache-backed behavior and stale-session semantics that do not exist in production.

Useful? React with 👍 / 👎.

end
API->>GET: retrieve barcode payload
API-->>FE: payload + timestamps
FE->>FE: render PDF417
end
```

### 3) Fulfillment Completion

```mermaid
sequenceDiagram
participant FE as Requester Scan Page
participant API
participant GET as GET Service
participant DB as App DB

FE->>API: poll scan-state
API->>DB: load request and baseline balance
alt baseline missing
API->>GET: retrieve current account balance
API->>DB: save baseline balance
end
API->>GET: retrieve current account balance
alt current < baseline
API->>DB: mark request completed
API-->>FE: completed state
else no drop
API->>GET: retrieve current barcode payload
API-->>FE: active state + payload
Comment on lines +234 to +235
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fix fulfillment diagram to avoid implying scan-state returns QR data

In the "no drop" branch, the diagram says scan-state retrieves barcode payload and returns active state + payload, but GET /api/get/scan-state only returns status metadata (state, lastCheckedAt, expiresAt) and never returns barcode data; barcode payload is served by a separate endpoint (/api/get/barcode). This documentation error can cause client implementations to call the wrong endpoint and miss QR payloads.

Useful? React with 👍 / 👎.

end
```

## Available Scripts

- `npm run dev` - Start development server
Expand Down
Loading