# alghamdima/aaaasd architecture

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

- Interactive diagram: https://gitdiagram.com/alghamdima/aaaasd
- Repository: https://github.com/alghamdima/aaaasd

## Overview

1. **Repository shape**
   This is a Turborepo monorepo with three customer-facing apps under `apps/` and a large set of reusable packages under `packages/`. The top-level goal is “ship everywhere”: web, mobile, and browser extension share the same product domain, auth, billing, UI, and content systems.

2. **Client surfaces**
   - `apps/web`: Next.js App Router app for marketing, auth, dashboard, and admin.
   - `apps/mobile`: Expo Router app for onboarding, auth, user/organization dashboards, billing, and settings.
   - `apps/extension`: WXT-based browser extension with background, content script, popup, side panel, new tab, options, tabs, and devtools pages.
   Each app has its own route tree and app shell, but the domain modules are structured similarly across platforms.

3. **Central API layer**
   `packages/api` is the main backend service layer. It is organized by domain modules (`auth`, `billing`, `organization`, `storage`, `admin`, `ai`) with router, query, and mutation files. The web app exposes a catch-all `/api/[...route]` handler that proxies into this API layer, while mobile and extension use app-local API clients to talk to the same backend contract.

4. **Authentication boundary**
   `packages/auth` is the shared auth core, with separate client entry points for web and mobile plus server utilities. App code in `apps/web` and `apps/mobile` wraps it with platform-specific auth screens, forms, and layouts. Auth-related flows include login, registration, password reset, email verification, two-factor auth, passkeys on web, and invitation flows tied to organizations.

5. **Billing boundary**
   Billing is split into shared business logic and provider adapters:
   - `packages/billing/shared` holds plans, features, prices, subscriptions, and status mapping.
   - `packages/billing/web` supports web commerce providers such as Stripe, Lemon Squeezy, and Polar.
   - `packages/billing/mobile` supports mobile subscription providers such as RevenueCat and Superwall.
   The apps consume this through their billing modules and settings pages, while provider-specific webhook handling lives in the billing packages.

6. **Domain modules in the apps**
   The app code is organized by business domain rather than by technical layer:
   - `auth`, `billing`, `organization`, `user`, `admin`, `marketing`, `common`
   - mobile adds setup/onboarding and native-specific helpers
   - web adds richer admin dashboards and marketing pages
   These modules own screen composition, forms, tables, navigation, and page-level state.

7. **Content and marketing**
   `packages/cms` holds localized MDX content for blog and legal pages. The web app’s marketing routes render this content into blog listings, blog detail pages, and legal pages. This is a clear boundary: editorial content is separated from product data and lives in a dedicated content package.

8. **Shared UI and design system**
   `packages/ui` is split by platform:
   - `packages/ui/web` contains the web component library, including data-table primitives, dialogs, sidebar, sheet, charts, etc.
   - `packages/ui/mobile` contains native components such as sheets, dropdowns, inputs, tabs, and themed controls.
   - `packages/ui/shared` contains shared assets, SVGs, theme tokens, and global styles.
   App modules build screens from these primitives rather than duplicating component logic.

9. **Cross-cutting infrastructure packages**
   Several packages provide app-wide concerns:
   - `packages/i18n` for translations and locale helpers, used by both web and mobile.
   - `packages/analytics` for provider-agnostic tracking across web, mobile, and extension.
   - `packages/monitoring` for error/performance reporting.
   - `packages/email` for transactional templates and provider adapters.
   - `packages/storage` for object storage abstraction.
   - `packages/shared` for common types, logging, schemas, IDs, pagination, and utility helpers.
   These packages sit below the app/domain layer and are intended to be reused across all surfaces.

10. **Data and persistence**
    `packages/db` contains the database schema, migrations, seed/reset scripts, and server helpers. It is the persistence boundary for auth and billing data, and likely backs the API layer’s query/mutation modules. Drizzle migrations indicate schema-first relational persistence rather than a document store.

