SShortSingh.
Back to feed

How one developer enforced free-plan limits inside Postgres instead of the UI

0
·5 views

A developer building a release-tracker app moved free-plan enforcement from the frontend into a PostgreSQL database trigger, arguing that UI-side checks are easily bypassed via extra tabs, stale sessions, or direct API calls. The trigger fires before each insert into the follows table, counting existing rows for the user and rejecting any attempt to exceed 10 followed technologies on the free plan. A PostgreSQL advisory lock keyed to the user ID prevents race conditions where two simultaneous inserts could both pass the count check independently. Custom SQLSTATE error codes are returned through PostgREST directly to the browser, allowing the frontend to display precise, code-driven rejection messages without parsing error strings. The author notes the trigger also blocks follows of retired technologies and is designed to accommodate future paid-plan logic in a single, authoritative location.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

OpsMind AI Agent Uses Two-Stage Memory System to Learn from Past SRE Incidents

Engineers behind OpsMind, an AI site reliability engineering agent, designed a workflow that separates incident memory into two distinct operations: recalling historical context before diagnosis and retaining new outcomes after resolution. The system uses a tool called Hindsight as a persistent memory layer, querying past incidents based on current symptoms, service behavior, error patterns, and resource utilization rather than matching exact incident IDs. To avoid faulty automation, current telemetry and logs are treated as the primary evidence source, with historical memory serving only as supporting context. This prevents the agent from blindly reapplying old fixes to new incidents that may share surface-level symptoms but have different root causes. The design positions memory between evidence collection and AI reasoning, ensuring historical experience informs but does not override live operational data.

0
ProgrammingDEV Community ·

How to Build Scalable Payment Integrations with APIs, Webhooks and Fault Tolerance

Scalable payment integrations require strict controls at every layer, from outbound API calls to inbound webhook handling. Developers are advised to set explicit timeouts, implement exponential backoff retries, and use idempotency keys to prevent duplicate transactions caused by network uncertainty. Inbound webhooks should be acknowledged immediately with an HTTP 200 response, while all business logic is offloaded to background workers to avoid retry storms from payment gateways like Razorpay, which expect responses within five seconds. Deduplication using unique event IDs with database-level constraints ensures each webhook is processed only once, even when gateways redeliver events multiple times. Circuit breakers, token bucket rate limiting, and explicit state machines further protect application stability under high transaction loads.

0
ProgrammingDEV Community ·

Developer Guide: Building Scalable, Interoperable Health Record Platforms

Modern health record platforms require a structured technical architecture that goes beyond simple databases and APIs, according to a developer-focused guide published on DEV Community. These platforms must handle patient demographics, clinical workflows, and data exchange across multiple systems such as hospital EHRs, labs, pharmacies, and telehealth apps. The HL7 FHIR standard plays a central role, offering RESTful APIs and modular resources to enable standardized electronic health data exchange. A layered architecture — separating presentation, application services, integration, and data layers — is recommended to reduce coupling and improve maintainability. Developers are advised to map internal data models to FHIR resources and define interoperability requirements early, before implementing individual features.

0
ProgrammingDEV Community ·

Micelclaw's Activity Digest Offers a Quiet Catch-Up Tool for Returning Users

Developer platform Micelclaw has detailed a feature called the activity digest, designed to help users catch up on changes made while they were away without requiring real-time interruptions. The digest tracks new records across modules such as Notes, Events, and Bookmarks, then compiles them into a brief summary with a suggested next step. It operates separately from Micelclaw's background AI engine and can run during the day or overnight. The feature was demonstrated using a fictional event called Harbor Lights, with six artificially created records spanning three modules to simulate a realistic but entirely invented scenario. The resulting digest card displayed a change count, alert level, generated summary, and next-step suggestion, illustrating how the tool aims to inform rather than act on a user's behalf.