# sbktckp/clipency-finance-tracker architecture

> Architecture diagram of the GitHub repository sbktckp/clipency-finance-tracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sbktckp/clipency-finance-tracker
- Repository: https://github.com/sbktckp/clipency-finance-tracker

## Overview

#### Purpose and entry points
Clipency Finance Tracker is an internal Next.js finance-operations dashboard consolidating marketplace revenue and operational costs. The public landing route is `app/page.tsx`; authenticated users enter through `app/login/page.tsx`. The App Router root layout and global styling are defined in `app/layout.tsx` and `app/globals.css`.

#### Application shell and shared state
Authenticated finance modules are expected to share a consistent navigation and page frame through `components/app-shell.tsx` and `components/sidebar.tsx`. Cross-page currency selection/state is centralized in `components/currency-context.tsx`, exposed through `components/currency-switch.tsx`, and mounted with application-level providers in `components/providers.tsx`.

#### Authentication and security boundary
Supabase is the backend and identity boundary, initialized by `lib/supabase.ts`. Access beyond login is gated by Supabase Auth plus membership/role checks in the shared `admin_users` data model. Client-side money-moving operations must not write tables directly: mutations are delegated to protected Supabase `SECURITY DEFINER` RPCs guarded by `cx_is_admin()`.

#### Finance operations modules
The principal accounting surfaces are route-level App Router pages: incoming money at `app/credits/page.tsx`, outgoing spending at `app/debits/page.tsx`, account/fund balances at `app/funds/page.tsx`, and campaign-linked spend at `app/campaigns/page.tsx`. These modules consolidate data from the Supabase project shared with the main Clipency marketplace, separating operational presentation from backend financial authorization.

#### Analysis, calculation, and audit stages
The dashboard summary is served by `app/dashboard/page.tsx`; forward cash-flow views and reporting are represented by `app/projections/page.tsx` and `app/reports/page.tsx`. Core aggregation/calculation workflows have a dedicated surface in `app/engine/page.tsx`. Financial governance is split into point-in-time records (`app/snapshots/page.tsx`), tax preparation (`app/tax/page.tsx`), and action auditing (`app/logs/page.tsx`).

#### Administrative and people operations
Privileged administration is isolated at `app/admin/page.tsx`, consistent with the admin-role access model. Team and payroll-related finance records are handled through `app/team/page.tsx`. This separation makes admin controls, personnel costs, and transaction/accounting workflows distinct operational domains.

#### Runtime and presentation infrastructure
The runtime is Next.js 16 App Router with React 19 and TypeScript, deployed with environment-held credentials (not repository secrets), likely Vercel per the README. Tailwind CSS v4 provides styling; financial visualization is concentrated in `components/finance-charts.tsx` using Recharts. The marketing/landing composition is separate from internal operations under `components/landing/`, including `components/landing/FinanceDashboard.tsx` and `components/landing/HeroSection.tsx`.