11. **Platform-specific runtime behavior**
    The three apps differ meaningfully at the runtime boundary:
    - Web is server/client hybrid with locale-aware routes, admin views, and proxy/API routing.
    - Mobile is native-first, with Expo-specific providers, focus/refetch hooks, theme handling, and native billing integrations.
    - Extension has browser-context splits: background script, content script, and UI entrypoints.
    Shared business logic is intentionally kept outside these runtimes so it can be reused without leaking platform assumptions.

12. **Operational/tooling layer**
    The repo is built and governed with Turborepo, pnpm workspaces, TypeScript, Vitest, Oxlint/Oxfmt, and GitHub Actions. There are dedicated workflows for testing and publishing web/mobile/extension artifacts, plus scripts for migrations, versioning, and development setup. This makes the monorepo a coordinated multi-target product system rather than a collection of unrelated apps.

Main entry points: [`apps/web`](https://github.com/alghamdima/aaaasd/tree/main/apps/web) (Web), [`apps/mobile`](https://github.com/alghamdima/aaaasd/tree/main/apps/mobile) (Mobile), [`packages/api`](https://github.com/alghamdima/aaaasd/tree/main/packages/api) (API), [`apps/extension`](https://github.com/alghamdima/aaaasd/tree/main/apps/extension) (Extension)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Apps"]
  node_web["Web<br/>Next.js app"]
  node_mobile["Mobile<br/>Expo app"]
  node_extension["Extension<br/>WXT app"]
end

subgraph group_packages["Packages"]
  node_api["API<br/>Domain backend"]
  node_auth["Auth"]
  node_billing_shared["Billing Core<br/>Billing domain"]
  node_billing_web["Billing Web<br/>Web providers"]
  node_billing_mobile["Billing Mobile<br/>Mobile providers"]
  node_cms["CMS<br/>MDX content"]
  node_ui_web["UI Web<br/>Web design system"]
  node_ui_mobile["UI Mobile<br/>Native design system"]
  node_ui_shared["UI Shared<br/>Tokens/assets"]
  node_i18n["i18n<br/>Translations"]
  node_analytics["Analytics<br/>Tracking adapters"]
  node_monitoring["Monitoring<br/>Error reporting"]
  node_email["Email<br/>Templates/adapters"]
  node_storage["Storage"]
  node_db[("Database<br/>Drizzle schema")]
  node_shared["Shared<br/>Common utilities"]
end

subgraph group_tooling["Tooling"]
  node_tooling["Tooling"]
end

node_web -->|"routes through"| node_api
node_mobile -->|"calls"| node_api
node_extension -->|"calls"| node_api
node_web -->|"uses"| node_auth
node_mobile -->|"uses"| node_auth
node_web -->|"uses"| node_billing_web
node_mobile -->|"uses"| node_billing_mobile
node_web -->|"renders"| node_cms
node_web -->|"builds with"| node_ui_web
node_mobile -->|"builds with"| node_ui_mobile
node_web -->|"shares"| node_ui_shared
node_mobile -->|"shares"| node_ui_shared
node_extension -->|"shares"| node_ui_shared
node_web -->|"uses"| node_i18n
node_mobile -->|"uses"| node_i18n
node_extension -->|"reports"| node_analytics
node_web -->|"reports"| node_analytics
node_mobile -->|"reports"| node_analytics
node_web -->|"reports"| node_monitoring
node_mobile -->|"reports"| node_monitoring
node_extension -->|"reports"| node_monitoring
node_web -->|"sends"| node_email
node_web -->|"uses"| node_storage
node_mobile -->|"uses"| node_storage
node_api -->|"persists to"| node_db
node_api -->|"depends on"| node_auth
node_api -->|"depends on"| node_billing_shared
node_api -->|"depends on"| node_storage
node_web -->|"uses"| node_shared
node_mobile -->|"uses"| node_shared
node_extension -->|"uses"| node_shared
node_tooling -.->|"governs"| node_web
node_tooling -.->|"governs"| node_mobile
node_tooling -.->|"governs"| node_extension
node_tooling -.->|"governs"| node_api

click node_web "https://github.com/alghamdima/aaaasd/tree/main/apps/web"
click node_mobile "https://github.com/alghamdima/aaaasd/tree/main/apps/mobile"
click node_extension "https://github.com/alghamdima/aaaasd/tree/main/apps/extension"
click node_api "https://github.com/alghamdima/aaaasd/tree/main/packages/api"
click node_auth "https://github.com/alghamdima/aaaasd/tree/main/packages/auth"
click node_billing_shared "https://github.com/alghamdima/aaaasd/tree/main/packages/billing/shared"
click node_billing_web "https://github.com/alghamdima/aaaasd/tree/main/packages/billing/web"
click node_billing_mobile "https://github.com/alghamdima/aaaasd/tree/main/packages/billing/mobile"
click node_cms "https://github.com/alghamdima/aaaasd/tree/main/packages/cms"
click node_ui_web "https://github.com/alghamdima/aaaasd/tree/main/packages/ui/web"
click node_ui_mobile "https://github.com/alghamdima/aaaasd/tree/main/packages/ui/mobile"
click node_ui_shared "https://github.com/alghamdima/aaaasd/tree/main/packages/ui/shared"
click node_i18n "https://github.com/alghamdima/aaaasd/tree/main/packages/i18n"
click node_analytics "https://github.com/alghamdima/aaaasd/tree/main/packages/analytics"
click node_monitoring "https://github.com/alghamdima/aaaasd/tree/main/packages/monitoring"
click node_email "https://github.com/alghamdima/aaaasd/tree/main/packages/email"
click node_storage "https://github.com/alghamdima/aaaasd/tree/main/packages/storage"
click node_db "https://github.com/alghamdima/aaaasd/tree/main/packages/db"
click node_shared "https://github.com/alghamdima/aaaasd/tree/main/packages/shared"
click node_tooling "https://github.com/alghamdima/aaaasd/tree/main/tooling"

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_web,node_mobile,node_extension toneBlue
class node_api,node_auth,node_billing_shared,node_billing_web,node_billing_mobile,node_cms,node_ui_web,node_ui_mobile,node_ui_shared,node_i18n,node_analytics,node_monitoring,node_email,node_storage,node_db,node_shared toneAmber
class node_tooling toneMint
```

## Components

### Apps

Customer-facing runtime surfaces

- [Web](https://github.com/alghamdima/aaaasd/tree/main/apps/web): Next.js app · Marketing, auth, dashboard, and admin surface · `apps/web`
- [Mobile](https://github.com/alghamdima/aaaasd/tree/main/apps/mobile): Expo app · Native onboarding, dashboards, billing, and settings · `apps/mobile`
- [Extension](https://github.com/alghamdima/aaaasd/tree/main/apps/extension): WXT app · Browser extension with background and UI entrypoints · `apps/extension`

### Packages

Shared domain, platform, and infrastructure libraries

- [API](https://github.com/alghamdima/aaaasd/tree/main/packages/api): Domain backend · Shared router/query/mutation service layer · `packages/api`
- [Auth](https://github.com/alghamdima/aaaasd/tree/main/packages/auth): Auth core · Shared authentication client and server utilities · `packages/auth`
- [Billing Core](https://github.com/alghamdima/aaaasd/tree/main/packages/billing/shared): Billing domain · Plans, prices, subscriptions, and status mapping · `packages/billing/shared`
- [Billing Web](https://github.com/alghamdima/aaaasd/tree/main/packages/billing/web): Web providers · Stripe, Lemon Squeezy, and Polar integrations · `packages/billing/web`
- [Billing Mobile](https://github.com/alghamdima/aaaasd/tree/main/packages/billing/mobile): Mobile providers · RevenueCat and Superwall integrations · `packages/billing/mobile`
- [CMS](https://github.com/alghamdima/aaaasd/tree/main/packages/cms): MDX content · Localized blog and legal content · `packages/cms`
- [UI Web](https://github.com/alghamdima/aaaasd/tree/main/packages/ui/web): Web design system · Web components, tables, dialogs, sidebar, charts · `packages/ui/web`
- [UI Mobile](https://github.com/alghamdima/aaaasd/tree/main/packages/ui/mobile): Native design system · Mobile components and themed controls · `packages/ui/mobile`
- [UI Shared](https://github.com/alghamdima/aaaasd/tree/main/packages/ui/shared): Tokens/assets · Shared assets, SVGs, themes, and styles · `packages/ui/shared`
- [i18n](https://github.com/alghamdima/aaaasd/tree/main/packages/i18n): Translations · Shared locale helpers and language bundles · `packages/i18n`
- [Analytics](https://github.com/alghamdima/aaaasd/tree/main/packages/analytics): Tracking adapters · Provider-agnostic analytics for all surfaces · `packages/analytics`
- [Monitoring](https://github.com/alghamdima/aaaasd/tree/main/packages/monitoring): Error reporting · Shared Sentry/PostHog-style observability adapters · `packages/monitoring`
- [Email](https://github.com/alghamdima/aaaasd/tree/main/packages/email): Templates/adapters · Transactional email templates and providers · `packages/email`
- [Storage](https://github.com/alghamdima/aaaasd/tree/main/packages/storage): Object storage · S3-style storage abstraction and server helpers · `packages/storage`
- [Database](https://github.com/alghamdima/aaaasd/tree/main/packages/db): Drizzle schema · Relational persistence, migrations, and seed scripts · `packages/db`
- [Shared](https://github.com/alghamdima/aaaasd/tree/main/packages/shared): Common utilities · Types, logging, schemas, IDs, and helpers · `packages/shared`

### Tooling

Repo-wide build, lint, and automation

- [Tooling](https://github.com/alghamdima/aaaasd/tree/main/tooling): Repo tooling · Turborepo, TypeScript, linting, testing, and scripts · `tooling`

## Connections

- Web → API: routes through · Web API handler proxies into shared backend contract
- Mobile → API: calls · Native app uses local API client against shared contract
- Extension → API: calls · Extension uses local API client against shared contract
- Web → Auth: uses · Web auth screens and server/client wrappers
- Mobile → Auth: uses · Mobile auth flows and platform wrappers
- Web → Billing Web: uses · Web commerce and billing portal integrations
- Mobile → Billing Mobile: uses · Native billing and subscription integrations
- Web → CMS: renders · Marketing pages and legal/blog routes consume MDX content
- Web → UI Web: builds with · Web screens use the web component library
- Mobile → UI Mobile: builds with · Native screens use the mobile component library
- Web → UI Shared: shares · Web uses shared tokens, icons, and styles
- Mobile → UI Shared: shares · Mobile uses shared tokens, icons, and styles
- Extension → UI Shared: shares · Extension uses shared tokens, icons, and styles
- Web → i18n: uses · Locale-aware web routes and text
- Mobile → i18n: uses · Mobile localization and language helpers
- Extension → Analytics: reports · Extension tracking and provider wiring
- Web → Analytics: reports · Web analytics providers and page views
- Mobile → Analytics: reports · Mobile analytics providers and permissions
- Web → Monitoring: reports · Web error/performance instrumentation
- Mobile → Monitoring: reports · Mobile error/performance instrumentation
- Extension → Monitoring: reports · Extension error/performance instrumentation
- Web → Email: sends · Auth and contact email flows
- Web → Storage: uses · Web-facing storage boundary for app features
- Mobile → Storage: uses · Native storage boundary for app features
- API → Database: persists to · API queries and mutations sit over relational persistence
- API → Auth: depends on · Auth domain feeds shared backend contract
- API → Billing Core: depends on · Billing routes use shared billing rules
- API → Storage: depends on · Storage router wraps shared storage package
- Web → Shared: uses · Common types, logging, schemas, and utilities
- Mobile → Shared: uses · Common types, logging, schemas, and utilities
- Extension → Shared: uses · Common types, logging, schemas, and utilities
- Tooling → Web: governs · Build, lint, and test setup for web app
- Tooling → Mobile: governs · Build, lint, and test setup for mobile app
- Tooling → Extension: governs · Build, lint, and test setup for extension
- Tooling → API: governs · Build, lint, and test setup for API package
