# hafashproduction3/hafash architecture

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

- Interactive diagram: https://gitdiagram.com/hafashproduction3/hafash
- Repository: https://github.com/hafashproduction3/hafash

## Overview

The tree suggests Hafash is a photographer-focused business platform: photographers manage bookings, galleries, files, payments, portfolios, and professional connections, while clients view galleries and submit selections or reviews. The README only identifies a Next.js/Firebase starter, so product capabilities are inferred from route and module names. The graph highlights those domain areas; edges are limited to relationships visible in the supplied source index or excerpts, leaving unsampled page connections out.

Main entry points: [`src/lib/firebase-admin.ts`](https://github.com/hafashproduction3/hafash/blob/main/src/lib/firebase-admin.ts) (Firebase Admin), [`src/app/actions/storage.ts`](https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/storage.ts) (Storage actions), [`src/app/api/safepay/webhook/route.ts`](https://github.com/hafashproduction3/hafash/blob/main/src/app/api/safepay/webhook/route.ts) (Payment webhook), [`src/app/api/safepay/checkout/route.ts`](https://github.com/hafashproduction3/hafash/blob/main/src/app/api/safepay/checkout/route.ts) (Safepay checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_gallery["Client galleries<br/>[page.tsx]"]
  node_selections["Photo selections<br/>[page.tsx]"]
  node_reviews["Review submission<br/>[reviews.ts]"]
  node_reviewform["Review form"]
end

subgraph group_business["Studio operations"]
  node_booking["Bookings<br/>[page.tsx]"]
  node_events["Event management<br/>[page.tsx]"]
  node_portfolio["Studio portfolio<br/>[page.tsx]"]
  node_quotes["Quotes<br/>[quotes.ts]"]
end

subgraph group_monetization["Plans and payments"]
  node_plans["Plan definitions<br/>[plans.ts]"]
  node_subscription["Subscription status<br/>[status.ts]"]
  node_checkout["Safepay checkout<br/>[route.ts]"]
  node_webhook["Payment webhook<br/>[route.ts]"]
  node_receipts["Payment receipts"]
  node_expiry["Expiry reminders<br/>[route.ts]"]
  node_expiryemail["Reminder email"]
  node_safepay["Safepay service<br/>[safepay.ts]"]
end

subgraph group_platform["Data and files"]
  node_drive["Photographer drive<br/>[page.tsx]"]
  node_storageactions["Storage actions<br/>[storage.ts]"]
  node_storage["Storage provider<br/>[storage.ts]"]
  node_r2["Cloudflare R2<br/>[r2.ts]"]
  node_storagestats["Storage usage stats<br/>[stats.ts]"]
  node_firebase["Firebase client setup<br/>[init.ts]"]
  node_admin[("Firebase Admin<br/>[firebase-admin.ts]")]
end

subgraph group_extensions["Network and AI"]
  node_network["Photographer network<br/>[page.tsx]"]
  node_ai["AI gallery highlights"]
  node_genkit["Genkit runtime<br/>[genkit.ts]"]
end

node_visitor(("Client or visitor"))

node_visitor -.->|"views"| node_gallery
node_visitor -.->|"submits"| node_reviewform
node_reviewform -->|"submits review"| node_reviews
node_visitor -.->|"selects photos"| node_selections
node_storageactions -->|"checks plan"| node_subscription
node_storageactions -->|"checks quota"| node_storagestats
node_storageactions -->|"signs uploads"| node_storage
node_storage -->|"uses provider"| node_r2
node_checkout -->|"creates payment"| node_safepay
node_checkout -->|"verifies identity"| node_admin
node_checkout -->|"reads plan"| node_plans
node_webhook -->|"checks payment"| node_safepay
node_webhook -->|"activates plan"| node_admin
node_webhook -->|"reads plan"| node_plans
node_webhook -->|"sends receipt"| node_receipts
node_subscription -->|"reads definitions"| node_plans
node_expiry -->|"reads accounts"| node_admin
node_expiry -->|"sends reminder"| node_expiryemail
node_ai -->|"uses runtime"| node_genkit
node_booking -.->|"persists bookings"| node_admin
node_events -.->|"uploads media"| node_storageactions
node_drive -.->|"manages files"| node_storageactions
node_portfolio -.->|"presents studio"| node_visitor
node_network -.->|"stores network data"| node_admin
node_quotes -.->|"stores quotes"| node_admin

click node_gallery "https://github.com/hafashproduction3/hafash/blob/main/src/app/gallery/%5Bid%5D/page.tsx"
click node_selections "https://github.com/hafashproduction3/hafash/blob/main/src/app/album-selections/%5Bid%5D/details/page.tsx"
click node_reviews "https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/reviews.ts"
click node_reviewform "https://github.com/hafashproduction3/hafash/blob/main/src/components/gallery/ReviewFormSection.tsx"
click node_booking "https://github.com/hafashproduction3/hafash/blob/main/src/app/dashboard/bookings/%5Bid%5D/page.tsx"
click node_events "https://github.com/hafashproduction3/hafash/blob/main/src/app/events/%5Bid%5D/manage/page.tsx"
click node_portfolio "https://github.com/hafashproduction3/hafash/blob/main/src/app/studio/%5Bsubdomain%5D/portfolio/page.tsx"
click node_quotes "https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/quotes.ts"
click node_drive "https://github.com/hafashproduction3/hafash/blob/main/src/app/drive/page.tsx"
click node_storageactions "https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/storage.ts"
click node_storage "https://github.com/hafashproduction3/hafash/blob/main/src/lib/storage/storage.ts"
click node_r2 "https://github.com/hafashproduction3/hafash/blob/main/src/lib/storage/r2.ts"
click node_storagestats "https://github.com/hafashproduction3/hafash/blob/main/src/lib/storage/stats.ts"
click node_firebase "https://github.com/hafashproduction3/hafash/blob/main/src/firebase/init.ts"
click node_admin "https://github.com/hafashproduction3/hafash/blob/main/src/lib/firebase-admin.ts"
click node_plans "https://github.com/hafashproduction3/hafash/blob/main/src/lib/plans.ts"
click node_subscription "https://github.com/hafashproduction3/hafash/blob/main/src/lib/subscription/status.ts"
click node_checkout "https://github.com/hafashproduction3/hafash/blob/main/src/app/api/safepay/checkout/route.ts"
click node_webhook "https://github.com/hafashproduction3/hafash/blob/main/src/app/api/safepay/webhook/route.ts"
click node_receipts "https://github.com/hafashproduction3/hafash/blob/main/src/lib/email/sendPaymentReceipt.ts"
click node_expiry "https://github.com/hafashproduction3/hafash/blob/main/src/app/api/cron/check-expiry/route.ts"
click node_expiryemail "https://github.com/hafashproduction3/hafash/blob/main/src/lib/email/sendExpiryReminder.ts"
click node_network "https://github.com/hafashproduction3/hafash/blob/main/src/app/network/page.tsx"
click node_ai "https://github.com/hafashproduction3/hafash/blob/main/src/ai/flows/photographer-ai-gallery-highlights.ts"
click node_genkit "https://github.com/hafashproduction3/hafash/blob/main/src/ai/genkit.ts"
click node_safepay "https://github.com/hafashproduction3/hafash/blob/main/src/lib/safepay.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_gallery,node_selections,node_reviews,node_reviewform,node_visitor toneBlue
class node_booking,node_events,node_portfolio,node_quotes toneAmber
class node_plans,node_subscription,node_checkout,node_webhook,node_receipts,node_expiry,node_expiryemail,node_safepay toneMint
class node_drive,node_storageactions,node_storage,node_r2,node_storagestats,node_firebase,node_admin toneRose
class node_network,node_ai,node_genkit toneIndigo
```

## Components

### Client experience

- [Client galleries](https://github.com/hafashproduction3/hafash/blob/main/src/app/gallery/%5Bid%5D/page.tsx): `src/app/gallery/[id]/page.tsx`
- [Photo selections](https://github.com/hafashproduction3/hafash/blob/main/src/app/album-selections/%5Bid%5D/details/page.tsx): `src/app/album-selections/[id]/details/page.tsx`
- [Review submission](https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/reviews.ts): `src/app/actions/reviews.ts`
- [Review form](https://github.com/hafashproduction3/hafash/blob/main/src/components/gallery/ReviewFormSection.tsx): `src/components/gallery/ReviewFormSection.tsx`

### Studio operations

- [Bookings](https://github.com/hafashproduction3/hafash/blob/main/src/app/dashboard/bookings/%5Bid%5D/page.tsx): `src/app/dashboard/bookings/[id]/page.tsx`
- [Event management](https://github.com/hafashproduction3/hafash/blob/main/src/app/events/%5Bid%5D/manage/page.tsx): `src/app/events/[id]/manage/page.tsx`
- [Studio portfolio](https://github.com/hafashproduction3/hafash/blob/main/src/app/studio/%5Bsubdomain%5D/portfolio/page.tsx): `src/app/studio/[subdomain]/portfolio/page.tsx`
- [Quotes](https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/quotes.ts): `src/app/actions/quotes.ts`

### Plans and payments

- [Plan definitions](https://github.com/hafashproduction3/hafash/blob/main/src/lib/plans.ts): `src/lib/plans.ts`
- [Subscription status](https://github.com/hafashproduction3/hafash/blob/main/src/lib/subscription/status.ts): `src/lib/subscription/status.ts`
- [Safepay checkout](https://github.com/hafashproduction3/hafash/blob/main/src/app/api/safepay/checkout/route.ts): `src/app/api/safepay/checkout/route.ts`
- [Payment webhook](https://github.com/hafashproduction3/hafash/blob/main/src/app/api/safepay/webhook/route.ts): `src/app/api/safepay/webhook/route.ts`
- [Payment receipts](https://github.com/hafashproduction3/hafash/blob/main/src/lib/email/sendPaymentReceipt.ts): `src/lib/email/sendPaymentReceipt.ts`
- [Expiry reminders](https://github.com/hafashproduction3/hafash/blob/main/src/app/api/cron/check-expiry/route.ts): `src/app/api/cron/check-expiry/route.ts`
- [Reminder email](https://github.com/hafashproduction3/hafash/blob/main/src/lib/email/sendExpiryReminder.ts): `src/lib/email/sendExpiryReminder.ts`
- [Safepay service](https://github.com/hafashproduction3/hafash/blob/main/src/lib/safepay.ts): `src/lib/safepay.ts`

### Data and files

- [Photographer drive](https://github.com/hafashproduction3/hafash/blob/main/src/app/drive/page.tsx): `src/app/drive/page.tsx`
- [Storage actions](https://github.com/hafashproduction3/hafash/blob/main/src/app/actions/storage.ts): `src/app/actions/storage.ts`
- [Storage provider](https://github.com/hafashproduction3/hafash/blob/main/src/lib/storage/storage.ts): `src/lib/storage/storage.ts`
- [Cloudflare R2](https://github.com/hafashproduction3/hafash/blob/main/src/lib/storage/r2.ts): `src/lib/storage/r2.ts`
- [Storage usage stats](https://github.com/hafashproduction3/hafash/blob/main/src/lib/storage/stats.ts): `src/lib/storage/stats.ts`
- [Firebase client setup](https://github.com/hafashproduction3/hafash/blob/main/src/firebase/init.ts): `src/firebase/init.ts`
- [Firebase Admin](https://github.com/hafashproduction3/hafash/blob/main/src/lib/firebase-admin.ts): `src/lib/firebase-admin.ts`

### Network and AI

- [Photographer network](https://github.com/hafashproduction3/hafash/blob/main/src/app/network/page.tsx): `src/app/network/page.tsx`
- [AI gallery highlights](https://github.com/hafashproduction3/hafash/blob/main/src/ai/flows/photographer-ai-gallery-highlights.ts): `src/ai/flows/photographer-ai-gallery-highlights.ts`
- [Genkit runtime](https://github.com/hafashproduction3/hafash/blob/main/src/ai/genkit.ts): `src/ai/genkit.ts`

### Other components

- **Client or visitor**

## Connections

- Client or visitor → Client galleries: views
- Client or visitor → Review form: submits
- Review form → Review submission: submits review (evidence: `src/components/gallery/ReviewFormSection.tsx`)
- Client or visitor → Photo selections: selects photos
- Storage actions → Subscription status: checks plan (evidence: `src/app/actions/storage.ts`)
- Storage actions → Storage usage stats: checks quota (evidence: `src/app/actions/storage.ts`)
- Storage actions → Storage provider: signs uploads (evidence: `src/app/actions/storage.ts`)
- Storage provider → Cloudflare R2: uses provider (evidence: `src/lib/storage/storage.ts`)
- Safepay checkout → Safepay service: creates payment (evidence: `src/app/api/safepay/checkout/route.ts`)
- Safepay checkout → Firebase Admin: verifies identity (evidence: `src/app/api/safepay/checkout/route.ts`)
- Safepay checkout → Plan definitions: reads plan (evidence: `src/app/api/safepay/checkout/route.ts`)
- Payment webhook → Safepay service: checks payment (evidence: `src/app/api/safepay/webhook/route.ts`)
- Payment webhook → Firebase Admin: activates plan (evidence: `src/app/api/safepay/webhook/route.ts`)
- Payment webhook → Plan definitions: reads plan (evidence: `src/app/api/safepay/webhook/route.ts`)
- Payment webhook → Payment receipts: sends receipt (evidence: `src/app/api/safepay/webhook/route.ts`)
- Subscription status → Plan definitions: reads definitions (evidence: `src/lib/subscription/status.ts`)
- Expiry reminders → Firebase Admin: reads accounts (evidence: `src/app/api/cron/check-expiry/route.ts`)
- Expiry reminders → Reminder email: sends reminder (evidence: `src/app/api/cron/check-expiry/route.ts`)
- AI gallery highlights → Genkit runtime: uses runtime (evidence: `src/ai/flows/photographer-ai-gallery-highlights.ts`)
- Bookings → Firebase Admin: persists bookings
- Event management → Storage actions: uploads media
- Photographer drive → Storage actions: manages files
- Studio portfolio → Client or visitor: presents studio
- Photographer network → Firebase Admin: stores network data
- Quotes → Firebase Admin: stores quotes
