# mattias-wiberg/flipper-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/mattias-wiberg/flipper-v2
- Repository: https://github.com/mattias-wiberg/flipper-v2

## Overview

Flipper helps Albion Online players identify profitable Black Market trades. Its main workflow ingests market orders, stores them in Supabase, then loads buy and sell orders, calculates base and upgrade-adjusted deals, and presents them in a filterable table. Users authenticate and can manage ingestion tokens. The README also documents optional Umami product analytics. Some routes and integrations are represented from documentation or the source index rather than inspected implementation excerpts; unverified links are omitted or dashed.

Main entry points: [`app/authenticated/deals/page.tsx`](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/page.tsx) (Deals page), [`app/api/[token]/marketorders.ingest/route.ts`](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/api/%5Btoken%5D/marketorders.ingest/route.ts) (Order ingestion), [`components/login-form.tsx`](https://github.com/mattias-wiberg/flipper-v2/blob/main/components/login-form.tsx) (Login and signup), [`app/actions.ts`](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/actions.ts) (Auth actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authentication"]
  node_auth_ui["Login and signup<br/>[login-form.tsx]"]
  node_auth_actions["Auth actions<br/>[actions.ts]"]
  node_auth_callback["Auth callback<br/>[route.ts]"]
end

subgraph group_market["Market Data"]
  node_token_page["Token settings<br/>[page.tsx]"]
  node_token_help["Token tutorial<br/>[token-tutorial.tsx]"]
  node_ingest["Order ingestion<br/>[route.ts]"]
end

subgraph group_deals["Deal Discovery"]
  node_deals_page["Deals page<br/>[page.tsx]"]
  node_deal_calc["Deal calculation<br/>[deals.ts]"]
  node_upgrade_costs["Upgrade costs<br/>[upgradeCosts.ts]"]
  node_deal_table["Deals table<br/>[data-table.tsx]"]
  node_deal_columns["Deal columns<br/>[columns.tsx]"]
end

subgraph group_product["Product Surface"]
  node_home["Landing page<br/>[page.tsx]"]
  node_analytics["Product analytics<br/>[analytics.tsx]"]
end

node_player(("Player"))
node_data_client(("Albion Data Client"))
node_supabase_auth["Supabase Auth"]
node_supabase_db[("Supabase data")]
node_umami["Umami"]

node_player -->|"starts signup"| node_auth_ui
node_auth_ui -->|"submits credentials"| node_auth_actions
node_auth_actions -->|"authenticates"| node_supabase_auth
node_auth_callback -->|"exchanges code"| node_supabase_auth
node_player -->|"manages token"| node_token_page
node_token_page -->|"shows guidance"| node_token_help
node_data_client -.->|"submits orders"| node_ingest
node_ingest -->|"upserts orders"| node_supabase_db
node_ingest -->|"validates token"| node_supabase_db
node_player -->|"views deals"| node_deals_page
node_deals_page -->|"reads orders"| node_supabase_db
node_deals_page -->|"calculates deals"| node_deal_calc
node_deal_calc -->|"uses upgrade costs"| node_upgrade_costs
node_deals_page -->|"renders deal data"| node_deal_table
node_deal_table -->|"uses columns"| node_deal_columns
node_home -->|"links signup"| node_auth_ui
node_analytics -.->|"sends telemetry"| node_umami

click node_auth_ui "https://github.com/mattias-wiberg/flipper-v2/blob/main/components/login-form.tsx"
click node_auth_actions "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/actions.ts"
click node_auth_callback "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/auth/callback/route.ts"
click node_token_page "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/token/page.tsx"
click node_token_help "https://github.com/mattias-wiberg/flipper-v2/blob/main/components/token-tutorial.tsx"
click node_ingest "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/api/%5Btoken%5D/marketorders.ingest/route.ts"
click node_deals_page "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/page.tsx"
click node_deal_calc "https://github.com/mattias-wiberg/flipper-v2/blob/main/lib/deals.ts"
click node_upgrade_costs "https://github.com/mattias-wiberg/flipper-v2/blob/main/lib/upgradeCosts.ts"
click node_deal_table "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/components/data-table.tsx"
click node_deal_columns "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/components/columns.tsx"
click node_home "https://github.com/mattias-wiberg/flipper-v2/blob/main/app/page.tsx"
click node_analytics "https://github.com/mattias-wiberg/flipper-v2/blob/main/components/analytics.tsx"

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_auth_ui,node_auth_actions,node_auth_callback,node_data_client toneBlue
class node_token_page,node_token_help,node_ingest,node_supabase_db toneAmber
class node_deals_page,node_deal_calc,node_upgrade_costs,node_deal_table,node_deal_columns toneMint
class node_home,node_analytics toneRose
class node_player,node_supabase_auth,node_umami toneIndigo
```

## Components

### Authentication

- [Login and signup](https://github.com/mattias-wiberg/flipper-v2/blob/main/components/login-form.tsx): `components/login-form.tsx`
- [Auth actions](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/actions.ts): `app/actions.ts`
- [Auth callback](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/auth/callback/route.ts): `app/auth/callback/route.ts`

### Market Data

- [Token settings](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/token/page.tsx): `app/authenticated/token/page.tsx`
- [Token tutorial](https://github.com/mattias-wiberg/flipper-v2/blob/main/components/token-tutorial.tsx): `components/token-tutorial.tsx`
- [Order ingestion](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/api/%5Btoken%5D/marketorders.ingest/route.ts): `app/api/[token]/marketorders.ingest/route.ts`

### Deal Discovery

- [Deals page](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/page.tsx): `app/authenticated/deals/page.tsx`
- [Deal calculation](https://github.com/mattias-wiberg/flipper-v2/blob/main/lib/deals.ts): `lib/deals.ts`
- [Upgrade costs](https://github.com/mattias-wiberg/flipper-v2/blob/main/lib/upgradeCosts.ts): `lib/upgradeCosts.ts`
- [Deals table](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/components/data-table.tsx): `app/authenticated/deals/components/data-table.tsx`
- [Deal columns](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/authenticated/deals/components/columns.tsx): `app/authenticated/deals/components/columns.tsx`

### Product Surface

- [Landing page](https://github.com/mattias-wiberg/flipper-v2/blob/main/app/page.tsx): `app/page.tsx`
- [Product analytics](https://github.com/mattias-wiberg/flipper-v2/blob/main/components/analytics.tsx): `components/analytics.tsx`

### Other components

- **Player**
- **Albion Data Client**
- **Supabase Auth**
- **Supabase data**
- **Umami**

## Connections

- Player → Login and signup: starts signup
- Login and signup → Auth actions: submits credentials (evidence: `components/login-form.tsx`)
- Auth actions → Supabase Auth: authenticates (evidence: `app/actions.ts`)
- Auth callback → Supabase Auth: exchanges code (evidence: `app/auth/callback/route.ts`)
- Player → Token settings: manages token (evidence: `app/authenticated/token/page.tsx`)
- Token settings → Token tutorial: shows guidance (evidence: `app/authenticated/token/page.tsx`)
- Albion Data Client → Order ingestion: submits orders
- Order ingestion → Supabase data: upserts orders (evidence: `app/api/[token]/marketorders.ingest/route.ts`)
- Order ingestion → Supabase data: validates token (evidence: `app/api/[token]/marketorders.ingest/route.ts`)
- Player → Deals page: views deals (evidence: `app/authenticated/deals/page.tsx`)
- Deals page → Supabase data: reads orders (evidence: `app/authenticated/deals/page.tsx`)
- Deals page → Deal calculation: calculates deals (evidence: `app/authenticated/deals/page.tsx`)
- Deal calculation → Upgrade costs: uses upgrade costs (evidence: `lib/deals.ts`)
- Deals page → Deals table: renders deal data (evidence: `app/authenticated/deals/page.tsx`)
- Deals table → Deal columns: uses columns
- Landing page → Login and signup: links signup (evidence: `app/page.tsx`)
- Product analytics → Umami: sends telemetry