Main entry points: [`components/sidebar.tsx`](https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/sidebar.tsx) (Sidebar navigation), [`lib/supabase.ts`](https://github.com/sbktckp/clipency-finance-tracker/blob/main/lib/supabase.ts) (Supabase client), [`app/engine/page.tsx`](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/engine/page.tsx) (Calculation engine), [`app/layout.tsx`](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/layout.tsx) (Root layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["App Shell &amp; Presentation"]
  node_root_layout["Root layout<br/>Next.js layout<br/>[layout.tsx]"]
  node_providers["App providers<br/>React providers<br/>[providers.tsx]"]
  node_currency_context["Currency state<br/>React context"]
  node_app_shell["Authenticated shell<br/>shared UI<br/>[app-shell.tsx]"]
  node_sidebar["Sidebar navigation<br/>shared UI<br/>[sidebar.tsx]"]
  node_landing["Public landing<br/>App Router page<br/>[page.tsx]"]
  node_login["Login<br/>App Router page<br/>[page.tsx]"]
  node_finance_charts["Finance charts<br/>visualization<br/>[finance-charts.tsx]"]
end

subgraph group_operations["Finance Operations"]
  node_dashboard["Dashboard summary<br/>App Router page<br/>[page.tsx]"]
  node_ledger_ops["Credits, debits &amp; funds<br/>finance pages"]
  node_campaigns["Campaign spend<br/>App Router page<br/>[page.tsx]"]
  node_team["Team &amp; payroll<br/>App Router page<br/>[page.tsx]"]
end

subgraph group_governance["Analysis &amp; Governance"]
  node_engine["Calculation engine<br/>App Router page<br/>[page.tsx]"]
  node_projections["Cash-flow projections<br/>App Router page<br/>[page.tsx]"]
  node_reports["Reports<br/>App Router page<br/>[page.tsx]"]
  node_governance_records["Snapshots, tax &amp; logs<br/>finance pages"]
  node_admin["Administration<br/>App Router page<br/>[page.tsx]"]
end

subgraph group_backend["Supabase Security Boundary"]
  node_supabase_client[("Supabase client<br/>backend client<br/>[supabase.ts]")]
  node_auth_roles{{"Auth &amp; admin membership<br/>access control"}}
  node_protected_rpcs{{"Protected finance RPCs<br/>SECURITY DEFINER RPCs"}}
end

node_root_layout -->|"mounts"| node_providers
node_providers -->|"provides"| node_currency_context
node_root_layout -->|"routes"| node_landing
node_login -->|"authenticates with"| node_supabase_client
node_supabase_client -->|"enforces"| node_auth_roles
node_auth_roles -->|"permits access to"| node_app_shell
node_app_shell -->|"contains"| node_sidebar
node_sidebar -->|"navigates to"| node_dashboard
node_sidebar -->|"navigates to"| node_ledger_ops
node_sidebar -->|"navigates to"| node_campaigns
node_sidebar -->|"navigates to"| node_team
node_sidebar -->|"navigates to"| node_projections
node_sidebar -->|"navigates to"| node_reports
node_sidebar -->|"navigates to"| node_governance_records
node_sidebar -->|"navigates to"| node_admin
node_ledger_ops -->|"reads finance data"| node_supabase_client
node_campaigns -->|"reads finance data"| node_supabase_client
node_team -->|"reads finance data"| node_supabase_client
node_engine -->|"aggregates data"| node_supabase_client
node_engine -->|"feeds"| node_projections
node_engine -->|"feeds"| node_reports
node_dashboard -->|"renders"| node_finance_charts
node_ledger_ops -->|"mutates through"| node_protected_rpcs
node_protected_rpcs -->|"requires admin check"| node_auth_roles
node_admin -->|"requires"| node_auth_roles

click node_root_layout "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/layout.tsx"
click node_providers "https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/providers.tsx"
click node_currency_context "https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/currency-context.tsx"
click node_app_shell "https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/app-shell.tsx"
click node_sidebar "https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/sidebar.tsx"
click node_landing "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/page.tsx"
click node_login "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/login/page.tsx"
click node_dashboard "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/dashboard/page.tsx"
click node_campaigns "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/campaigns/page.tsx"
click node_team "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/team/page.tsx"
click node_engine "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/engine/page.tsx"
click node_projections "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/projections/page.tsx"
click node_reports "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/reports/page.tsx"
click node_admin "https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/admin/page.tsx"
click node_finance_charts "https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/finance-charts.tsx"
click node_supabase_client "https://github.com/sbktckp/clipency-finance-tracker/blob/main/lib/supabase.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_root_layout,node_providers,node_currency_context,node_app_shell,node_sidebar,node_landing,node_login,node_finance_charts toneBlue
class node_dashboard,node_ledger_ops,node_campaigns,node_team toneAmber
class node_engine,node_projections,node_reports,node_governance_records,node_admin toneMint
class node_supabase_client,node_auth_roles,node_protected_rpcs toneRose
```

## Components

### App Shell & Presentation

- [Root layout](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/layout.tsx): Next.js layout · Mounts global styles and application structure. · `app/layout.tsx`
- [App providers](https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/providers.tsx): React providers · Mounts shared application-level state. · `components/providers.tsx`
- [Currency state](https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/currency-context.tsx): React context · Cross-page currency selection state. · `components/currency-context.tsx`
- [Authenticated shell](https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/app-shell.tsx): shared UI · Provides the finance navigation and page frame. · `components/app-shell.tsx`
- [Sidebar navigation](https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/sidebar.tsx): shared UI · `components/sidebar.tsx`
- [Public landing](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/page.tsx): App Router page · Public entry route. · `app/page.tsx`
- [Login](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/login/page.tsx): App Router page · Authentication entry route. · `app/login/page.tsx`
- [Finance charts](https://github.com/sbktckp/clipency-finance-tracker/blob/main/components/finance-charts.tsx): visualization · Recharts-based financial visualization. · `components/finance-charts.tsx`

### Finance Operations

- [Dashboard summary](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/dashboard/page.tsx): App Router page · Consolidated finance overview. · `app/dashboard/page.tsx`
- **Credits, debits & funds**: finance pages · Incoming money, spending, and account balances.
- [Campaign spend](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/campaigns/page.tsx): App Router page · Campaign-linked spending records. · `app/campaigns/page.tsx`
- [Team & payroll](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/team/page.tsx): App Router page · Personnel-related finance records. · `app/team/page.tsx`

### Analysis & Governance

- [Calculation engine](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/engine/page.tsx): App Router page · Dedicated aggregation and calculation workflow. · `app/engine/page.tsx`
- [Cash-flow projections](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/projections/page.tsx): App Router page · `app/projections/page.tsx`
- [Reports](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/reports/page.tsx): App Router page · `app/reports/page.tsx`
- **Snapshots, tax & logs**: finance pages · Point-in-time records, tax preparation, and action auditing.
- [Administration](https://github.com/sbktckp/clipency-finance-tracker/blob/main/app/admin/page.tsx): App Router page · Privileged administration surface. · `app/admin/page.tsx`

### Supabase Security Boundary

- [Supabase client](https://github.com/sbktckp/clipency-finance-tracker/blob/main/lib/supabase.ts): backend client · Backend and identity integration. · `lib/supabase.ts`
- **Auth & admin membership**: access control · Supabase Auth plus admin_users role checks gate access.
- **Protected finance RPCs**: SECURITY DEFINER RPCs · Money-moving mutations require cx_is_admin().

## Connections

- Root layout → App providers: mounts
- App providers → Currency state: provides
- Root layout → Public landing: routes
- Login → Supabase client: authenticates with
- Supabase client → Auth & admin membership: enforces
- Auth & admin membership → Authenticated shell: permits access to
- Authenticated shell → Sidebar navigation: contains
- Sidebar navigation → Dashboard summary: navigates to
- Sidebar navigation → Credits, debits & funds: navigates to
- Sidebar navigation → Campaign spend: navigates to
- Sidebar navigation → Team & payroll: navigates to
- Sidebar navigation → Cash-flow projections: navigates to
- Sidebar navigation → Reports: navigates to
- Sidebar navigation → Snapshots, tax & logs: navigates to
- Sidebar navigation → Administration: navigates to
- Credits, debits & funds → Supabase client: reads finance data
- Campaign spend → Supabase client: reads finance data
- Team & payroll → Supabase client: reads finance data
- Calculation engine → Supabase client: aggregates data
- Calculation engine → Cash-flow projections: feeds
- Calculation engine → Reports: feeds
- Dashboard summary → Finance charts: renders
- Credits, debits & funds → Protected finance RPCs: mutates through
- Protected finance RPCs → Auth & admin membership: requires admin check
- Administration → Auth & admin membership: requires
