# thsigyyy678b/daily-whatsapp-wins architecture

> Architecture diagram of the GitHub repository thsigyyy678b/daily-whatsapp-wins, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thsigyyy678b/daily-whatsapp-wins
- Repository: https://github.com/thsigyyy678b/daily-whatsapp-wins

## Overview

#### Purpose and delivery model
Daily WhatsApp Challenge is a client-rendered marketplace: users complete WhatsApp-status tasks for rewards, while businesses purchase and operate status-ad campaigns. It is a TypeScript React SPA built with Vite/Bun and deployable as static GitHub Pages or to conventional static hosts. Browser clients call Supabase directly using publishable-key environment variables.

Key deployment path: `.github/workflows/deploy.yml`; application bootstrap: `src/start.ts`, `src/server.ts`.

#### Application bootstrap and routing
The route tree defines the primary product surfaces: public landing/authentication, user dashboard, business dashboard, and administrator panel. Routing must support a configurable base path for GitHub Pages and SPA hosting.

- Router construction/base path: `src/router.tsx`
- Root document/layout and global providers: `src/routes/__root.tsx`
- Generated route registration: `src/routeTree.gen.ts`

Primary endpoints are represented by route modules, not server APIs: `src/routes/index.tsx`, `src/routes/dashboard.tsx`, `src/routes/business.tsx`, `src/routes/admin.tsx`.

#### Identity and access boundary
Authentication is application-managed rather than Supabase Auth. User and business credentials are stored/validated through app data; super-admin credentials are explicitly hardcoded. Role selection after login controls access to user, business, or admin routes and operations.

- Session and admin credential logic: `src/lib/session.ts`
- Unified login: `src/routes/login.tsx`
- User and business onboarding: `src/routes/signup-user.tsx`, `src/routes/signup-business.tsx`

This is the main security boundary: the documented model uses plaintext credentials and unrestricted anon-role database CRUD, so it is unsuitable for production without auth, server-side authorization, and RLS.

#### Supabase persistence layer
Supabase is the sole backend/data API, accessed directly from the browser. The initial migration establishes operational entities: users, businesses, tasks, assignments/submissions, campaigns, withdrawals, wallet history, and globally editable settings.

- Supabase client/environment integration: `src/lib/supabase.ts`
- Schema bootstrap: `supabase/migrations/20260101000000_init.sql`
- Shared application limits/settings-related policy: `src/lib/limits.ts`

The database is the source of truth for wallets, task lifecycle, campaign lifecycle, payout requests, and admin-configured URLs/package values.

#### Core product workflows
User flow: sign up → authenticate → receive/perform eligible tasks → submit status proof → earn wallet entries after approval → request withdrawals; referrals and free-task limits are governed by settings. Business flow: sign up → select package/manage campaign → submit ad creative and campaign details. Admin flow: review and control users, tasks, submissions, businesses, campaigns, withdrawals, and settings.

- User work/reward surface: `src/routes/dashboard.tsx`
- Business campaign surface: `src/routes/business.tsx`
- Operational approval/configuration surface: `src/routes/admin.tsx`

Task creatives, proof screenshots, campaign images, and carousel images are Google Drive share links transformed client-side into direct-view URLs; Google Drive is therefore an external content dependency.

#### UI composition and client boundaries
Page modules own feature workflows and compose a shared header plus a local shadcn-style UI component library. Global styles establish the premium black/green visual system. There is no indicated dedicated API server, background worker, or payment-provider integration; UPI configuration is stored as settings for payout guidance/QR use.

- Shared navigation: `src/components/site-header.tsx`
- Reusable UI primitives: `src/components/ui/`
- Global styles: `src/styles.css`

#### Reliability and publishing
Client errors are captured/reported through Lovable-oriented helpers and route-level error handling. GitHub Pages builds in static SPA mode, including a 404 shell for refresh fallback; other hosts need the same Supabase public environment variables.

