When Observation Becomes a Rule

OpenStock changes character when a reader stops merely looking at a symbol and saves it for continued attention. A watchlist item preserves that interest; a price alert adds a condition that the system should evaluate later. This chapter follows both lifecycles to show what becomes durable, what triggers a transition, and why a detected threshold is not automatically a real-time notification or a trade.

A watchlist turns a search result into personal state

A search result is temporary. It answers a question asked now and can disappear when the query changes or the page closes. A watchlist item has a different purpose: it records that a particular user wants a symbol to remain in their monitoring context. OpenStock stores a user ID, an uppercase and trimmed symbol, a company label, and an added timestamp. That small record is the bridge between public market information and personal continuity.

The lifecycle begins when an item is added. The server action uses an upsert keyed by user ID and normalized symbol. If the same user tries to add the symbol again, the operation updates or returns the existing record instead of creating a second personal copy. Removal uses the same user-and-symbol relationship, and retrieval sorts the stored items by most recently added. The visible result is a list, but the underlying behavior is a controlled transition from “not in this user’s context” to “persisted in this user’s context.”

Normalization is part of the lifecycle. Symbols are uppercased and trimmed before storage, so different presentations of the same ticker do not automatically become different records for one user. The compound unique index on (userId, symbol) turns that expectation into a database invariant. It is not only a performance detail. It protects a user-facing promise: adding the same symbol twice should not make the watchlist appear to contain two distinct interests.

The invariant is scoped to a user. Two different users may save the same company, because the point is not to make symbols globally unique. The same public security can be relevant to many people while remaining a separate relationship for each account. This is why the user ID is part of the key rather than an incidental field.

Once retrieved, the list becomes an input to more than one surface. The client manager can sort the symbols in default, A–Z, or Z–A order without changing their stored meaning. The page can render symbol chips and a TradingView watchlist. More importantly, the list can guide news retrieval. When symbols exist, OpenStock asks for company news related to them; when no symbols exist, it keeps general market news as the fallback. Persistence therefore affects what context the application tries to assemble next.

That relationship makes the watchlist durable without making it a portfolio. A saved symbol does not prove that the user owns shares, has placed an order, or intends to buy. It expresses attention. The application can use that attention to tailor the next information request, but it does not acquire custody of the asset or a financial claim over it.