# essienjoy/voucher architecture

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

- Interactive diagram: https://gitdiagram.com/essienjoy/voucher
- Repository: https://github.com/essienjoy/voucher

## Overview

#### Purpose and Runtime
This is a Next.js App Router application for a voucher-oriented account portal. It exposes public marketing/authentication pages, authenticated account pages, and an admin dashboard. The runtime is TypeScript/React on Next.js, with global styling and root document concerns in `app/layout.tsx` and `app/globals.css`.

#### Route Entry Points
The public landing route is `app/page.tsx`, composed from reusable presentation components in `app/_components/`. Authentication routes are `app/(auth)/login/page.tsx` and `app/(auth)/signup/page.tsx`. Account routes are grouped under `app/(account)/`, including dashboard, profile, voucher listing, and voucher creation; the group layout is `app/(account)/layout.tsx`. Admin access begins at `app/admin/dashboard/page.tsx`.

#### Authentication and Session Boundary
Authentication is centralized in `app/_lib/auth.ts`, with login/signup UI in `app/_components/LoginForm.tsx` and `app/_components/SignUpForm.tsx`. Supabase integration is split by execution context: browser client creation in `app/_lib/supabase/client.ts`, server-side access in `app/_lib/supabase/server.ts`, and request/session proxy support in `app/_lib/supabase/proxy.ts`.

#### Request Protection and Routing Control
The top-level `proxy.ts` is the likely request interception boundary for session refresh and route protection, delegating Supabase-specific behavior to `app/_lib/supabase/proxy.ts`. This separates cross-cutting authentication enforcement from individual pages and account-layout rendering.

#### Account Portal Flow
Authenticated users enter the shared account shell through `app/(account)/layout.tsx`, which uses account-specific navigation/presentation from `app/(account)/_components/Header.tsx`. Primary user workflows are dashboard viewing (`app/(account)/dashboard/page.tsx`), profile management (`app/(account)/profile/page.tsx`), voucher browsing (`app/(account)/voucher/page.tsx`), and voucher creation (`app/(account)/voucher/create/page.tsx`).

#### Public UI and Auth Transitions
The landing page can assemble site chrome and marketing sections from `app/_components/Header.tsx`, `app/_components/Hero.tsx`, `app/_components/About.tsx`, and `app/_components/Footer.tsx`. Authentication forms transition users into the protected account area; `app/_components/LogoutButton.tsx` provides the inverse session-ending action.

#### External Services and Deployment
Supabase is the material external backend dependency for authentication and likely persisted application data, based on the dedicated client/server/proxy modules. Next.js supplies server rendering, route handling, and deployment compatibility; the README identifies Vercel as the intended deployment platform. `next.config.ts` is the framework configuration boundary.

