Scroll
Index / Work / 06 · Insighta Labs
2025 HNG Internship 14 · Stage 2 Backend Solo · backend NestJS · SupabaseRule-based NLUBackend

A demographic query layer over a 2,026-row profiles table. Combinable filters, indexed sort, clamped pagination — and a rule-based natural-language endpoint that converts "young males from nigeria above 30" into the same filter object the typed query uses. No LLM, no embeddings, no external calls.

Client
HNG Internship 14 · Stage 2 Backend
Role
Solo · backend
Duration
11 / 2025
Stack
NestJS 11 · TypeScript · Supabase · PostgreSQL · class-validator
INSIGHTA LABS · 2025 · COVER PLATE
06 / 11
100%
rule-based NLU
4-layer
idempotent seeder
2026
rows · pre-seeded
§ 02 · Chapter

Natural language without an LLM

The /search endpoint runs a sequence of regex passes — gender, age-group keywords, the "young" bracket (16–24), comparators (above/below/older-than/under), age ranges (between N and M), and a longest-name-first country match against Intl.DisplayNames plus a curated alias table. "Male and female teenagers above 17" suppresses the gender filter on purpose; "banana" returns 400 with "Unable to interpret query." Every supported phrase has a worked example in the README.

§ 03 · Chapter

Idempotent by design

The seeder enforces "no duplicate records" at four layers: input normalisation (lowercase names, uppercase ISO codes, fill missing country names from Intl.DisplayNames), an intra-file dedup pass through a Map, a DB pre-check that filters out existing names per batch, and a final upsert with onConflict ignoreDuplicates. The second run inserts zero rows and prints "Seed is up to date" — every time.

§ 04 · Chapter

Query layer

Every filter column and every sort column carries a dedicated index. count: "exact" piggybacks the total onto the same SELECT so listing is one round-trip. Page and limit clamp instead of erroring on out-of-range values, because a paginated UI should never crash on a stale query string.

§99 · Continue

Have a brief?
Let's talk.

© 2026 · Moluno · Powered by sapa
v2.04.026 · 60Hz · 6.5244 N · 3.3792 E