# 6931503045-design/lumen_line architecture

> Architecture diagram of the GitHub repository 6931503045-design/lumen_line, 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/6931503045-design/lumen_line
- Repository: https://github.com/6931503045-design/lumen_line

## Overview

JOD tang is a Thai personal-finance bot with a LINE interface and a same-origin web dashboard. Its main flow is: a LINE message is authenticated and dispatched, fixed commands or the quick parser handle supported input, transaction services apply finance rules and persist results, and LINE replies with text or a card. README documents additional AI-assisted interpretation and receipt reading, but the sampled AI router is a stub and image handling was not sampled, so those branches are shown as documented capabilities without invented call wiring. The tree also shows email import, recurring transactions, savings plans, budgets, summaries, and scheduled jobs; the sampled job registry does not include daily summaries.

Main entry points: [`src/handlers/textHandler.ts`](https://github.com/6931503045-design/lumen_line/blob/main/src/handlers/textHandler.ts) (Text handler), [`src/routes/api.ts`](https://github.com/6931503045-design/lumen_line/blob/main/src/routes/api.ts) (Web API), [`src/db/queries`](https://github.com/6931503045-design/lumen_line/tree/main/src/db/queries) (Database queries), [`src/services/transaction.service.ts`](https://github.com/6931503045-design/lumen_line/blob/main/src/services/transaction.service.ts) (Transactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["LINE interaction"]
  node_webhook["Webhook endpoint<br/>[webhook.ts]"]
  node_text_handler["Text handler<br/>[textHandler.ts]"]
  node_postback_handler["Postback handler<br/>[postbackHandler.ts]"]
  node_line_reply["LINE replies<br/>[reply.ts]"]
  node_line_push["LINE push<br/>[push.ts]"]
end

subgraph group_finance["Finance services"]
  node_commands["Commands<br/>[command.service.ts]"]
  node_quick_parser["Quick parser<br/>[regexParser.ts]"]
  node_transactions["Transactions"]
  node_budgets["Budgets<br/>[budget.service.ts]"]
  node_categories["Categories"]
  node_summaries["Summaries<br/>[summary.service.ts]"]
  node_plans["Savings plans<br/>[plan.service.ts]"]
  node_recurring["Recurring rules"]
end

subgraph group_imports["AI and imports"]
  node_ai_router["AI interpretation<br/>[router.ts]"]
  node_ai_guard["AI safeguards<br/>[guard.ts]"]
  node_receipt["Receipt vision<br/>[vision.ts]"]
  node_email_import["Bank email import<br/>[email.service.ts]"]
end

subgraph group_webjobs["Web and jobs"]
  node_web_app["Web dashboard<br/>[app.js]"]
  node_api["Web API<br/>[api.ts]"]
  node_jobs_route["Job endpoint<br/>[jobs.ts]"]
  node_job_registry["Job registry<br/>[index.ts]"]
  node_recurring_job["Recurring job<br/>[recurringJob.ts]"]
  node_email_job["Email polling job<br/>[emailPoll.ts]"]
  node_cleanup_job["Cleanup job<br/>[cleanup.ts]"]
  node_plan_job["Plan check job<br/>[planCheck.ts]"]
end

subgraph group_storage["Persistence"]
  node_queries["Database queries"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_database[("Supabase database")]
end

node_line_user(("LINE user"))

node_line_user -->|"sends events"| node_webhook
node_webhook -->|"dispatches text"| node_text_handler
node_webhook -->|"dispatches postback"| node_postback_handler
node_text_handler -->|"checks commands"| node_commands
node_text_handler -->|"parses text"| node_quick_parser
node_text_handler -->|"creates transaction"| node_transactions
node_text_handler -->|"formats alert"| node_budgets
node_text_handler -->|"sends reply"| node_line_reply
node_text_handler -->|"sends card"| node_line_reply
node_postback_handler -->|"undoes transaction"| node_transactions
node_postback_handler -->|"saves to plan"| node_plans
node_postback_handler -->|"sends reply"| node_line_reply
node_commands -->|"requests summary"| node_summaries
node_commands -->|"runs savings command"| node_plans
node_transactions -->|"reads and writes"| node_queries
node_budgets -->|"reads and writes"| node_queries
node_categories -->|"reads and writes"| node_queries
node_summaries -->|"reads data"| node_queries
node_plans -->|"reads and writes"| node_queries
node_plans -->|"creates transfer"| node_transactions
node_recurring -->|"reads and writes"| node_queries
node_web_app -->|"requests data"| node_api
node_api -->|"manages transactions"| node_transactions
node_api -->|"manages budgets"| node_budgets
node_api -->|"manages categories"| node_categories
node_api -->|"requests summaries"| node_summaries
node_api -->|"manages plans"| node_plans
node_api -->|"manages rules"| node_recurring
node_jobs_route -->|"dispatches jobs"| node_job_registry
node_job_registry -->|"runs recurring"| node_recurring_job
node_job_registry -->|"runs email poll"| node_email_job
node_job_registry -->|"runs cleanup"| node_cleanup_job
node_job_registry -->|"runs plan check"| node_plan_job
node_recurring_job -->|"creates due entries"| node_recurring
node_email_job -->|"polls email"| node_email_import
node_email_import -->|"imports transactions"| node_transactions
node_queries -->|"uses client"| node_supabase
node_supabase -->|"queries"| node_database
node_text_handler -.->|"interprets fallback"| node_ai_router
node_ai_router -.->|"uses safeguards"| node_ai_guard
node_line_user -.->|"sends receipt image"| node_receipt
node_receipt -.->|"returns for confirmation"| node_line_reply
node_line_push -->|"sends notifications"| node_line_user

click node_webhook "https://github.com/6931503045-design/lumen_line/blob/main/src/routes/webhook.ts"
click node_text_handler "https://github.com/6931503045-design/lumen_line/blob/main/src/handlers/textHandler.ts"
click node_postback_handler "https://github.com/6931503045-design/lumen_line/blob/main/src/handlers/postbackHandler.ts"
click node_line_reply "https://github.com/6931503045-design/lumen_line/blob/main/src/line/reply.ts"
click node_line_push "https://github.com/6931503045-design/lumen_line/blob/main/src/line/push.ts"
click node_commands "https://github.com/6931503045-design/lumen_line/blob/main/src/services/command.service.ts"
click node_quick_parser "https://github.com/6931503045-design/lumen_line/blob/main/src/utils/regexParser.ts"
click node_transactions "https://github.com/6931503045-design/lumen_line/blob/main/src/services/transaction.service.ts"
click node_budgets "https://github.com/6931503045-design/lumen_line/blob/main/src/services/budget.service.ts"
click node_categories "https://github.com/6931503045-design/lumen_line/blob/main/src/services/category.service.ts"
click node_summaries "https://github.com/6931503045-design/lumen_line/blob/main/src/services/summary.service.ts"
click node_plans "https://github.com/6931503045-design/lumen_line/blob/main/src/services/plan.service.ts"
click node_recurring "https://github.com/6931503045-design/lumen_line/blob/main/src/services/recurring.service.ts"
click node_ai_router "https://github.com/6931503045-design/lumen_line/blob/main/src/services/ai/router.ts"
click node_ai_guard "https://github.com/6931503045-design/lumen_line/blob/main/src/services/ai/guard.ts"
click node_receipt "https://github.com/6931503045-design/lumen_line/blob/main/src/services/ai/vision.ts"
click node_email_import "https://github.com/6931503045-design/lumen_line/blob/main/src/services/email.service.ts"
click node_web_app "https://github.com/6931503045-design/lumen_line/blob/main/web/js/app.js"
click node_api "https://github.com/6931503045-design/lumen_line/blob/main/src/routes/api.ts"
click node_jobs_route "https://github.com/6931503045-design/lumen_line/blob/main/src/routes/jobs.ts"
click node_job_registry "https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/index.ts"
click node_recurring_job "https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/recurringJob.ts"
click node_email_job "https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/emailPoll.ts"
click node_cleanup_job "https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/cleanup.ts"
click node_plan_job "https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/planCheck.ts"
click node_queries "https://github.com/6931503045-design/lumen_line/tree/main/src/db/queries"
click node_supabase "https://github.com/6931503045-design/lumen_line/blob/main/src/db/supabase.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_webhook,node_text_handler,node_postback_handler,node_line_reply,node_line_push,node_line_user toneBlue
class node_commands,node_quick_parser,node_transactions,node_budgets,node_categories,node_summaries,node_plans,node_recurring toneAmber
class node_ai_router,node_ai_guard,node_receipt,node_email_import toneMint
class node_web_app,node_api,node_jobs_route,node_job_registry,node_recurring_job,node_email_job,node_cleanup_job,node_plan_job toneRose
class node_queries,node_supabase,node_database toneIndigo
```

## Components

### LINE interaction

- [Webhook endpoint](https://github.com/6931503045-design/lumen_line/blob/main/src/routes/webhook.ts): `src/routes/webhook.ts`
- [Text handler](https://github.com/6931503045-design/lumen_line/blob/main/src/handlers/textHandler.ts): `src/handlers/textHandler.ts`
- [Postback handler](https://github.com/6931503045-design/lumen_line/blob/main/src/handlers/postbackHandler.ts): `src/handlers/postbackHandler.ts`
- [LINE replies](https://github.com/6931503045-design/lumen_line/blob/main/src/line/reply.ts): `src/line/reply.ts`
- [LINE push](https://github.com/6931503045-design/lumen_line/blob/main/src/line/push.ts): `src/line/push.ts`

### Finance services

- [Commands](https://github.com/6931503045-design/lumen_line/blob/main/src/services/command.service.ts): `src/services/command.service.ts`
- [Quick parser](https://github.com/6931503045-design/lumen_line/blob/main/src/utils/regexParser.ts): `src/utils/regexParser.ts`
- [Transactions](https://github.com/6931503045-design/lumen_line/blob/main/src/services/transaction.service.ts): `src/services/transaction.service.ts`
- [Budgets](https://github.com/6931503045-design/lumen_line/blob/main/src/services/budget.service.ts): `src/services/budget.service.ts`
- [Categories](https://github.com/6931503045-design/lumen_line/blob/main/src/services/category.service.ts): `src/services/category.service.ts`
- [Summaries](https://github.com/6931503045-design/lumen_line/blob/main/src/services/summary.service.ts): `src/services/summary.service.ts`
- [Savings plans](https://github.com/6931503045-design/lumen_line/blob/main/src/services/plan.service.ts): `src/services/plan.service.ts`
- [Recurring rules](https://github.com/6931503045-design/lumen_line/blob/main/src/services/recurring.service.ts): `src/services/recurring.service.ts`

### AI and imports

- [AI interpretation](https://github.com/6931503045-design/lumen_line/blob/main/src/services/ai/router.ts): `src/services/ai/router.ts`
- [AI safeguards](https://github.com/6931503045-design/lumen_line/blob/main/src/services/ai/guard.ts): `src/services/ai/guard.ts`
- [Receipt vision](https://github.com/6931503045-design/lumen_line/blob/main/src/services/ai/vision.ts): `src/services/ai/vision.ts`
- [Bank email import](https://github.com/6931503045-design/lumen_line/blob/main/src/services/email.service.ts): `src/services/email.service.ts`

### Web and jobs

- [Web dashboard](https://github.com/6931503045-design/lumen_line/blob/main/web/js/app.js): `web/js/app.js`
- [Web API](https://github.com/6931503045-design/lumen_line/blob/main/src/routes/api.ts): `src/routes/api.ts`
- [Job endpoint](https://github.com/6931503045-design/lumen_line/blob/main/src/routes/jobs.ts): `src/routes/jobs.ts`
- [Job registry](https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/index.ts): `src/jobs/index.ts`
- [Recurring job](https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/recurringJob.ts): `src/jobs/recurringJob.ts`
- [Email polling job](https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/emailPoll.ts): `src/jobs/emailPoll.ts`
- [Cleanup job](https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/cleanup.ts): `src/jobs/cleanup.ts`
- [Plan check job](https://github.com/6931503045-design/lumen_line/blob/main/src/jobs/planCheck.ts): `src/jobs/planCheck.ts`

### Persistence

- [Database queries](https://github.com/6931503045-design/lumen_line/tree/main/src/db/queries): `src/db/queries`
- [Supabase client](https://github.com/6931503045-design/lumen_line/blob/main/src/db/supabase.ts): `src/db/supabase.ts`
- **Supabase database**

### Other components

- **LINE user**

## Connections

- LINE user → Webhook endpoint: sends events
- Webhook endpoint → Text handler: dispatches text
- Webhook endpoint → Postback handler: dispatches postback
- Text handler → Commands: checks commands
- Text handler → Quick parser: parses text
- Text handler → Transactions: creates transaction
- Text handler → Budgets: formats alert
- Text handler → LINE replies: sends reply
- Text handler → LINE replies: sends card
- Postback handler → Transactions: undoes transaction
- Postback handler → Savings plans: saves to plan
- Postback handler → LINE replies: sends reply
- Commands → Summaries: requests summary
- Commands → Savings plans: runs savings command
- Transactions → Database queries: reads and writes
- Budgets → Database queries: reads and writes
- Categories → Database queries: reads and writes
- Summaries → Database queries: reads data
- Savings plans → Database queries: reads and writes
- Savings plans → Transactions: creates transfer
- Recurring rules → Database queries: reads and writes
- Web dashboard → Web API: requests data
- Web API → Transactions: manages transactions
- Web API → Budgets: manages budgets
- Web API → Categories: manages categories
- Web API → Summaries: requests summaries
- Web API → Savings plans: manages plans
- Web API → Recurring rules: manages rules
- Job endpoint → Job registry: dispatches jobs
- Job registry → Recurring job: runs recurring
- Job registry → Email polling job: runs email poll
- Job registry → Cleanup job: runs cleanup
- Job registry → Plan check job: runs plan check
- Recurring job → Recurring rules: creates due entries
- Email polling job → Bank email import: polls email
- Bank email import → Transactions: imports transactions
- Database queries → Supabase client: uses client
- Supabase client → Supabase database: queries
- Text handler → AI interpretation: interprets fallback
- AI interpretation → AI safeguards: uses safeguards
- LINE user → Receipt vision: sends receipt image
- Receipt vision → LINE replies: returns for confirmation
- LINE push → LINE user: sends notifications