Main entry points: [`app/(account)/layout.tsx`](https://github.com/essienjoy/voucher/blob/main/app/(account)/layout.tsx) (Account shell), [`app/_lib/auth.ts`](https://github.com/essienjoy/voucher/blob/main/app/_lib/auth.ts) (Auth service), [`proxy.ts`](https://github.com/essienjoy/voucher/blob/main/proxy.ts) (Request proxy), [`app/_components/LoginForm.tsx`](https://github.com/essienjoy/voucher/blob/main/app/_components/LoginForm.tsx) (Auth forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js Web App"]
  node_next{{"Next.js runtime<br/>framework runtime"}}
  node_root_layout["Root layout &amp; styles<br/>document shell<br/>[layout.tsx]"]
  node_next_config["Next configuration<br/>framework config<br/>[next.config.ts]"]
  node_vercel(("Vercel<br/>deployment platform"))
end

subgraph group_public["Public &amp; Auth"]
  node_landing["Landing page<br/>public route<br/>[page.tsx]"]
  node_marketing_ui["Marketing components<br/>React components"]
  node_login["Login route<br/>auth route<br/>[page.tsx]"]
  node_signup["Signup route<br/>auth route<br/>[page.tsx]"]
  node_auth_forms["Auth forms<br/>React components<br/>[LoginForm.tsx]"]
end

subgraph group_account["Account Portal"]
  node_account_layout["Account shell<br/>protected layout<br/>[layout.tsx]"]
  node_account_header["Account header<br/>React component<br/>[Header.tsx]"]
  node_account_routes["Account workflows<br/>protected routes<br/>[page.tsx]"]
  node_admin_dashboard["Admin dashboard<br/>admin route<br/>[page.tsx]"]
  node_logout["Logout control<br/>React component<br/>[LogoutButton.tsx]"]
end

subgraph group_backend["Session &amp; Backend"]
  node_auth_service["Auth service<br/>authentication module<br/>[auth.ts]"]
  node_request_proxy{{"Request proxy<br/>request boundary<br/>[proxy.ts]"}}
  node_supabase_proxy["Supabase proxy support<br/>session middleware<br/>[proxy.ts]"]
  node_supabase_browser["Browser Supabase client<br/>browser data client<br/>[client.ts]"]
  node_supabase_server["Server Supabase client<br/>server data client<br/>[server.ts]"]
  node_supabase[("Supabase<br/>external backend")]
end

node_next -->|"renders"| node_root_layout
node_next -->|"routes"| node_landing
node_next -->|"routes"| node_login
node_next -->|"routes"| node_signup
node_next -->|"renders protected routes"| node_account_layout
node_root_layout -.->|"configured by"| node_next_config
node_landing -->|"composes"| node_marketing_ui
node_login -->|"uses"| node_auth_forms
node_signup -->|"uses"| node_auth_forms
node_auth_forms -->|"authenticates through"| node_auth_service
node_auth_service -->|"uses in browser"| node_supabase_browser
node_auth_service -->|"uses on server"| node_supabase_server
node_supabase_browser -->|"connects to"| node_supabase
node_supabase_server -->|"connects to"| node_supabase
node_request_proxy -->|"delegates session handling"| node_supabase_proxy
node_supabase_proxy -->|"refreshes session with"| node_supabase
node_request_proxy -->|"protects"| node_account_layout
node_request_proxy -->|"protects"| node_admin_dashboard
node_account_layout -->|"uses"| node_account_header
node_account_layout -->|"hosts"| node_account_routes
node_account_layout -->|"includes"| node_logout
node_logout -->|"ends session via"| node_auth_service
node_next -.->|"deploys to"| node_vercel

click node_root_layout "https://github.com/essienjoy/voucher/blob/main/app/layout.tsx"
click node_next_config "https://github.com/essienjoy/voucher/blob/main/next.config.ts"
click node_landing "https://github.com/essienjoy/voucher/blob/main/app/page.tsx"
click node_login "https://github.com/essienjoy/voucher/blob/main/app/(auth)/login/page.tsx"
click node_signup "https://github.com/essienjoy/voucher/blob/main/app/(auth)/signup/page.tsx"
click node_auth_forms "https://github.com/essienjoy/voucher/blob/main/app/_components/LoginForm.tsx"
click node_auth_service "https://github.com/essienjoy/voucher/blob/main/app/_lib/auth.ts"
click node_request_proxy "https://github.com/essienjoy/voucher/blob/main/proxy.ts"
click node_supabase_proxy "https://github.com/essienjoy/voucher/blob/main/app/_lib/supabase/proxy.ts"
click node_supabase_browser "https://github.com/essienjoy/voucher/blob/main/app/_lib/supabase/client.ts"
click node_supabase_server "https://github.com/essienjoy/voucher/blob/main/app/_lib/supabase/server.ts"
click node_account_layout "https://github.com/essienjoy/voucher/blob/main/app/(account)/layout.tsx"
click node_account_header "https://github.com/essienjoy/voucher/blob/main/app/(account)/_components/Header.tsx"
click node_account_routes "https://github.com/essienjoy/voucher/blob/main/app/(account)/dashboard/page.tsx"
click node_admin_dashboard "https://github.com/essienjoy/voucher/blob/main/app/admin/dashboard/page.tsx"
click node_logout "https://github.com/essienjoy/voucher/blob/main/app/_components/LogoutButton.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_next,node_root_layout,node_next_config,node_vercel toneBlue
class node_landing,node_marketing_ui,node_login,node_signup,node_auth_forms toneAmber
class node_account_layout,node_account_header,node_account_routes,node_admin_dashboard,node_logout toneMint
class node_auth_service,node_request_proxy,node_supabase_proxy,node_supabase_browser,node_supabase_server,node_supabase toneRose
```

## Components

### Next.js Web App

- **Next.js runtime**: framework runtime · Provides App Router rendering and route handling.
- [Root layout & styles](https://github.com/essienjoy/voucher/blob/main/app/layout.tsx): document shell · `app/layout.tsx`
- [Next configuration](https://github.com/essienjoy/voucher/blob/main/next.config.ts): framework config · `next.config.ts`
- **Vercel**: deployment platform · Intended deployment target.

### Public & Auth

- [Landing page](https://github.com/essienjoy/voucher/blob/main/app/page.tsx): public route · `app/page.tsx`
- **Marketing components**: React components · Header, hero, about, and footer compose the landing page.
- [Login route](https://github.com/essienjoy/voucher/blob/main/app/(auth)/login/page.tsx): auth route · `app/(auth)/login/page.tsx`
- [Signup route](https://github.com/essienjoy/voucher/blob/main/app/(auth)/signup/page.tsx): auth route · `app/(auth)/signup/page.tsx`
- [Auth forms](https://github.com/essienjoy/voucher/blob/main/app/_components/LoginForm.tsx): React components · Login and signup interfaces. · `app/_components/LoginForm.tsx`

### Account Portal

- [Account shell](https://github.com/essienjoy/voucher/blob/main/app/(account)/layout.tsx): protected layout · Shared authenticated portal layout and navigation. · `app/(account)/layout.tsx`
- [Account header](https://github.com/essienjoy/voucher/blob/main/app/(account)/_components/Header.tsx): React component · `app/(account)/_components/Header.tsx`
- [Account workflows](https://github.com/essienjoy/voucher/blob/main/app/(account)/dashboard/page.tsx): protected routes · Dashboard, profile, voucher listing, and voucher creation. · `app/(account)/dashboard/page.tsx`
- [Admin dashboard](https://github.com/essienjoy/voucher/blob/main/app/admin/dashboard/page.tsx): admin route · `app/admin/dashboard/page.tsx`
- [Logout control](https://github.com/essienjoy/voucher/blob/main/app/_components/LogoutButton.tsx): React component · Ends the active session. · `app/_components/LogoutButton.tsx`

### Session & Backend

- [Auth service](https://github.com/essienjoy/voucher/blob/main/app/_lib/auth.ts): authentication module · Centralizes authentication operations. · `app/_lib/auth.ts`
- [Request proxy](https://github.com/essienjoy/voucher/blob/main/proxy.ts): request boundary · Refreshes sessions and enforces protected routing. · `proxy.ts`
- [Supabase proxy support](https://github.com/essienjoy/voucher/blob/main/app/_lib/supabase/proxy.ts): session middleware · `app/_lib/supabase/proxy.ts`
- [Browser Supabase client](https://github.com/essienjoy/voucher/blob/main/app/_lib/supabase/client.ts): browser data client · `app/_lib/supabase/client.ts`
- [Server Supabase client](https://github.com/essienjoy/voucher/blob/main/app/_lib/supabase/server.ts): server data client · `app/_lib/supabase/server.ts`
- **Supabase**: external backend · Authentication and persisted application data.

## Connections

- Next.js runtime → Root layout & styles: renders
- Next.js runtime → Landing page: routes
- Next.js runtime → Login route: routes
- Next.js runtime → Signup route: routes
- Next.js runtime → Account shell: renders protected routes
- Root layout & styles → Next configuration: configured by
- Landing page → Marketing components: composes
- Login route → Auth forms: uses
- Signup route → Auth forms: uses
- Auth forms → Auth service: authenticates through
- Auth service → Browser Supabase client: uses in browser
- Auth service → Server Supabase client: uses on server
- Browser Supabase client → Supabase: connects to
- Server Supabase client → Supabase: connects to
- Request proxy → Supabase proxy support: delegates session handling
- Supabase proxy support → Supabase: refreshes session with
- Request proxy → Account shell: protects
- Request proxy → Admin dashboard: protects
- Account shell → Account header: uses
- Account shell → Account workflows: hosts
- Account shell → Logout control: includes
- Logout control → Auth service: ends session via
- Next.js runtime → Vercel: deploys to
