# 1-ken/fx-alert architecture

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

- Interactive diagram: https://gitdiagram.com/1-ken/fx-alert
- Repository: https://github.com/1-ken/fx-alert

## Overview

This is a trading analytics web app for monitoring instruments, configuring alerts, and reviewing market behavior through backtests and prediction scorecards. A trader’s alert workflow runs from the alert form through alert state and a market snapshot; analytics workflows submit backtest or prediction requests and present results. Authentication and bootstrap support the application’s account setup, while charting, subscriptions, and administration are distinct product areas. The graph follows the supplied tree and source index; unsampled modules are represented where their paths are known, but uncertain runtime connections are omitted.

Main entry points: [`components/alerts/create-alert-form.tsx`](https://github.com/1-ken/fx-alert/blob/main/components/alerts/create-alert-form.tsx) (Alert form), [`app/api/analytics/backtest/route.ts`](https://github.com/1-ken/fx-alert/blob/main/app/api/analytics/backtest/route.ts) (Backtest endpoint), [`app/api/analytics/predictions/route.ts`](https://github.com/1-ken/fx-alert/blob/main/app/api/analytics/predictions/route.ts) (Prediction endpoint), [`components/bootstrap-provider.tsx`](https://github.com/1-ken/fx-alert/blob/main/components/bootstrap-provider.tsx) (Bootstrap provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Market experience"]
  node_dashboard["Dashboard<br/>[dashboard-page.tsx]"]
  node_instrument["Instrument detail"]
  node_tradingchart["Trading chart"]
end

subgraph group_alerts["Alerting"]
  node_alertsform["Alert form"]
  node_alertstate["Alert state<br/>[use-alerts.ts]"]
  node_snapshot["Market snapshot<br/>[use-snapshot.ts]"]
  node_alertapi["Alert endpoints<br/>[route.ts]"]
  node_notifications["Triggered notifications"]
end

subgraph group_analytics["Analytics"]
  node_backtestui["Backtest experience<br/>[backtest-page.tsx]"]
  node_backtesthook["Backtest data hook<br/>[use-backtest.ts]"]
  node_backtestapi["Backtest endpoint<br/>[route.ts]"]
  node_history["Historical data retrieval<br/>[history-ensure.ts]"]
  node_predictionui["Prediction scorecard"]
  node_predictionhook["Prediction data hook"]
  node_predictionapi["Prediction endpoint<br/>[route.ts]"]
  node_scorecard["Scorecard logic"]
end

subgraph group_platform["Account platform"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_bootstrap["Bootstrap provider"]
  node_bootstrapapi["Bootstrap API client<br/>[bootstrap.ts]"]
  node_onboarding["Onboarding"]
  node_subscriptions["Subscription controls<br/>[paywall-modal.tsx]"]
  node_admin["Admin panel<br/>[admin-panel.tsx]"]
end

node_trader(("Trader"))
node_analyticsservice["Analytics service"]
node_observer["Observer API"]

node_trader -->|"configures"| node_alertsform
node_alertsform -->|"creates alerts"| node_alertstate
node_alertsform -->|"reads snapshot"| node_snapshot
node_alertsform -->|"reads account setup"| node_bootstrap
node_trader -->|"views markets"| node_dashboard
node_trader -->|"opens instrument"| node_instrument
node_trader -->|"runs analysis"| node_backtestui
node_backtestapi -->|"ensures candles"| node_history
node_backtestapi -->|"forwards backtest"| node_analyticsservice
node_predictionapi -->|"builds scorecard"| node_scorecard
node_predictionapi -->|"requests OHLC"| node_observer
node_auth -->|"authenticates"| node_observer
node_bootstrap -->|"loads bootstrap"| node_bootstrapapi
node_onboarding -.->|"updates setup"| node_bootstrapapi

click node_dashboard "https://github.com/1-ken/fx-alert/blob/main/components/dashboard/dashboard-page.tsx"
click node_instrument "https://github.com/1-ken/fx-alert/blob/main/components/instruments/pair-detail-page.tsx"
click node_tradingchart "https://github.com/1-ken/fx-alert/blob/main/components/charts/interactive-trading-chart.tsx"
click node_alertsform "https://github.com/1-ken/fx-alert/blob/main/components/alerts/create-alert-form.tsx"
click node_alertstate "https://github.com/1-ken/fx-alert/blob/main/hooks/alerts/use-alerts.ts"
click node_snapshot "https://github.com/1-ken/fx-alert/blob/main/hooks/snapshot/use-snapshot.ts"
click node_alertapi "https://github.com/1-ken/fx-alert/blob/main/app/api/observer/alerts/route.ts"
click node_notifications "https://github.com/1-ken/fx-alert/blob/main/components/triggered-notification-listener.tsx"
click node_backtestui "https://github.com/1-ken/fx-alert/blob/main/components/analytics/backtest-page.tsx"
click node_backtesthook "https://github.com/1-ken/fx-alert/blob/main/hooks/analytics/use-backtest.ts"
click node_backtestapi "https://github.com/1-ken/fx-alert/blob/main/app/api/analytics/backtest/route.ts"
click node_history "https://github.com/1-ken/fx-alert/blob/main/lib/history-ensure.ts"
click node_predictionui "https://github.com/1-ken/fx-alert/blob/main/components/analytics/prediction-scorecard-page.tsx"
click node_predictionhook "https://github.com/1-ken/fx-alert/blob/main/hooks/analytics/use-prediction-scorecard.ts"
click node_predictionapi "https://github.com/1-ken/fx-alert/blob/main/app/api/analytics/predictions/route.ts"
click node_scorecard "https://github.com/1-ken/fx-alert/blob/main/lib/prediction-scorecard.ts"
click node_auth "https://github.com/1-ken/fx-alert/blob/main/lib/auth.ts"
click node_bootstrap "https://github.com/1-ken/fx-alert/blob/main/components/bootstrap-provider.tsx"
click node_bootstrapapi "https://github.com/1-ken/fx-alert/blob/main/lib/api/bootstrap.ts"
click node_onboarding "https://github.com/1-ken/fx-alert/blob/main/components/onboarding/onboarding-page.tsx"
click node_subscriptions "https://github.com/1-ken/fx-alert/blob/main/components/subscription/paywall-modal.tsx"
click node_admin "https://github.com/1-ken/fx-alert/blob/main/components/admin/admin-panel.tsx"

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_dashboard,node_instrument,node_tradingchart toneBlue
class node_alertsform,node_alertstate,node_snapshot,node_alertapi,node_notifications toneAmber
class node_backtestui,node_backtesthook,node_backtestapi,node_history,node_predictionui,node_predictionhook,node_predictionapi,node_scorecard,node_observer toneMint
class node_auth,node_bootstrap,node_bootstrapapi,node_onboarding,node_subscriptions,node_admin toneRose
class node_trader,node_analyticsservice toneIndigo
```

## Components

### Market experience

- [Dashboard](https://github.com/1-ken/fx-alert/blob/main/components/dashboard/dashboard-page.tsx): `components/dashboard/dashboard-page.tsx`
- [Instrument detail](https://github.com/1-ken/fx-alert/blob/main/components/instruments/pair-detail-page.tsx): `components/instruments/pair-detail-page.tsx`
- [Trading chart](https://github.com/1-ken/fx-alert/blob/main/components/charts/interactive-trading-chart.tsx): `components/charts/interactive-trading-chart.tsx`

### Alerting

- [Alert form](https://github.com/1-ken/fx-alert/blob/main/components/alerts/create-alert-form.tsx): `components/alerts/create-alert-form.tsx`
- [Alert state](https://github.com/1-ken/fx-alert/blob/main/hooks/alerts/use-alerts.ts): `hooks/alerts/use-alerts.ts`
- [Market snapshot](https://github.com/1-ken/fx-alert/blob/main/hooks/snapshot/use-snapshot.ts): `hooks/snapshot/use-snapshot.ts`
- [Alert endpoints](https://github.com/1-ken/fx-alert/blob/main/app/api/observer/alerts/route.ts): `app/api/observer/alerts/route.ts`
- [Triggered notifications](https://github.com/1-ken/fx-alert/blob/main/components/triggered-notification-listener.tsx): `components/triggered-notification-listener.tsx`

### Analytics

- [Backtest experience](https://github.com/1-ken/fx-alert/blob/main/components/analytics/backtest-page.tsx): `components/analytics/backtest-page.tsx`
- [Backtest data hook](https://github.com/1-ken/fx-alert/blob/main/hooks/analytics/use-backtest.ts): `hooks/analytics/use-backtest.ts`
- [Backtest endpoint](https://github.com/1-ken/fx-alert/blob/main/app/api/analytics/backtest/route.ts): `app/api/analytics/backtest/route.ts`
- [Historical data retrieval](https://github.com/1-ken/fx-alert/blob/main/lib/history-ensure.ts): `lib/history-ensure.ts`
- [Prediction scorecard](https://github.com/1-ken/fx-alert/blob/main/components/analytics/prediction-scorecard-page.tsx): `components/analytics/prediction-scorecard-page.tsx`
- [Prediction data hook](https://github.com/1-ken/fx-alert/blob/main/hooks/analytics/use-prediction-scorecard.ts): `hooks/analytics/use-prediction-scorecard.ts`
- [Prediction endpoint](https://github.com/1-ken/fx-alert/blob/main/app/api/analytics/predictions/route.ts): `app/api/analytics/predictions/route.ts`
- [Scorecard logic](https://github.com/1-ken/fx-alert/blob/main/lib/prediction-scorecard.ts): `lib/prediction-scorecard.ts`

### Account platform

- [Authentication](https://github.com/1-ken/fx-alert/blob/main/lib/auth.ts): `lib/auth.ts`
- [Bootstrap provider](https://github.com/1-ken/fx-alert/blob/main/components/bootstrap-provider.tsx): `components/bootstrap-provider.tsx`
- [Bootstrap API client](https://github.com/1-ken/fx-alert/blob/main/lib/api/bootstrap.ts): `lib/api/bootstrap.ts`
- [Onboarding](https://github.com/1-ken/fx-alert/blob/main/components/onboarding/onboarding-page.tsx): `components/onboarding/onboarding-page.tsx`
- [Subscription controls](https://github.com/1-ken/fx-alert/blob/main/components/subscription/paywall-modal.tsx): `components/subscription/paywall-modal.tsx`
- [Admin panel](https://github.com/1-ken/fx-alert/blob/main/components/admin/admin-panel.tsx): `components/admin/admin-panel.tsx`

### Other components

- **Trader**
- **Analytics service**
- **Observer API**

## Connections

- Trader → Alert form: configures
- Alert form → Alert state: creates alerts (evidence: `components/alerts/create-alert-form.tsx`)
- Alert form → Market snapshot: reads snapshot (evidence: `components/alerts/create-alert-form.tsx`)
- Alert form → Bootstrap provider: reads account setup (evidence: `components/alerts/create-alert-form.tsx`)
- Trader → Dashboard: views markets
- Trader → Instrument detail: opens instrument
- Trader → Backtest experience: runs analysis
- Backtest endpoint → Historical data retrieval: ensures candles (evidence: `app/api/analytics/backtest/route.ts`)
- Backtest endpoint → Analytics service: forwards backtest (evidence: `app/api/analytics/backtest/route.ts`)
- Prediction endpoint → Scorecard logic: builds scorecard (evidence: `app/api/analytics/predictions/route.ts`)
- Prediction endpoint → Observer API: requests OHLC (evidence: `app/api/analytics/predictions/route.ts`)
- Authentication → Observer API: authenticates (evidence: `lib/auth.ts`)
- Bootstrap provider → Bootstrap API client: loads bootstrap (evidence: `components/bootstrap-provider.tsx`)
- Onboarding → Bootstrap API client: updates setup
