# 09ahmad/analytics- architecture

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

- Interactive diagram: https://gitdiagram.com/09ahmad/analytics-
- Repository: https://github.com/09ahmad/analytics-

## Overview

This is a web analytics product: site owners create projects, install a tracking script on their domains, and review collected traffic analytics in a dashboard. The sampled tracking endpoint validates the project and records aggregate visits and visitor dimensions. The tree also shows project management, authentication, bug reporting, and operational logs. Dashboard data wiring is not established by the sampled source, so those UI components are represented without speculative connections.

Main entry points: [`src/auth.ts`](https://github.com/09ahmad/analytics-/blob/main/src/auth.ts) (Authentication), [`src/lib/db.ts`](https://github.com/09ahmad/analytics-/blob/main/src/lib/db.ts) (Application database), [`src/app/api/project/route.ts`](https://github.com/09ahmad/analytics-/blob/main/src/app/api/project/route.ts) (Project API), [`src/app/api/project/[id]/route.ts`](https://github.com/09ahmad/analytics-/blob/main/src/app/api/project/%5Bid%5D/route.ts) (Project update API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Event collection"]
  node_tracking["Tracking script<br/>[tracking-script.js]"]
  node_trackapi["Track endpoint<br/>[route.ts]"]
end

subgraph group_dashboard["Analytics dashboard"]
  node_analyticsui["Analytics views<br/>[analytics.tsx]"]
  node_analyticsgraph["Analytics graph"]
  node_projectdata["Project detail<br/>[project-data.tsx]"]
end

subgraph group_projects["Project management"]
  node_projectsui["Project list<br/>[page.tsx]"]
  node_projectcreate["Project creation<br/>[create-project.tsx]"]
  node_projectapi["Project API<br/>[route.ts]"]
  node_projectitemapi["Project update API<br/>[route.ts]"]
  node_projectlogic["Project use cases<br/>[projects.ts]"]
  node_projectaccess["Project data access<br/>[projects.ts]"]
end

subgraph group_account["Identity and operations"]
  node_authui["Sign-in page<br/>[page.tsx]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_bugapi["Bug reports API<br/>[route.ts]"]
  node_settingsui["Settings views<br/>[page.tsx]"]
  node_logsapi["Logs API<br/>[route.ts]"]
end

node_sitevisitor(("Site visitor"))
node_owners(("Site owner"))
node_google["Google identity"]
node_database[("Application database<br/>[db.ts]")]

node_sitevisitor -->|"loads"| node_tracking
node_tracking -->|"sends events"| node_trackapi
node_trackapi -->|"writes aggregates"| node_database
node_owners -->|"manages projects"| node_projectsui
node_projectapi -->|"checks session"| node_auth
node_projectapi -->|"creates project"| node_database
node_projectitemapi -->|"checks session"| node_auth
node_projectitemapi -->|"updates project"| node_database
node_authui -->|"signs in"| node_auth
node_auth -.->|"authenticates with"| node_google
node_auth -->|"uses adapter"| node_database
node_bugapi -->|"checks session"| node_auth
node_bugapi -->|"reads and writes"| node_database
node_logsapi -->|"checks session"| node_auth
node_logsapi -->|"reads and writes"| node_database

click node_tracking "https://github.com/09ahmad/analytics-/blob/main/public/tracking-script.js"
click node_trackapi "https://github.com/09ahmad/analytics-/blob/main/src/app/api/track/route.ts"
click node_analyticsui "https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/analytics.tsx"
click node_analyticsgraph "https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/analytics-graph.tsx"
click node_projectdata "https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/project-data.tsx"
click node_projectsui "https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/page.tsx"
click node_projectcreate "https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/create-project.tsx"
click node_projectapi "https://github.com/09ahmad/analytics-/blob/main/src/app/api/project/route.ts"
click node_projectitemapi "https://github.com/09ahmad/analytics-/blob/main/src/app/api/project/%5Bid%5D/route.ts"
click node_projectlogic "https://github.com/09ahmad/analytics-/blob/main/src/use-cases/projects.ts"
click node_projectaccess "https://github.com/09ahmad/analytics-/blob/main/src/data-access/projects.ts"
click node_authui "https://github.com/09ahmad/analytics-/blob/main/src/app/(auth)/signin/page.tsx"
click node_auth "https://github.com/09ahmad/analytics-/blob/main/src/auth.ts"
click node_bugapi "https://github.com/09ahmad/analytics-/blob/main/src/app/api/bug-report/route.ts"
click node_settingsui "https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/settings/page.tsx"
click node_logsapi "https://github.com/09ahmad/analytics-/blob/main/src/app/api/logs/route.ts"
click node_database "https://github.com/09ahmad/analytics-/blob/main/src/lib/db.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_tracking,node_trackapi toneBlue
class node_analyticsui,node_analyticsgraph,node_projectdata,node_database toneAmber
class node_projectsui,node_projectcreate,node_projectapi,node_projectitemapi,node_projectlogic,node_projectaccess toneMint
class node_authui,node_auth,node_bugapi,node_settingsui,node_logsapi toneRose
class node_sitevisitor,node_owners,node_google toneIndigo
```

## Components

### Event collection

- [Tracking script](https://github.com/09ahmad/analytics-/blob/main/public/tracking-script.js): `public/tracking-script.js`
- [Track endpoint](https://github.com/09ahmad/analytics-/blob/main/src/app/api/track/route.ts): `src/app/api/track/route.ts`

### Analytics dashboard

- [Analytics views](https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/analytics.tsx): `src/app/(root)/projects/_components/analytics.tsx`
- [Analytics graph](https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/analytics-graph.tsx): `src/app/(root)/projects/_components/analytics-graph.tsx`
- [Project detail](https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/project-data.tsx): `src/app/(root)/projects/_components/project-data.tsx`

### Project management

- [Project list](https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/page.tsx): `src/app/(root)/projects/page.tsx`
- [Project creation](https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/projects/_components/create-project.tsx): `src/app/(root)/projects/_components/create-project.tsx`
- [Project API](https://github.com/09ahmad/analytics-/blob/main/src/app/api/project/route.ts): `src/app/api/project/route.ts`
- [Project update API](https://github.com/09ahmad/analytics-/blob/main/src/app/api/project/%5Bid%5D/route.ts): `src/app/api/project/[id]/route.ts`
- [Project use cases](https://github.com/09ahmad/analytics-/blob/main/src/use-cases/projects.ts): `src/use-cases/projects.ts`
- [Project data access](https://github.com/09ahmad/analytics-/blob/main/src/data-access/projects.ts): `src/data-access/projects.ts`

### Identity and operations

- [Sign-in page](https://github.com/09ahmad/analytics-/blob/main/src/app/(auth)/signin/page.tsx): `src/app/(auth)/signin/page.tsx`
- [Authentication](https://github.com/09ahmad/analytics-/blob/main/src/auth.ts): `src/auth.ts`
- [Bug reports API](https://github.com/09ahmad/analytics-/blob/main/src/app/api/bug-report/route.ts): `src/app/api/bug-report/route.ts`
- [Settings views](https://github.com/09ahmad/analytics-/blob/main/src/app/(root)/settings/page.tsx): `src/app/(root)/settings/page.tsx`
- [Logs API](https://github.com/09ahmad/analytics-/blob/main/src/app/api/logs/route.ts): `src/app/api/logs/route.ts`

### Other components

- **Site visitor**
- **Site owner**
- **Google identity**
- [Application database](https://github.com/09ahmad/analytics-/blob/main/src/lib/db.ts): `src/lib/db.ts`

## Connections

- Site visitor → Tracking script: loads
- Tracking script → Track endpoint: sends events
- Track endpoint → Application database: writes aggregates
- Site owner → Project list: manages projects
- Project API → Authentication: checks session
- Project API → Application database: creates project
- Project update API → Authentication: checks session
- Project update API → Application database: updates project
- Sign-in page → Authentication: signs in
- Authentication → Google identity: authenticates with
- Authentication → Application database: uses adapter
- Bug reports API → Authentication: checks session
- Bug reports API → Application database: reads and writes
- Logs API → Authentication: checks session
- Logs API → Application database: reads and writes
