# ronavp/subscription-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/ronavp/subscription-tracker
- Repository: https://github.com/ronavp/subscription-tracker

## Overview

Subscription Tracker imports bank CSVs, normalizes transactions with AI, detects likely recurring charges, and presents subscriptions and spending answers. The main path is upload → merchant analysis → recurrence detection; users can also adjust their share of a bill, ask questions, or clear the dataset. The README documents these product stages and capabilities; sampled route code confirms their main dependencies and storage operations. UploadForm’s implementation was not sampled, so its documented workflow links are shown without asserting its internal request sequencing.

Main entry points: [`lib/db.ts`](https://github.com/ronavp/subscription-tracker/blob/main/lib/db.ts) (Prisma client), [`app/page.tsx`](https://github.com/ronavp/subscription-tracker/blob/main/app/page.tsx) (Home page), [`components/UploadForm.tsx`](https://github.com/ronavp/subscription-tracker/blob/main/components/UploadForm.tsx) (CSV upload), [`app/api/upload/route.ts`](https://github.com/ronavp/subscription-tracker/blob/main/app/api/upload/route.ts) (Import transactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_home["Home page<br/>[page.tsx]"]
  node_uploadform["CSV upload<br/>[UploadForm.tsx]"]
  node_sublist["Subscription list"]
  node_chatbox["Spending chat<br/>[ChatBox.tsx]"]
end

subgraph group_ingestion["Transaction processing"]
  node_upload["Import transactions<br/>[route.ts]"]
  node_csv["CSV parsing<br/>[csv.ts]"]
  node_analyze["Clean merchants<br/>[route.ts]"]
end

subgraph group_intelligence["Subscription intelligence"]
  node_detectroute["Detect subscriptions<br/>[route.ts]"]
  node_detection["Recurrence math<br/>[detection.ts]"]
  node_chatroute["Answer questions<br/>[route.ts]"]
end

subgraph group_persistence["Persistence"]
  node_listapi["List subscriptions<br/>[route.ts]"]
  node_updateapi["Adjust user share<br/>[route.ts]"]
  node_resetapi["Clear dataset<br/>[route.ts]"]
  node_prisma["Prisma client<br/>[db.ts]"]
  node_database[("Application database<br/>[schema.prisma]")]
end

node_user(("User"))
node_anthropic{{"Claude API"}}

node_user -->|"uses"| node_home
node_home -->|"renders"| node_uploadform
node_home -->|"renders"| node_sublist
node_home -->|"renders"| node_chatbox
node_home -->|"loads list"| node_listapi
node_home -->|"requests reset"| node_resetapi
node_uploadform -->|"uploads CSV"| node_upload
node_uploadform -->|"requests analysis"| node_analyze
node_uploadform -->|"requests detection"| node_detectroute
node_upload -->|"parses rows"| node_csv
node_upload -->|"infers columns"| node_anthropic
node_upload -->|"stores transactions"| node_prisma
node_analyze -->|"reads and updates"| node_prisma
node_analyze -->|"normalizes merchants"| node_anthropic
node_detectroute -->|"reads and saves"| node_prisma
node_detectroute -->|"checks recurrence"| node_detection
node_detectroute -->|"judges matches"| node_anthropic
node_chatbox -->|"sends question"| node_chatroute
node_chatroute -->|"reads subscriptions"| node_prisma
node_chatroute -->|"normalizes spend"| node_detection
node_chatroute -->|"requests answer"| node_anthropic
node_sublist -->|"saves share"| node_updateapi
node_sublist -->|"refreshes list"| node_home
node_listapi -->|"reads subscriptions"| node_prisma
node_updateapi -->|"updates subscription"| node_prisma
node_resetapi -->|"deletes records"| node_prisma
node_prisma -->|"queries and persists"| node_database

click node_home "https://github.com/ronavp/subscription-tracker/blob/main/app/page.tsx"
click node_uploadform "https://github.com/ronavp/subscription-tracker/blob/main/components/UploadForm.tsx"
click node_sublist "https://github.com/ronavp/subscription-tracker/blob/main/components/SubscriptionList.tsx"
click node_chatbox "https://github.com/ronavp/subscription-tracker/blob/main/components/ChatBox.tsx"
click node_upload "https://github.com/ronavp/subscription-tracker/blob/main/app/api/upload/route.ts"
click node_csv "https://github.com/ronavp/subscription-tracker/blob/main/lib/csv.ts"
click node_analyze "https://github.com/ronavp/subscription-tracker/blob/main/app/api/analyze/route.ts"
click node_detectroute "https://github.com/ronavp/subscription-tracker/blob/main/app/api/detect/route.ts"
click node_detection "https://github.com/ronavp/subscription-tracker/blob/main/lib/detection.ts"
click node_chatroute "https://github.com/ronavp/subscription-tracker/blob/main/app/api/chat/route.ts"
click node_listapi "https://github.com/ronavp/subscription-tracker/blob/main/app/api/subscriptions/route.ts"
click node_updateapi "https://github.com/ronavp/subscription-tracker/blob/main/app/api/subscriptions/%5Bid%5D/route.ts"
click node_resetapi "https://github.com/ronavp/subscription-tracker/blob/main/app/api/reset/route.ts"
click node_prisma "https://github.com/ronavp/subscription-tracker/blob/main/lib/db.ts"
click node_database "https://github.com/ronavp/subscription-tracker/blob/main/prisma/schema.prisma"

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_home,node_uploadform,node_sublist,node_chatbox,node_user toneBlue
class node_upload,node_csv,node_analyze toneAmber
class node_detectroute,node_detection,node_chatroute,node_anthropic toneMint
class node_listapi,node_updateapi,node_resetapi,node_prisma,node_database toneRose
```

## Components

### User interface

- [Home page](https://github.com/ronavp/subscription-tracker/blob/main/app/page.tsx): `app/page.tsx`
- [CSV upload](https://github.com/ronavp/subscription-tracker/blob/main/components/UploadForm.tsx): `components/UploadForm.tsx`
- [Subscription list](https://github.com/ronavp/subscription-tracker/blob/main/components/SubscriptionList.tsx): `components/SubscriptionList.tsx`
- [Spending chat](https://github.com/ronavp/subscription-tracker/blob/main/components/ChatBox.tsx): `components/ChatBox.tsx`

### Transaction processing

- [Import transactions](https://github.com/ronavp/subscription-tracker/blob/main/app/api/upload/route.ts): `app/api/upload/route.ts`
- [CSV parsing](https://github.com/ronavp/subscription-tracker/blob/main/lib/csv.ts): `lib/csv.ts`
- [Clean merchants](https://github.com/ronavp/subscription-tracker/blob/main/app/api/analyze/route.ts): `app/api/analyze/route.ts`

### Subscription intelligence

- [Detect subscriptions](https://github.com/ronavp/subscription-tracker/blob/main/app/api/detect/route.ts): `app/api/detect/route.ts`
- [Recurrence math](https://github.com/ronavp/subscription-tracker/blob/main/lib/detection.ts): `lib/detection.ts`
- [Answer questions](https://github.com/ronavp/subscription-tracker/blob/main/app/api/chat/route.ts): `app/api/chat/route.ts`

### Persistence

- [List subscriptions](https://github.com/ronavp/subscription-tracker/blob/main/app/api/subscriptions/route.ts): `app/api/subscriptions/route.ts`
- [Adjust user share](https://github.com/ronavp/subscription-tracker/blob/main/app/api/subscriptions/%5Bid%5D/route.ts): `app/api/subscriptions/[id]/route.ts`
- [Clear dataset](https://github.com/ronavp/subscription-tracker/blob/main/app/api/reset/route.ts): `app/api/reset/route.ts`
- [Prisma client](https://github.com/ronavp/subscription-tracker/blob/main/lib/db.ts): `lib/db.ts`
- [Application database](https://github.com/ronavp/subscription-tracker/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Other components

- **User**
- **Claude API**

## Connections

- User → Home page: uses
- Home page → CSV upload: renders
- Home page → Subscription list: renders
- Home page → Spending chat: renders
- Home page → List subscriptions: loads list
- Home page → Clear dataset: requests reset
- CSV upload → Import transactions: uploads CSV
- CSV upload → Clean merchants: requests analysis
- CSV upload → Detect subscriptions: requests detection
- Import transactions → CSV parsing: parses rows
- Import transactions → Claude API: infers columns
- Import transactions → Prisma client: stores transactions
- Clean merchants → Prisma client: reads and updates
- Clean merchants → Claude API: normalizes merchants
- Detect subscriptions → Prisma client: reads and saves
- Detect subscriptions → Recurrence math: checks recurrence
- Detect subscriptions → Claude API: judges matches
- Spending chat → Answer questions: sends question
- Answer questions → Prisma client: reads subscriptions
- Answer questions → Recurrence math: normalizes spend
- Answer questions → Claude API: requests answer
- Subscription list → Adjust user share: saves share
- Subscription list → Home page: refreshes list
- List subscriptions → Prisma client: reads subscriptions
- Adjust user share → Prisma client: updates subscription
- Clear dataset → Prisma client: deletes records
- Prisma client → Application database: queries and persists
