Skip to content

feat(alerts): price alerts system (API, evaluator worker, notifications, UI) (M2-EPIC4)#48

Merged
dazw00110 merged 4 commits intomainfrom
feature/alerts-system
Jan 5, 2026
Merged

feat(alerts): price alerts system (API, evaluator worker, notifications, UI) (M2-EPIC4)#48
dazw00110 merged 4 commits intomainfrom
feature/alerts-system

Conversation

@Shakalito
Copy link
Copy Markdown
Owner

@Shakalito Shakalito commented Jan 4, 2026

Summary

Implements a complete price alerts system covering backend, evaluation logic, notifications, and frontend UI.

Users can create price threshold alerts (ABOVE / BELOW), monitor them via UI, and have them automatically evaluated against live market quotes.

Backend (Alerts API)

  • Added price_alerts DB model with full CRUD.
  • Endpoints:
    • POST /alerts
    • GET /alerts/me?active=true|false
    • PATCH /alerts/{id} (enable / disable)
    • DELETE /alerts/{id}
  • Validates listing existence.
  • Uses enum-based alert condition (ABOVE, BELOW).
  • Currency is derived server-side from listing metadata (frontend does not provide it).
  • Proper ownership checks and timestamp updates.

Alert Evaluator Worker

  • Added alert evaluator that:
  • polls active alerts,
  • fetches batch quotes from Finnhub,
  • evaluates alert conditions,
  • deactivates triggered alerts and sets last_triggered_at.
  • Idempotent on reruns (already-triggered alerts are skipped).
  • Currently executed manually via script.

Notifications

  • Added minimal notification service:
    • console notifier (active),
    • SMTP notifier scaffold (draft).
  • Notification is sent on alert trigger using user’s email.

Frontend (Alerts UI)

  • Added alerts pages:
    • /alerts – list, filter (active / inactive / all), enable/disable, delete.
    • /alerts/new – create alert with listing search dropdown.
  • Integrated with backend alerts API.
  • Currency is display-only and derived from listing.
  • Routes integrated into app navigation.

Testing

  • Manual verification performed:
  • Create / list / toggle / delete alerts via UI and Swagger.
  • Alert evaluator correctly triggers and deactivates alerts.
  • Invalid listing IDs return 404.
  • Invalid currency values rejected by validation.

Notes / Future Improvements (non-blocking)

  • Consistency: unify quote batch result keys (UUID vs string) across services.
  • Metrics: extend evaluator stats (separate counters for skipped-by-error vs skipped-by-missing-price).
  • Execution model:
    • current: manual one-off execution from terminal,
    • future: loop-based worker or dedicated alert-worker service (Docker).
      These are cosmetic / architectural improvements and do not block MVP functionality.

Closes #14 Ref #30, #31, #32, #33

- Added alerts.price_alerts model + CRUD endpoints (/alerts, /alerts/me, patch/delete).
- Validates listing existence; supports enable/disable + active filter; updates updated_at on change.
- Uses enum condition (ABOVE/BELOW).
Manual Swagger tests: create/list/update/delete + invalid listing 404.
- Added evaluator script that polls active alerts and checks Finnhub batch quotes.
- On trigger: sets last_triggered_at, deactivates alert (idempotent on rerun).
- Removes unused ticker lookup from evaluator.
- Added notify_service with console notifier and SMTP(draft) implementation
- Send notification on alert trigger from evaluator (uses user's email)
- Add /alerts and /alerts/new pages with listing lookup.
- Implement alerts CRUD UI against /alerts endpoints.
- backend derives currency from listing.
@Shakalito Shakalito self-assigned this Jan 4, 2026
@Shakalito Shakalito added enhancement New feature or request frontend User interface, dashboards, charts, and client-side state management. labels Jan 4, 2026
@Shakalito Shakalito linked an issue Jan 4, 2026 that may be closed by this pull request
1 task
@Shakalito Shakalito added the backend Server-side logic, API endpoints, database models, and financial calculations. label Jan 4, 2026
@Shakalito Shakalito linked an issue Jan 4, 2026 that may be closed by this pull request
1 task
@Shakalito Shakalito marked this pull request as ready for review January 4, 2026 23:22
Copy link
Copy Markdown
Collaborator

@dazw00110 dazw00110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All functionalities described in the PR have been manually verified and are working correctly:

  • Backend & DB: The price_alerts model stores data correctly, and CRUD operations (create, read, update, delete) work flawlessly via the API.
  • Alert Evaluator: The run_alert_evaluator.py script correctly fetches prices from Finnhub and reacts to ABOVE/BELOW conditions. A test on AAPL (target 10 USD) confirmed that alerts are properly triggered and deactivated.
  • UI (Frontend): The /alerts page and /alerts/new form are fully integrated with the backend. Filtering and Enable/Disable/Delete buttons work as described.
  • Notifications: The system correctly records the alert trigger by saving the last_triggered_at date in the database.

I have noticed that a new Issue has already been created regarding the "Future Improvements" note.

@dazw00110 dazw00110 merged commit f8eee4e into main Jan 5, 2026
1 check passed
@Shakalito Shakalito linked an issue Jan 5, 2026 that may be closed by this pull request
1 task
@Shakalito Shakalito deleted the feature/alerts-system branch January 9, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server-side logic, API endpoints, database models, and financial calculations. enhancement New feature or request frontend User interface, dashboards, charts, and client-side state management.

Projects

None yet

2 participants