# ikaikahussey/hoku-constellation architecture

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

- Interactive diagram: https://gitdiagram.com/ikaikahussey/hoku-constellation
- Repository: https://github.com/ikaikahussey/hoku-constellation

## Overview

HOKU Insider maps Hawaiʻi’s political and economic power structure from public records: ingest source data, resolve entities and document-backed relationships, then expose search, profiles, network analytics, alerts, briefings, and team research tools. The graph includes major documented product branches, including reports and billing. Several route and analytics implementations are not sampled, so their internal call paths are omitted rather than inferred; documented capabilities remain represented.

Main entry points: [`lib/reports/index.ts`](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/reports/index.ts) (Client reports), [`app/api/import/route.ts`](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/import/route.ts) (Manual import), [`lib/import/pipeline.ts`](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/pipeline.ts) (Record pipeline), [`lib/ai/claude.ts`](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/ai/claude.ts) (Cited generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data ingestion"]
  node_import_api["Manual import<br/>[route.ts]"]
  node_import_run["Importer runner<br/>[run.ts]"]
  node_import_pipeline["Record pipeline<br/>[pipeline.ts]"]
  node_source_registry["Source registry<br/>[source-registry.ts]"]
  node_entity_match["Entity matching<br/>[entity-match.ts]"]
  node_attribute_schema["Record validation<br/>[attributes.ts]"]
end

subgraph group_discovery["Public research"]
  node_search_api["Search API<br/>[route.ts]"]
  node_search_page["Search experience<br/>[page.tsx]"]
  node_entity_profiles["Entity profiles<br/>[page.tsx]"]
  node_document_pages["Public documents<br/>[page.tsx]"]
end

subgraph group_analytics["Network intelligence"]
  node_analytics["Network analytics<br/>[index.ts]"]
  node_alert_pipeline["Alert pipeline<br/>[index.ts]"]
  node_alert_events["Alert events<br/>[events.ts]"]
  node_briefings["Cited briefings<br/>[index.ts]"]
end

subgraph group_workspace["Research workspace"]
  node_workspace["Team workspace<br/>[page.tsx]"]
  node_ask_api["Ask endpoint<br/>[route.ts]"]
  node_ask["Corpus Q&amp;A<br/>[index.ts]"]
  node_reports["Client reports<br/>[index.ts]"]
end

subgraph group_platform["Shared platform"]
  node_ai_narrative["Cited generation<br/>[claude.ts]"]
  node_service_db["Database service<br/>[service.ts]"]
  node_db_adapter["Postgres adapter<br/>[pg-adapter.ts]"]
  node_db_types["Data interfaces<br/>[types.ts]"]
  node_billing_webhook["Stripe webhook<br/>[route.ts]"]
  node_billing["Team billing<br/>[index.ts]"]
  node_teams["Team membership<br/>[teams.ts]"]
  node_header["Site navigation<br/>[Header.tsx]"]
  node_footer["Site footer<br/>[Footer.tsx]"]
  node_button["Button component<br/>[Button.tsx]"]
  node_email["Email delivery<br/>[resend.ts]"]
  node_pdf["PDF rendering<br/>[pdf.ts]"]
end

node_staff(("Staff"))
node_researchers(("Researchers"))
node_public(("Public visitors"))

node_staff -->|"uploads records"| node_import_api
node_import_api -->|"runs importer"| node_import_run
node_import_api -->|"reads cursor"| node_import_pipeline
node_import_pipeline -->|"resolves entities"| node_entity_match
node_import_pipeline -->|"validates edges"| node_attribute_schema
node_public -.->|"searches records"| node_search_page
node_researchers -.->|"uses workspace"| node_workspace
node_researchers -->|"asks questions"| node_ask_api
node_ask_api -->|"calls"| node_ask
node_ask -->|"generates answers"| node_ai_narrative
node_briefings -->|"generates summaries"| node_ai_narrative
node_reports -->|"generates narrative"| node_ai_narrative
node_reports -->|"sends reports"| node_email
node_reports -->|"renders files"| node_pdf
node_alert_pipeline -->|"matches events"| node_alert_events
node_alert_pipeline -->|"marks stale"| node_briefings
node_billing_webhook -->|"opens database"| node_service_db
node_billing_webhook -->|"handles team billing"| node_billing
node_billing -->|"checks membership"| node_teams
node_service_db -->|"wraps pool"| node_db_adapter
node_header -->|"uses"| node_button

click node_import_api "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/import/route.ts"
click node_import_run "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/run.ts"
click node_import_pipeline "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/pipeline.ts"
click node_source_registry "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/source-registry.ts"
click node_entity_match "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/entity-match.ts"
click node_attribute_schema "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/schema/attributes.ts"
click node_search_api "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/search/route.ts"
click node_search_page "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/search/page.tsx"
click node_entity_profiles "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/person/%5Bslug%5D/page.tsx"
click node_document_pages "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/documents/page.tsx"
click node_analytics "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/analytics/index.ts"
click node_alert_pipeline "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/alerts/index.ts"
click node_alert_events "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/alerts/events.ts"
click node_briefings "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/briefings/index.ts"
click node_workspace "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/workspace/page.tsx"
click node_ask_api "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/ask/route.ts"
click node_ask "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/ask/index.ts"
click node_reports "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/reports/index.ts"
click node_ai_narrative "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/ai/claude.ts"
click node_service_db "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/db/service.ts"
click node_db_adapter "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/db/pg-adapter.ts"
click node_db_types "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/db/types.ts"
click node_billing_webhook "https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/webhook/stripe/route.ts"
click node_billing "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/billing/index.ts"
click node_teams "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/teams.ts"
click node_header "https://github.com/ikaikahussey/hoku-constellation/blob/main/components/layout/Header.tsx"
click node_footer "https://github.com/ikaikahussey/hoku-constellation/blob/main/components/layout/Footer.tsx"
click node_button "https://github.com/ikaikahussey/hoku-constellation/blob/main/components/ui/Button.tsx"
click node_email "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/email/resend.ts"
click node_pdf "https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/render/pdf.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_import_api,node_import_run,node_import_pipeline,node_source_registry,node_entity_match,node_attribute_schema toneBlue
class node_search_api,node_search_page,node_entity_profiles,node_document_pages toneAmber
class node_analytics,node_alert_pipeline,node_alert_events,node_briefings toneMint
class node_workspace,node_ask_api,node_ask,node_reports toneRose
class node_ai_narrative,node_service_db,node_db_adapter,node_db_types,node_billing_webhook,node_billing,node_teams,node_header,node_footer,node_button,node_email,node_pdf,node_staff,node_researchers,node_public toneIndigo
```

## Components

### Data ingestion

- [Manual import](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/import/route.ts): `app/api/import/route.ts`
- [Importer runner](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/run.ts): `lib/import/run.ts`
- [Record pipeline](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/pipeline.ts): `lib/import/pipeline.ts`
- [Source registry](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/import/source-registry.ts): `lib/import/source-registry.ts`
- [Entity matching](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/entity-match.ts): `lib/entity-match.ts`
- [Record validation](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/schema/attributes.ts): `lib/schema/attributes.ts`

### Public research

- [Search API](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/search/route.ts): `app/api/search/route.ts`
- [Search experience](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/search/page.tsx): `app/search/page.tsx`
- [Entity profiles](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/person/%5Bslug%5D/page.tsx): `app/person/[slug]/page.tsx`
- [Public documents](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/documents/page.tsx): `app/documents/page.tsx`

### Network intelligence

- [Network analytics](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/analytics/index.ts): `lib/analytics/index.ts`
- [Alert pipeline](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/alerts/index.ts): `lib/alerts/index.ts`
- [Alert events](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/alerts/events.ts): `lib/alerts/events.ts`
- [Cited briefings](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/briefings/index.ts): `lib/briefings/index.ts`

### Research workspace

- [Team workspace](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/workspace/page.tsx): `app/workspace/page.tsx`
- [Ask endpoint](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/ask/route.ts): `app/api/ask/route.ts`
- [Corpus Q&A](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/ask/index.ts): `lib/ask/index.ts`
- [Client reports](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/reports/index.ts): `lib/reports/index.ts`

### Shared platform

- [Cited generation](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/ai/claude.ts): `lib/ai/claude.ts`
- [Database service](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/db/service.ts): `lib/db/service.ts`
- [Postgres adapter](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/db/pg-adapter.ts): `lib/db/pg-adapter.ts`
- [Data interfaces](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/db/types.ts): `lib/db/types.ts`
- [Stripe webhook](https://github.com/ikaikahussey/hoku-constellation/blob/main/app/api/webhook/stripe/route.ts): `app/api/webhook/stripe/route.ts`
- [Team billing](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/billing/index.ts): `lib/billing/index.ts`
- [Team membership](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/teams.ts): `lib/teams.ts`
- [Site navigation](https://github.com/ikaikahussey/hoku-constellation/blob/main/components/layout/Header.tsx): `components/layout/Header.tsx`
- [Site footer](https://github.com/ikaikahussey/hoku-constellation/blob/main/components/layout/Footer.tsx): `components/layout/Footer.tsx`
- [Button component](https://github.com/ikaikahussey/hoku-constellation/blob/main/components/ui/Button.tsx): `components/ui/Button.tsx`
- [Email delivery](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/email/resend.ts): `lib/email/resend.ts`
- [PDF rendering](https://github.com/ikaikahussey/hoku-constellation/blob/main/lib/render/pdf.ts): `lib/render/pdf.ts`

### Other components

- **Staff**
- **Researchers**
- **Public visitors**

## Connections

- Staff → Manual import: uploads records (evidence: `app/api/import/route.ts`)
- Manual import → Importer runner: runs importer (evidence: `app/api/import/route.ts`)
- Manual import → Record pipeline: reads cursor (evidence: `app/api/import/route.ts`)
- Record pipeline → Entity matching: resolves entities (evidence: `lib/import/pipeline.ts`)
- Record pipeline → Record validation: validates edges (evidence: `lib/import/pipeline.ts`)
- Public visitors → Search experience: searches records
- Researchers → Team workspace: uses workspace
- Researchers → Ask endpoint: asks questions (evidence: `app/api/ask/route.ts`)
- Ask endpoint → Corpus Q&A: calls (evidence: `app/api/ask/route.ts`)
- Corpus Q&A → Cited generation: generates answers (evidence: `lib/ask/index.ts`)
- Cited briefings → Cited generation: generates summaries (evidence: `lib/briefings/index.ts`)
- Client reports → Cited generation: generates narrative (evidence: `lib/reports/index.ts`)
- Client reports → Email delivery: sends reports (evidence: `lib/reports/index.ts`)
- Client reports → PDF rendering: renders files (evidence: `lib/reports/index.ts`)
- Alert pipeline → Alert events: matches events (evidence: `lib/alerts/index.ts`)
- Alert pipeline → Cited briefings: marks stale (evidence: `lib/alerts/index.ts`)
- Stripe webhook → Database service: opens database (evidence: `app/api/webhook/stripe/route.ts`)
- Stripe webhook → Team billing: handles team billing (evidence: `app/api/webhook/stripe/route.ts`)
- Team billing → Team membership: checks membership (evidence: `lib/billing/index.ts`)
- Database service → Postgres adapter: wraps pool (evidence: `lib/db/service.ts`)
- Site navigation → Button component: uses (evidence: `components/layout/Header.tsx`)
