# woon-woo/original-otomotiv architecture

> Architecture diagram of the GitHub repository woon-woo/original-otomotiv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/woon-woo/original-otomotiv
- Repository: https://github.com/woon-woo/original-otomotiv

## Overview

1. **Overall shape:** this repo is a three-surface system built around a single Supabase backend. The surfaces are: the public/admin web app in `apps/web`, the internal iOS/macOS-style terminal app in `apps/ogot`, and the shared database/auth/storage layer in `supabase`.

2. **Public + admin web app (`apps/web`):** Next.js App Router is used for both the public storefront and the protected admin panel. The site has public routes for the homepage, about page, product/part listings, and store pages, while the panel lives under `/panel` and is split into many domain areas such as catalog, products, members, suppliers, records, deletion requests, and store management.

3. **Authentication and session flow on the web:** login and account-recovery flows are separated into dedicated routes and server actions (`/giris`, `/sifremi-unuttum`, `/sifre-belirle`, `/auth/confirm`). There is also a multi-factor authentication section under `/panel/mfa`, which includes setup, email challenge/verification, and verification display screens. The web app uses Supabase client/server/admin helpers to enforce this boundary.

4. **Protected operations in the web panel:** the protected layout under `/panel/(protected)` indicates that most mutation-heavy behavior is server-side and gated. Each major admin area has its own `actions.ts`, so form submissions and record changes happen through server actions rather than direct client-side API calls. There is also a dedicated export route for Sahibinden integration, which matches the repository’s “Sahibinden taxonomy 1:1” model.

5. **Frontend domain model:** the public catalog and admin panel are centered on automotive inventory concepts: parts/products, brands, categories, lists, stores, members, suppliers, shelves, depots, and vehicle filters. The presence of `CatalogUI`, `VehicleFilter`, `ProductRow`, and rich-text/photo components suggests the UI is built around structured product metadata plus media and search/filtering.

6. **Backend data layer (`supabase`):** Supabase is the system of record and contains the schema evolution for auth profiles, audit logging, catalog data, vehicles, inventory, suppliers/printing, multi-tenant stores, store owner privacy, account deletion, email 2FA, category trees/sorting, and denormalized storefront views. RLS is a core architectural boundary: the README states all tables use RLS, with soft delete and audit logs everywhere important.

7. **How data is exposed from the backend:** the migration set shows a deliberate split between authoritative tables and derived/public-facing shapes. That includes denormalized storefront data, category trees, store-only anonymous columns, and RPCs for read/search operations. This is a strong signal that the web and OGOT clients consume curated views and RPCs rather than raw tables for many paths.

8. **Internal staff app (`apps/ogot`):** OGOT is a separate Swift/SwiftUI app for internal warehouse or counter workflows. Its screens suggest login, depot management, product browsing, shelf/location operations, QR scanning, label printing, and add-product flows. It is not just a thin web wrapper; it is its own client with native UI and device capabilities.

9. **Printing subsystem (`NiimbotKit`):** this Swift package isolates Niimbot B1 label printing. The package has packet/command/printer abstractions plus QR rendering and bitmap conversion, with separate debug and verification executables and tests. In architecture terms, it is a device-driver-like boundary used by OGOT for QR label output over Bluetooth/CoreBluetooth.

10. **Operational integrations:** the product flow avoids online checkout; the purchase path is a WhatsApp handoff, reflected by `whatsapp.ts` and static `wa.me` links. There are also support utilities for email, thumbnails, sanitization, logging, and anti-bot protection via Turnstile, which all sit around the core catalog/auth flows.

11. **Security and governance:** the repo emphasizes admin MFA, audit history, account deletion, and store-owner privacy. The combination of RLS, login tracking, audit tables, and soft delete means the system is designed for traceability and controlled access rather than a simple CRUD app.

