← Back to App

Architecture

v1.0

This document describes the system architecture for the Celerity POC Tracker, including the data model, entity relationships, and technology stack.

Overview

The application uses a multi-tenant architecture where each organization operates with isolated data. The system is built on Convex for the backend, which provides real-time data synchronization and TypeScript-first APIs.

Multi-Tenant
Data isolation per org
Real-Time
Convex subscriptions
Role-Based
Org & client-level
Type-Safe
End-to-end TypeScript

Data Model

The data model follows a hierarchical structure with organizations as the root tenant.

organizations

Root tenant container. Each organization has isolated data and its own set of team members and clients.

FieldTypeDescription
namestringDisplay name
slugstringURL-safe identifier
createdAtnumberUnix timestamp
teamMembers

Junction table linking users to organizations with role assignments.

FieldTypeDescription
userIdId<users>Reference to user
organizationIdId<organizations>Reference to org
roleadmin | account_manager | viewerOrg-level permission
clients

Customer accounts (brands) within an organization.

FieldTypeDescription
organizationIdId<organizations>Parent organization
namestringClient/brand name
isActivebooleanActive status
channels

Advertising platforms (lookup table shared across organizations).

FieldTypeDescription
namestringPlatform name
slugstringURL-safe identifier
iconUrlstring?Optional icon URL
clientChannels

Junction table enabling clients to use specific channels.

FieldTypeDescription
clientIdId<clients>Reference to client
channelIdId<channels>Reference to channel
isActivebooleanActive status
campaignGroups

Container for campaigns within a client-channel combination.

FieldTypeDescription
clientChannelIdId<clientChannels>Parent client-channel
namestringGroup name
weeklyBudgetnumber?Budget allocation
campaigns

Individual advertising campaigns with performance targets.

FieldTypeDescription
campaignGroupIdId<campaignGroups>Parent group
namestringCampaign name
targetRoasnumber?Target ROAS
weeklyMetrics

Weekly performance data for each campaign.

FieldTypeDescription
campaignIdId<campaigns>Parent campaign
weekStartstringISO date (Monday)
adSpendnumberSpend in dollars
salesnumberSales in dollars
roasnumberReturn on ad spend

Entity Relationships

The schema uses junction tables for many-to-many relationships.

organizations
    │
    ├── teamMembers ──────► users
    │
    └── clients
            │
            └── clientChannels ──────► channels (lookup)
                    │
                    └── campaignGroups
                            │
                            └── campaigns
                                    │
                                    └── weeklyMetrics

One-to-Many

  • • organizations → clients
  • • clients → clientChannels
  • • campaignGroups → campaigns
  • • campaigns → weeklyMetrics

Many-to-Many (via junction)

  • • users ↔ organizations (via teamMembers)
  • • clients ↔ channels (via clientChannels)

Technology Stack

ConvexBackend & Database

Real-time backend platform providing database, serverless functions, and authentication. Generates TypeScript types from schema definitions.

Next.js 15Frontend Framework

React framework with App Router architecture. Uses server and client components with Turbopack for development.

Tailwind CSSStyling

Utility-first CSS framework with custom design tokens. Supports dark/light themes via CSS variables.

shadcn/uiComponent Library

Accessible component primitives built on Radix UI. Components are copied into the codebase rather than imported as a dependency.

TypeScriptLanguage

Used throughout the stack. Convex automatically generates types from schema, providing end-to-end type safety.

VercelDeployment

Hosting platform for the Next.js frontend. Convex backend is hosted separately on Convex Cloud.

Implementation Status

Implemented

  • Multi-tenant data model
  • Organization-level role-based access
  • Team member management
  • Client and channel configuration
  • Campaign group and campaign management
  • Weekly metrics tracking
  • Real-time data sync
  • Email authentication (magic links)
  • Dark/light theme

Not Yet Implemented

  • Subscription billing
  • Self-service organization signup
  • Custom domains per organization
  • External API access
  • SSO/SAML authentication
  • Audit logging
  • Client-level role assignments