- Error capture/reporting: `src/lib/error-capture.ts`, `src/lib/lovable-error-reporting.ts`
- Error-page handling: `src/lib/error-page.ts`
- Static deployment workflow: `.github/workflows/deploy.yml`

Main entry points: [`src/router.tsx`](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/router.tsx) (Router and base path), [`src/routes/dashboard.tsx`](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/dashboard.tsx) (User work and wallet), [`src/lib/session.ts`](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/session.ts) (Session and roles), [`src/routes/business.tsx`](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/business.tsx) (Campaign management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_spa["React SPA"]
  node_bootstrap["App bootstrap<br/>Vite entry<br/>[start.ts]"]
  node_server["Static server entry<br/>SPA entry<br/>[server.ts]"]
  node_router["Router and base path<br/>routing<br/>[router.tsx]"]
  node_root["Root layout<br/>providers/layout<br/>[__root.tsx]"]
  node_public["Landing and auth<br/>public routes<br/>[index.tsx]"]
  node_login["Login and onboarding<br/>identity routes<br/>[login.tsx]"]
  node_session{{"Session and roles<br/>access control<br/>[session.ts]"}}
  node_user_dashboard["User work and wallet<br/>user dashboard<br/>[dashboard.tsx]"]
  node_business_dashboard["Campaign management<br/>business dashboard<br/>[business.tsx]"]
  node_admin["Operations admin<br/>admin panel<br/>[admin.tsx]"]
  node_shared_ui["Shared UI and styles<br/>component library<br/>[site-header.tsx]"]
  node_error_handling["Error reporting<br/>client reliability<br/>[error-capture.ts]"]
end

subgraph group_data["Supabase"]
  node_supabase_client["Supabase browser client<br/>data client<br/>[supabase.ts]"]
  node_database[("Operational database<br/>Supabase schema")]
  node_limits["Limits and settings policy<br/>application policy<br/>[limits.ts]"]
end

subgraph group_external["External dependencies"]
  node_google_drive["Google Drive content<br/>external media"]
end

subgraph group_delivery["Publishing"]
  node_github_pages["GitHub Pages deployment<br/>static publishing<br/>[deploy.yml]"]
end

node_github_pages -->|"publishes static app"| node_bootstrap
node_bootstrap -->|"initializes"| node_server
node_bootstrap -->|"mounts"| node_router
node_router -->|"renders within"| node_root
node_router -->|"public route"| node_public
node_router -->|"identity routes"| node_login
node_router -->|"user route"| node_user_dashboard
node_router -->|"business route"| node_business_dashboard
node_router -->|"admin route"| node_admin
node_login -->|"authenticates via"| node_session
node_session -->|"authorizes user role"| node_user_dashboard
node_session -->|"authorizes business role"| node_business_dashboard
node_session -->|"authorizes admin role"| node_admin
node_user_dashboard -->|"reads and writes"| node_supabase_client
node_business_dashboard -->|"reads and writes"| node_supabase_client
node_admin -->|"operates and configures"| node_supabase_client
node_supabase_client -->|"direct browser CRUD"| node_database
node_limits -->|"governs eligibility"| node_user_dashboard
node_database -->|"stores editable settings"| node_limits
node_user_dashboard -->|"loads proof and task media"| node_google_drive
node_business_dashboard -->|"loads campaign media"| node_google_drive
node_root -->|"composes"| node_shared_ui
node_router -.->|"reports route errors"| node_error_handling

click node_bootstrap "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/start.ts"
click node_server "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/server.ts"
click node_router "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/router.tsx"
click node_root "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/__root.tsx"
click node_public "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/index.tsx"
click node_login "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/login.tsx"
click node_session "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/session.ts"
click node_user_dashboard "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/dashboard.tsx"
click node_business_dashboard "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/business.tsx"
click node_admin "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/admin.tsx"
click node_shared_ui "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/components/site-header.tsx"
click node_error_handling "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/error-capture.ts"
click node_supabase_client "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/supabase.ts"
click node_database "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/supabase/migrations/20260101000000_init.sql"
click node_limits "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/limits.ts"
click node_github_pages "https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/.github/workflows/deploy.yml"

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_bootstrap,node_server,node_router,node_root,node_public,node_login,node_session,node_user_dashboard,node_business_dashboard,node_admin,node_shared_ui,node_error_handling toneBlue
class node_supabase_client,node_database,node_limits toneAmber
class node_google_drive toneMint
class node_github_pages toneRose
```

## Components

### React SPA

Client-rendered product surfaces and shared UI.

- [App bootstrap](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/start.ts): Vite entry · `src/start.ts`
- [Static server entry](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/server.ts): SPA entry · `src/server.ts`
- [Router and base path](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/router.tsx): routing · Supports GitHub Pages base paths and SPA routing. · `src/router.tsx`
- [Root layout](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/__root.tsx): providers/layout · `src/routes/__root.tsx`
- [Landing and auth](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/index.tsx): public routes · `src/routes/index.tsx`
- [Login and onboarding](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/login.tsx): identity routes · Unified login plus user and business signup flows. · `src/routes/login.tsx`
- [Session and roles](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/session.ts): access control · App-managed credentials select user, business, or admin access. · `src/lib/session.ts`
- [User work and wallet](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/dashboard.tsx): user dashboard · Tasks, proof submission, rewards, referrals, and withdrawals. · `src/routes/dashboard.tsx`
- [Campaign management](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/business.tsx): business dashboard · Packages, creative, and campaign operations. · `src/routes/business.tsx`
- [Operations admin](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/routes/admin.tsx): admin panel · Reviews entities, approvals, withdrawals, and settings. · `src/routes/admin.tsx`
- [Shared UI and styles](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/components/site-header.tsx): component library · `src/components/site-header.tsx`
- [Error reporting](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/error-capture.ts): client reliability · Route errors are captured through Lovable-oriented helpers. · `src/lib/error-capture.ts`

### Supabase

Browser-accessed persistence boundary.

- [Supabase browser client](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/supabase.ts): data client · Uses publishable environment variables from the browser. · `src/lib/supabase.ts`
- [Operational database](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/supabase/migrations/20260101000000_init.sql): Supabase schema · Source of truth for identities, workflows, wallets, campaigns, and settings. · `supabase/migrations/20260101000000_init.sql`
- [Limits and settings policy](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/src/lib/limits.ts): application policy · Applies shared task and settings-related limits. · `src/lib/limits.ts`

### External dependencies

- **Google Drive content**: external media · Share links are transformed client-side for creatives and proof images.

### Publishing

- [GitHub Pages deployment](https://github.com/thsigyyy678b/daily-whatsapp-wins/blob/main/.github/workflows/deploy.yml): static publishing · Builds a static SPA with a 404 refresh fallback. · `.github/workflows/deploy.yml`

## Connections

- GitHub Pages deployment → App bootstrap: publishes static app
- App bootstrap → Static server entry: initializes
- App bootstrap → Router and base path: mounts
- Router and base path → Root layout: renders within
- Router and base path → Landing and auth: public route
- Router and base path → Login and onboarding: identity routes
- Router and base path → User work and wallet: user route
- Router and base path → Campaign management: business route
- Router and base path → Operations admin: admin route
- Login and onboarding → Session and roles: authenticates via
- Session and roles → User work and wallet: authorizes user role
- Session and roles → Campaign management: authorizes business role
- Session and roles → Operations admin: authorizes admin role
- User work and wallet → Supabase browser client: reads and writes
- Campaign management → Supabase browser client: reads and writes
- Operations admin → Supabase browser client: operates and configures
- Supabase browser client → Operational database: direct browser CRUD · Anon-role access is the principal security boundary.
- Limits and settings policy → User work and wallet: governs eligibility
- Operational database → Limits and settings policy: stores editable settings
- User work and wallet → Google Drive content: loads proof and task media
- Campaign management → Google Drive content: loads campaign media
- Root layout → Shared UI and styles: composes
- Router and base path → Error reporting: reports route errors