12. **Repo boundaries for a diagram:** draw the web app and OGOT app as separate clients, both talking to the same Supabase backend; draw NiimbotKit as a native-printing submodule only used by OGOT; and show public storefront reads separated from protected admin mutations by auth/RLS/server-actions boundaries. The most important shared domain is catalog/inventory/store management, with web focused on public commerce/admin and OGOT focused on in-person operations and label printing.

Main entry points: [`apps/web/src/lib/supabase`](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/lib/supabase) (Supabase Helpers), [`supabase/migrations`](https://github.com/woon-woo/original-otomotiv/tree/main/supabase/migrations) (Schema), [`apps/ogot/OGOT/OGOT`](https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/OGOT/OGOT) (OGOT App), [`supabase/migrations/0009_rpc.sql`](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0009_rpc.sql) (RPC & Views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web App"]
  node_web_site["Public Site<br/>Next.js site"]
  node_web_auth["Auth Flows<br/>Next.js auth"]
  node_web_panel["Admin Panel<br/>Protected admin"]
  node_web_catalog["Catalog Admin<br/>Admin domain"]
  node_web_products["Products<br/>Admin domain"]
  node_web_members["Members<br/>Admin domain"]
  node_web_suppliers["Suppliers<br/>Admin domain"]
  node_web_records["Records<br/>Admin domain"]
  node_web_store["Store Ops<br/>Admin domain"]
  node_web_mfa["MFA<br/>Security flows"]
  node_web_export["Sahibinden Export<br/>Export route<br/>[route.ts]"]
  node_web_lib["Supabase Helpers<br/>Web data layer"]
  node_web_components["UI Components<br/>Web UI"]
end

subgraph group_backend["Supabase"]
  node_supabase_schema[("Schema<br/>SQL migrations")]
  node_supabase_rls{{"RLS & Grants<br/>Security SQL"}}
  node_supabase_rpc["RPC & Views<br/>Data API SQL<br/>[0009_rpc.sql]"]
  node_supabase_storage[("Storage<br/>[0010_storage.sql]")]
  node_supabase_mfa["MFA Data<br/>Auth SQL"]
  node_supabase_audit["Audit Log<br/>Audit SQL<br/>[0003_audit.sql]"]
  node_supabase_privacy["Privacy & Deletion<br/>Governance SQL"]
end

subgraph group_ogot["OGOT"]
  node_ogot_app["OGOT App<br/>SwiftUI client"]
  node_ogot_backend["Backend Client<br/>Swift backend<br/>[Backend.swift]"]
  node_ogot_depot["Depot<br/>Workflow screen<br/>[DepotView.swift]"]
  node_ogot_products["Products<br/>Workflow screen<br/>[ProductsView.swift]"]
  node_ogot_scan["QR Scan<br/>Device feature"]
  node_ogot_print["Print Labels<br/>Device feature"]
end

subgraph group_printing["Printing"]
  node_niimbot_kit["NiimbotKit<br/>Swift package<br/>[Package.swift]"]
  node_niimbot_core{{"Printer Core<br/>Printer driver"}}
  node_niimbot_tools["Debug Tools<br/>Printer tooling"]
end

node_web_site -->|"read data"| node_web_lib
node_web_auth -->|"session"| node_web_lib
node_web_panel -->|"guarded data"| node_web_lib
node_web_panel -->|"compose ui"| node_web_components
node_web_catalog -->|"mutate data"| node_web_lib
node_web_products -->|"mutate data"| node_web_lib
node_web_members -->|"mutate data"| node_web_lib
node_web_suppliers -->|"mutate data"| node_web_lib
node_web_records -->|"read/update"| node_web_lib
node_web_store -->|"admin ops"| node_web_lib
node_web_mfa -->|"verify"| node_web_lib
node_web_export -->|"export"| node_supabase_rpc
node_web_lib -->|"tables"| node_supabase_schema
node_web_lib -->|"rpc/views"| node_supabase_rpc
node_web_lib -->|"media"| node_supabase_storage
node_web_panel -.->|"enforced by"| node_supabase_rls
node_ogot_app -->|"session data"| node_ogot_backend
node_ogot_app -->|"shows"| node_ogot_depot
node_ogot_app -->|"shows"| node_ogot_products
node_ogot_app -->|"uses"| node_ogot_scan
node_ogot_app -->|"uses"| node_ogot_print
node_ogot_print -->|"prints via"| node_niimbot_kit
node_niimbot_kit -->|"implements"| node_niimbot_core
node_niimbot_kit -->|"verifies"| node_niimbot_tools
node_ogot_backend -->|"reads"| node_supabase_schema
node_ogot_backend -->|"queries"| node_supabase_rpc
node_ogot_app -->|"mfa"| node_supabase_mfa
node_supabase_schema -.->|"tracked by"| node_supabase_audit
node_supabase_schema -.->|"governed by"| node_supabase_privacy
node_supabase_schema -.->|"protected by"| node_supabase_rls
node_supabase_schema -->|"served through"| node_supabase_rpc
node_supabase_schema -->|"uploads"| node_supabase_storage
node_supabase_schema -->|"auth 2fa"| node_supabase_mfa

click node_web_site "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/(site)"
click node_web_auth "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/giris"
click node_web_panel "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)"
click node_web_catalog "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/katalog"
click node_web_products "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/parca"
click node_web_members "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/uyeler"
click node_web_suppliers "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/tedarikciler"
click node_web_records "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/kayitlar"
click node_web_store "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/magazam"
click node_web_mfa "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/mfa"
click node_web_export "https://github.com/woon-woo/original-otomotiv/blob/main/apps/web/src/app/panel/export/sahibinden/route.ts"
click node_web_lib "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/lib/supabase"
click node_web_components "https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/components"
click node_supabase_schema "https://github.com/woon-woo/original-otomotiv/tree/main/supabase/migrations"
click node_supabase_rls "https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0008_rls_policies.sql"
click node_supabase_rpc "https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0009_rpc.sql"
click node_supabase_storage "https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0010_storage.sql"
click node_supabase_mfa "https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0016_data_layer_mfa.sql"
click node_supabase_audit "https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0003_audit.sql"
click node_supabase_privacy "https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0017_store_owner_privacy.sql"
click node_ogot_app "https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/OGOT/OGOT"
click node_ogot_backend "https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/Backend.swift"
click node_ogot_depot "https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/DepotView.swift"
click node_ogot_products "https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/ProductsView.swift"
click node_ogot_scan "https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/QRScannerView.swift"
click node_ogot_print "https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/PrintLabelView.swift"
click node_niimbot_kit "https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/NiimbotKit/Package.swift"
click node_niimbot_core "https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/NiimbotKit/Sources/NiimbotKit"
click node_niimbot_tools "https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/NiimbotKit/Sources/NiimbotDebug"

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_site,node_web_auth,node_web_panel,node_web_catalog,node_web_products,node_web_members,node_web_suppliers,node_web_records,node_web_store,node_web_mfa,node_web_export,node_web_lib,node_web_components toneBlue
class node_supabase_schema,node_supabase_rls,node_supabase_rpc,node_supabase_storage,node_supabase_mfa,node_supabase_audit,node_supabase_privacy toneAmber
class node_ogot_app,node_ogot_backend,node_ogot_depot,node_ogot_products,node_ogot_scan,node_ogot_print toneMint
class node_niimbot_kit,node_niimbot_core,node_niimbot_tools toneRose
```

## Components

### Web App

Next.js storefront and admin panel

- [Public Site](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/(site)): Next.js site · Homepage, about, listings, and store pages · `apps/web/src/app/(site)`
- [Auth Flows](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/giris): Next.js auth · Login, recovery, password setup, and confirm routes · `apps/web/src/app/giris`
- [Admin Panel](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)): Protected admin · Authenticated panel shell and domain areas · `apps/web/src/app/panel/(protected)`
- [Catalog Admin](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/katalog): Admin domain · Brands, categories, lists, and catalog management · `apps/web/src/app/panel/(protected)/katalog`
- [Products](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/parca): Admin domain · Part and product editing, creation, and detail actions · `apps/web/src/app/panel/(protected)/parca`
- [Members](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/uyeler): Admin domain · Store members and store-specific member management · `apps/web/src/app/panel/(protected)/uyeler`
- [Suppliers](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/tedarikciler): Admin domain · Supplier management and related mutations · `apps/web/src/app/panel/(protected)/tedarikciler`
- [Records](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/kayitlar): Admin domain · Operational record views and actions · `apps/web/src/app/panel/(protected)/kayitlar`
- [Store Ops](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/(protected)/magazam): Admin domain · Store management and store-owner workflows · `apps/web/src/app/panel/(protected)/magazam`
- [MFA](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/app/panel/mfa): Security flows · Setup, email challenge, and verification screens · `apps/web/src/app/panel/mfa`
- [Sahibinden Export](https://github.com/woon-woo/original-otomotiv/blob/main/apps/web/src/app/panel/export/sahibinden/route.ts): Export route · Specialized export endpoint for marketplace integration · `apps/web/src/app/panel/export/sahibinden/route.ts`
- [Supabase Helpers](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/lib/supabase): Web data layer · Client, server, admin, session, and update helpers · `apps/web/src/lib/supabase`
- [UI Components](https://github.com/woon-woo/original-otomotiv/tree/main/apps/web/src/components): Web UI · Catalog, forms, filters, auth gates, and media widgets · `apps/web/src/components`

### Supabase

Database, auth, storage, and RPC layer

- [Schema](https://github.com/woon-woo/original-otomotiv/tree/main/supabase/migrations): SQL migrations · Core tables for profiles, catalog, inventory, stores, and auth · `supabase/migrations`
- [RLS & Grants](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0008_rls_policies.sql): Security SQL · Row-level security, role hardening, and service grants · `supabase/migrations/0008_rls_policies.sql`
- [RPC & Views](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0009_rpc.sql): Data API SQL · Search, read, denormalized storefront, and helper RPCs · `supabase/migrations/0009_rpc.sql`
- [Storage](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0010_storage.sql): Storage SQL · File storage and hardening for media assets · `supabase/migrations/0010_storage.sql`
- [MFA Data](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0016_data_layer_mfa.sql): Auth SQL · Database support for email two-factor authentication · `supabase/migrations/0016_data_layer_mfa.sql`
- [Audit Log](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0003_audit.sql): Audit SQL · Audit history, revert support, and login tracking · `supabase/migrations/0003_audit.sql`
- [Privacy & Deletion](https://github.com/woon-woo/original-otomotiv/blob/main/supabase/migrations/0017_store_owner_privacy.sql): Governance SQL · Store-owner privacy and account deletion controls · `supabase/migrations/0017_store_owner_privacy.sql`

### OGOT

Native internal warehouse app

- [OGOT App](https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/OGOT/OGOT): SwiftUI client · Native internal login, depot, product, and workflow app · `apps/ogot/OGOT/OGOT`
- [Backend Client](https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/Backend.swift): Swift backend · App-side Supabase access and session handling · `apps/ogot/OGOT/OGOT/Backend.swift`
- [Depot](https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/DepotView.swift): Workflow screen · Depot and warehouse management screens · `apps/ogot/OGOT/OGOT/DepotView.swift`
- [Products](https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/ProductsView.swift): Workflow screen · Product browsing and operational item lookup · `apps/ogot/OGOT/OGOT/ProductsView.swift`
- [QR Scan](https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/QRScannerView.swift): Device feature · QR scanning for item and location workflows · `apps/ogot/OGOT/OGOT/QRScannerView.swift`
- [Print Labels](https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/OGOT/OGOT/PrintLabelView.swift): Device feature · Label printing flow used by warehouse staff · `apps/ogot/OGOT/OGOT/PrintLabelView.swift`

### Printing

Niimbot label-printing package

- [NiimbotKit](https://github.com/woon-woo/original-otomotiv/blob/main/apps/ogot/NiimbotKit/Package.swift): Swift package · Label printer driver package with QR and bitmap support · `apps/ogot/NiimbotKit/Package.swift`
- [Printer Core](https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/NiimbotKit/Sources/NiimbotKit): Printer driver · Packet, command, printer, and bitmap primitives · `apps/ogot/NiimbotKit/Sources/NiimbotKit`
- [Debug Tools](https://github.com/woon-woo/original-otomotiv/tree/main/apps/ogot/NiimbotKit/Sources/NiimbotDebug): Printer tooling · Verification and debug executables for printer output · `apps/ogot/NiimbotKit/Sources/NiimbotDebug`

## Connections

- Public Site → Supabase Helpers: read data · Public pages consume Supabase through shared helpers
- Auth Flows → Supabase Helpers: session · Auth routes use server/client helpers and session updates
- Admin Panel → Supabase Helpers: guarded data · Protected panel uses server-side Supabase access
- Admin Panel → UI Components: compose ui · Panel shells and domain pages use shared UI components
- Catalog Admin → Supabase Helpers: mutate data · Catalog admin submits through server actions and helpers
- Products → Supabase Helpers: mutate data · Product detail and creation actions flow through helpers
- Members → Supabase Helpers: mutate data · Member management uses protected server actions
- Suppliers → Supabase Helpers: mutate data · Supplier workflows are handled server-side
- Records → Supabase Helpers: read/update · Operational records are loaded and changed through actions
- Store Ops → Supabase Helpers: admin ops · Store management depends on authenticated Supabase access
- MFA → Supabase Helpers: verify · MFA setup and challenge screens use shared auth helpers
- Sahibinden Export → RPC & Views: export · Export route likely reads curated catalog data via backend APIs
- Supabase Helpers → Schema: tables · Web helpers target the shared system-of-record schema
- Supabase Helpers → RPC & Views: rpc/views · Read/search flows use derived API shapes
- Supabase Helpers → Storage: media · Uploads and thumbnails depend on storage
- Admin Panel → RLS & Grants: enforced by · Protected admin operations rely on RLS and grants
- OGOT App → Backend Client: session data · Native screens depend on the app backend layer
- OGOT App → Depot: shows · Depot management is a major OGOT surface
- OGOT App → Products: shows · Product browsing is a major OGOT surface
- OGOT App → QR Scan: uses · OGOT includes device QR scanning workflows
- OGOT App → Print Labels: uses · Label printing is exposed in the native app
- Print Labels → NiimbotKit: prints via · OGOT delegates label output to the printer package
- NiimbotKit → Printer Core: implements · Core package contains printer protocols and QR rendering
- NiimbotKit → Debug Tools: verifies · Debug executables exercise the printing stack
- Backend Client → Schema: reads · OGOT uses the same backend system of record
- Backend Client → RPC & Views: queries · Native workflows likely consume curated RPCs and views
- OGOT App → MFA Data: mfa · Internal login supports multi-factor auth data flows
- Schema → Audit Log: tracked by · Important tables are covered by audit and login tracking
- Schema → Privacy & Deletion: governed by · Profiles, deletion, and store-owner privacy are enforced in SQL
- Schema → RLS & Grants: protected by · Core data is guarded by row-level security
- Schema → RPC & Views: served through · Curated read/search and storefront views sit on top of tables
- Schema → Storage: uploads · Catalog media and assets are stored separately from tables
- Schema → MFA Data: auth 2fa · Email 2FA extends the auth/profile data layer
