Files
flowsight/docs/DATA-MODEL.md
T
asepharyana 3882c5aef0 Add comprehensive documentation for FlowSight project
- Introduced AGENT-SPECS.md detailing the specifications for seven agents including their inputs, processing steps, and outputs.
- Created API-REFERENCE.md outlining the Sectors API v2 endpoints, parameters, costs, and usage.
- Developed API.md to specify backend routes, request/response structures, and error handling.
- Established ARCHITECTURE.md to describe the project layout, conventions, scheduler, and citation pipeline.
- Added DATA-MODEL.md to define the database schema, tables, and seed strategy.
- Compiled PLAN.md to outline the project concept, problem statement, unique features, and implementation timeline.
- Created README.md as an index for documentation with links to all relevant files.
- Documented ROUTINES.md detailing the seven automated routines, their schedules, inputs, detection logic, and delivery formats.
- Introduced TECH-STACK.md to specify the technology choices and rationale for both backend and frontend components.
2026-09-14 20:35:02 +07:00

1.9 KiB
Raw Blame History

Data model

SQLite for the hackathon; schema kept Postgres-compatible (serial → integer PK, JSON → TEXT with JSON1, no SQLite-only DDL). Migrations numbered in backend/app/store/migrations/.

Tables

  • snapshots(id, ticker, date, source, payload_json, fetched_at) — raw API rows. Index (ticker, date, source). Retention: 180d, then compact to weekly.
  • broker_activity(broker_code, ticker, date, buy, sell, net, lots, freq, avg_price) Index (ticker, date), (broker_code, date).
  • foreign_flow(ticker, date, net_inflow) — PK (ticker, date).
  • news_items(id, ticker, date, source, sentiment, confidence, url, title) — Index (ticker, date).
  • filings(id, ticker, date, holder_type, txn_type, volume, price) — Index (ticker, date).
  • routines(id, user_key, type, schedule_cron, channels_json, enabled) — 7 types (R1–R7).
  • routine_runs(id, routine_id, started_at, status, payload_json, credits_used).
  • alerts(id, user_key, name, rule_json, channels_json, last_fired).
  • alert_events(id, alert_id, ticker, date, message, context_json, citations_json).
  • watchlists(user_key, ticker, added_at) — PK (user_key, ticker).
  • reports(id, ticker, generated_at, payload_json, citations_json).
  • agent_accuracy(id, agent, ticker, prediction, predict_date, resolved, hit, actual_return).
  • briefings(date, payload_json, citations_json) — PK date.
  • credit_ledger(date, endpoint, calls, credits) — daily spend audit.

Seed strategy

seed.py loads one historical trading week into snapshots + derived tables so the full demo (briefing → radar → report → interrogation) runs offline. Fixtures live in tests/fixtures/ as JSON exports of real API shapes (field names match schema.json).

Cursors

  • meta(key, value): quarterly_since (universe poll cursor), news_since, filings_since — persisted so restarts resume incrementally.