# sentfromthefuture/cf-test architecture

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

- Interactive diagram: https://gitdiagram.com/sentfromthefuture/cf-test
- Repository: https://github.com/sentfromthefuture/cf-test

## Overview

DemandRadar is a market-intelligence product: users explore collected problem signals and opportunity analyses, then develop them into business concepts and briefs. Its research engine gathers public discussions, analyzes and clusters signals, and supports demand scoring and trend views; the app also includes accounts and paid tiers. The graph includes documented product areas even where their implementation was not sampled. Evidence for some subsystem boundaries comes from the source index or README, so uncertain internal connections are omitted.

Main entry points: [`src/App.tsx`](https://github.com/sentfromthefuture/cf-test/blob/main/src/App.tsx) (App shell), [`src/lib/liveData.ts`](https://github.com/sentfromthefuture/cf-test/blob/main/src/lib/liveData.ts) (Live data client), [`functions/api/generate-brief.ts`](https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/generate-brief.ts) (Brief API), [`supabase/functions/_shared/collector/ai.ts`](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/ai.ts) (Signal analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product_ui["Product experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardView.tsx]"]
  node_problems["Problem explorer"]
  node_opportunities["Opportunity intelligence"]
  node_trends["Trend analytics"]
  node_generator["Brief generator"]
  node_data_sources["Data sources"]
  node_research_activity["Research activity"]
  node_scoring["Scoring controls"]
  node_seed_data["Demo opportunities<br/>[mockData.ts]"]
  node_brief_api["Brief API<br/>[generate-brief.ts]"]
end

subgraph group_research_engine["Research engine"]
  node_collector_api["Collection function<br/>[index.ts]"]
  node_connectors["Source connectors"]
  node_analysis["Signal analysis<br/>[ai.ts]"]
  node_heuristics["Analysis heuristics<br/>[heuristics.ts]"]
  node_decisions["Decisions engine<br/>[decisions.ts]"]
  node_ai_common["AI cache plumbing<br/>[ai-common.ts]"]
  node_store[("Research store<br/>[store.ts]")]
end

subgraph group_data_access["Data access"]
  node_live_data["Live data client<br/>[liveData.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
end

subgraph group_accounts_billing["Accounts and billing"]
  node_account_api["Account API<br/>[account.ts]"]
  node_checkout_api["Checkout API<br/>[checkout.ts]"]
  node_portal_api["Customer portal API<br/>[customer-portal.ts]"]
  node_webhook_api["Payment webhook<br/>[webhook.ts]"]
end

node_user(("User"))
node_gemini{{"Gemini AI"}}
node_public_sources(("Public discussions"))
node_payment_provider{{"Payment provider"}}

node_user -->|"uses"| node_app
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_problems
node_app -->|"renders"| node_opportunities
node_app -->|"renders"| node_trends
node_app -->|"renders"| node_generator
node_app -->|"renders"| node_data_sources
node_app -->|"renders"| node_research_activity
node_app -->|"renders"| node_scoring
node_app -->|"fetches live data"| node_live_data
node_app -->|"loads fallback data"| node_seed_data
node_live_data -->|"queries"| node_supabase
node_live_data -->|"invokes sync"| node_collector_api
node_user -.->|"public posts originate"| node_connectors
node_connectors -.->|"fetches discussions"| node_public_sources
node_analysis -->|"uses rules"| node_heuristics
node_decisions -->|"uses rules"| node_heuristics
node_analysis -.->|"requests analysis"| node_gemini
node_ai_common -.->|"caches results"| node_store
node_user -.->|"manages account"| node_account_api
node_user -.->|"starts checkout"| node_checkout_api
node_user -.->|"opens portal"| node_portal_api
node_checkout_api -.->|"initiates payment"| node_payment_provider
node_payment_provider -.->|"notifies payment"| node_webhook_api
node_user -.->|"requests brief"| node_brief_api
node_generator -.->|"requests generation"| node_brief_api
node_brief_api -.->|"generates brief"| node_gemini

click node_app "https://github.com/sentfromthefuture/cf-test/blob/main/src/App.tsx"
click node_dashboard "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/DashboardView.tsx"
click node_problems "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/ProblemExplorerView.tsx"
click node_opportunities "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/OpportunityIntelligenceView.tsx"
click node_trends "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/TrendAnalyticsView.tsx"
click node_generator "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/AiGeneratorView.tsx"
click node_data_sources "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/DataSourcesView.tsx"
click node_research_activity "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/ResearchActivityView.tsx"
click node_scoring "https://github.com/sentfromthefuture/cf-test/blob/main/src/components/ScoringCalculatorModal.tsx"
click node_seed_data "https://github.com/sentfromthefuture/cf-test/blob/main/src/data/mockData.ts"
click node_live_data "https://github.com/sentfromthefuture/cf-test/blob/main/src/lib/liveData.ts"
click node_supabase "https://github.com/sentfromthefuture/cf-test/blob/main/src/lib/supabase.ts"
click node_collector_api "https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/collect/index.ts"
click node_connectors "https://github.com/sentfromthefuture/cf-test/tree/main/supabase/functions/_shared/collector/connectors"
click node_analysis "https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/ai.ts"
click node_heuristics "https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/heuristics.ts"
click node_decisions "https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/decisions.ts"
click node_ai_common "https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/ai-common.ts"
click node_store "https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/store.ts"
click node_account_api "https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/account.ts"
click node_checkout_api "https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/checkout.ts"
click node_portal_api "https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/customer-portal.ts"
click node_webhook_api "https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/webhook.ts"
click node_brief_api "https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/generate-brief.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_app,node_dashboard,node_problems,node_opportunities,node_trends,node_generator,node_data_sources,node_research_activity,node_scoring,node_seed_data,node_brief_api,node_user toneBlue
class node_collector_api,node_connectors,node_analysis,node_heuristics,node_decisions,node_ai_common,node_store toneAmber
class node_live_data,node_supabase toneMint
class node_account_api,node_checkout_api,node_portal_api,node_webhook_api toneRose
class node_gemini,node_public_sources,node_payment_provider toneIndigo
```

## Components

### Product experience

- [App shell](https://github.com/sentfromthefuture/cf-test/blob/main/src/App.tsx): `src/App.tsx`
- [Dashboard](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`
- [Problem explorer](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/ProblemExplorerView.tsx): `src/components/ProblemExplorerView.tsx`
- [Opportunity intelligence](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/OpportunityIntelligenceView.tsx): `src/components/OpportunityIntelligenceView.tsx`
- [Trend analytics](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/TrendAnalyticsView.tsx): `src/components/TrendAnalyticsView.tsx`
- [Brief generator](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/AiGeneratorView.tsx): `src/components/AiGeneratorView.tsx`
- [Data sources](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/DataSourcesView.tsx): `src/components/DataSourcesView.tsx`
- [Research activity](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/ResearchActivityView.tsx): `src/components/ResearchActivityView.tsx`
- [Scoring controls](https://github.com/sentfromthefuture/cf-test/blob/main/src/components/ScoringCalculatorModal.tsx): `src/components/ScoringCalculatorModal.tsx`
- [Demo opportunities](https://github.com/sentfromthefuture/cf-test/blob/main/src/data/mockData.ts): `src/data/mockData.ts`
- [Brief API](https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/generate-brief.ts): `functions/api/generate-brief.ts`

### Research engine

- [Collection function](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/collect/index.ts): `supabase/functions/collect/index.ts`
- [Source connectors](https://github.com/sentfromthefuture/cf-test/tree/main/supabase/functions/_shared/collector/connectors): `supabase/functions/_shared/collector/connectors`
- [Signal analysis](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/ai.ts): `supabase/functions/_shared/collector/ai.ts`
- [Analysis heuristics](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/heuristics.ts): `supabase/functions/_shared/collector/heuristics.ts`
- [Decisions engine](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/decisions.ts): `supabase/functions/_shared/collector/decisions.ts`
- [AI cache plumbing](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/ai-common.ts): `supabase/functions/_shared/collector/ai-common.ts`
- [Research store](https://github.com/sentfromthefuture/cf-test/blob/main/supabase/functions/_shared/collector/store.ts): `supabase/functions/_shared/collector/store.ts`

### Data access

- [Live data client](https://github.com/sentfromthefuture/cf-test/blob/main/src/lib/liveData.ts): `src/lib/liveData.ts`
- [Supabase client](https://github.com/sentfromthefuture/cf-test/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Accounts and billing

- [Account API](https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/account.ts): `functions/api/account.ts`
- [Checkout API](https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/checkout.ts): `functions/api/checkout.ts`
- [Customer portal API](https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/customer-portal.ts): `functions/api/customer-portal.ts`
- [Payment webhook](https://github.com/sentfromthefuture/cf-test/blob/main/functions/api/webhook.ts): `functions/api/webhook.ts`

### Other components

- **User**
- **Gemini AI**
- **Public discussions**
- **Payment provider**

## Connections

- User → App shell: uses (evidence: `README.md`)
- App shell → Dashboard: renders (evidence: `src/App.tsx`)
- App shell → Problem explorer: renders (evidence: `src/App.tsx`)
- App shell → Opportunity intelligence: renders (evidence: `src/App.tsx`)
- App shell → Trend analytics: renders (evidence: `src/App.tsx`)
- App shell → Brief generator: renders (evidence: `src/App.tsx`)
- App shell → Data sources: renders (evidence: `src/App.tsx`)
- App shell → Research activity: renders (evidence: `src/App.tsx`)
- App shell → Scoring controls: renders (evidence: `src/App.tsx`)
- App shell → Live data client: fetches live data (evidence: `src/App.tsx`)
- App shell → Demo opportunities: loads fallback data (evidence: `src/App.tsx`)
- Live data client → Supabase client: queries (evidence: `src/lib/liveData.ts`)
- Live data client → Collection function: invokes sync (evidence: `src/lib/liveData.ts`)
- User → Source connectors: public posts originate (evidence: `README.md`)
- Source connectors → Public discussions: fetches discussions (evidence: `README.md`)
- Signal analysis → Analysis heuristics: uses rules (evidence: `supabase/functions/_shared/collector/ai.ts`)
- Decisions engine → Analysis heuristics: uses rules (evidence: `supabase/functions/_shared/collector/decisions.ts`)
- Signal analysis → Gemini AI: requests analysis
- AI cache plumbing → Research store: caches results (evidence: `supabase/functions/_shared/collector/store.ts`)
- User → Account API: manages account
- User → Checkout API: starts checkout
- User → Customer portal API: opens portal
- Checkout API → Payment provider: initiates payment
- Payment provider → Payment webhook: notifies payment
- User → Brief API: requests brief
- Brief generator → Brief API: requests generation
- Brief API → Gemini AI: generates brief
