[5.2] Agency Admin View

1. Front Matter

  • Title: Agency Admin View

  • Author: scorevi/dyorgie (Backend/Frontend)

  • Reviewers: scorevi/dyorgie (Backend/Frontend)

  • Created: February 2026

  • Status: Approved

  • References:

    • Issue: [5.2] Agency Admin View #44

    • Milestone: [5] Dashboards


2. Introduction & Goals

  • Problem Summary: Agency administrators need a centralized dashboard to manage team productivity, branding settings, and AI resource allocation.

  • Goals:

    • Provide token quota management (slider control)

    • Enable agency branding (logo upload)

    • Display team member overview with usage stats

    • Show reviewer analytics

  • Non-Goals:

    • Individual user billing management

    • Cross-agency analytics

    • Agency creation wizard

  • Glossary:

    • Token Quota: Max AI tokens allocated per user per month

    • Agency Branding: Custom logo displayed in dashboard header


3. High-Level Architecture

  • System Diagram:

image.png
  • Technologies Used:

    • Supabase - Agency data storage

    • Supabase Storage - Logo uploads

    • Shadcn Slider - Token quota control

    • React Hook Form - Settings form


4. Detailed Design & Implementation

  • Data Model / Schema:

agencies table:

Column

Type

Description

id

UUID PK

Auto-generated

name

TEXT

Agency name

owner_id

TEXT

Clerk ID of admin

logo_url

TEXT

Uploaded logo URL

max_tokens_per_user

INTEGER

Token quota (default: 100000)

created_at

TIMESTAMPTZ

Creation time

agency_members table:

Column

Type

Description

agency_id

UUID FK

Agency reference

user_id

TEXT

Member Clerk ID

role

TEXT

Member role

tokens_used

INTEGER

Monthly usage

  • API Specification:

    • GET /api/agency/settings - Fetch agency settings

    • PATCH /api/agency/settings - Update settings

    • POST /api/agency/upload-logo - Upload agency logo

    • GET /api/agency/members - List team members

  • Logic & Workflows:

Token quota control settings:

  • Range: 0 – 1,000,000 tokens

  • Default: 100,000 tokens

  • Step: 10,000 tokens

  • Display: Live cost estimate

Logo upload flow:

  1. User selects image (PNG/JPG, max 2MB)

  2. Live preview displayed

  3. On save → upload to Supabase Storage

  4. URL saved to agencies.logo_url

  5. Header updates with new logo

  • Key Files:

    • app/agency/page.tsx - Dashboard page

    • components/agency/AgencySettingsForm.tsx - Settings form

    • components/agency/TeamMemberList.tsx - Member list

    • components/agency/ReviewerAnalyticsCard.tsx - Analytics display


5. Infrastructure & Operations

  • Dependencies:

    • Supabase DB - Agency data

    • Supabase Storage - Logo storage

  • Monitoring & Alerting: No specific monitoring required.

  • Deployment Plan:

    1. Run agencies and agency_members migrations

    2. Deploy UI components

    3. No feature flags needed


6. Testing & Quality Assurance

  • Test Strategy:

    • Manual: Settings update, logo upload

    • Integration: Token quota enforcement

  • Known Limitations:

    • Logo max size: 2MB

    • No logo cropping (must upload correctly sized)

    • Single admin per agency


7. Maintenance & Support

  • Troubleshooting:

    • Logo not displaying → Check Storage bucket permissions

    • Token quota not enforcing → Verify member agency_id link

  • Changelog:

    • 1.0 (Feb 2026): Initial implementation


Document Version

1.0 - Approved, Feature deployed to production, 02/26/2026


Was this article helpful?