Peopolz is a network of neighbourhood communities: each community has its own directory of local businesses with reviews and a map, its own wall and its own people. Building it raised product and engineering challenges, but the one that taught us the most was the search. A neighbour does not type “hairdresser”: they type “someone to fix my hair”, “my back hurts” or “hairdreser” with a typo. Solving that without blowing up the cost or sending anyone’s data to a model on every keystroke is an architecture problem, not a matter of “adding AI”. This is what we did and what we measured.
What is Peopolz and what is it built with?
Each community (a neighbourhood, a village, a housing estate) is its own space where members publish businesses they know, review them, write on a wall and can gather neighbourhood support in a petition. There are public and private communities. The project rests on the same MVP base I use to launch products (authentication, database, email, AI usage logging) and the stack is:
| Layer | Technology |
|---|---|
| Web | Next.js 15 with React 19 |
| API | Fastify with TypeScript and Zod validation |
| Data | PostgreSQL with PostGIS (locations) and pgvector (embeddings) |
| Maps | MapLibre over a PMTiles file in our own bucket |
| Deployment | Docker on a shared Hetzner server, with GitHub Actions |
A single database acts as directory, geographic engine and meaning index. There is no separate search service to maintain.
What were the main challenges?
Many communities, one codebase
Each community is an isolated tenant: its members, its moderation, its AI budget and its visibility. Private communities are not indexed, and the wall and the member directory carry noindex and are visible only to active members. Isolation is not solved in the interface but in every query: reads filter by community, and the community identifier travels in the session token.
Making a business owner the actual owner
Any member can publish a business they know, but the real owner must be able to claim it. The flow requires one to three documents (PDF or image), which the API checks are what they claim to be, and moderators open them through a signed URL that expires after ten minutes. As soon as the claim is resolved, the documents are deleted: the decision is kept, the ID card and the deeds are not. It is a challenge of trust more than of technology.
Maps and addresses without bills or violations
Maps are drawn with MapLibre over an OpenStreetMap PMTiles file hosted in our bucket: the browser requests only the chunks it needs, with no third-party keys and no per-visit cost. Geocoding (address to coordinates) uses Nominatim, whose policy forbids autocomplete and limits usage to one request per second. So we only geocode on save, through a one-request-per-second queue and with a cache.
AI cost and privacy
Each community has a monthly AI budget: an alert at 80% and, at 100%, calls are blocked until next month. All calls go through a shared layer that records tokens and cost. Search text is deleted from the logs after 90 days (the row with the cost remains) and who searched is never stored. With the model we measured something surprising: with reasoning enabled, a long answer was cut off at 8,000 tokens and cost almost twice as much as without reasoning, which returned it complete. We leave it off by default.
A shared server with little memory
Peopolz lives on a server shared with other projects and four gigabytes of memory. Images are built on GitHub, not on the server (a Next build would take it down), every service has a memory limit and log rotation, and the deployment rolls back to the previous version if the services are not healthy within three minutes.
How does the search work?
The search is hybrid: text plus meaning, with a language model only as a last resort. The usual (listing, filtering, searching “bakery”) never calls a paid model. There are five steps:
- Filters in SQL. Community, active status, category (a root category includes its children) and radius. This is never delegated to AI.
- Lexical ranking. A generated
tsvectorcolumn in Spanish, accent-insensitive (name weighs more than tags, and tags more than description and address) with a GIN index; name similarity by trigrams, which tolerates typos such as “hairdreser”; and a match against the category name, so “bakeries” finds a business that never wrote the word. Words are matched by prefix. - Semantic ranking. Each business has a 1,536-dimension vector (
text-embedding-3-small) in an HNSW index with cosine distance. Only businesses within 0.68 of the query and no more than 0.05 from the best result count. - Reciprocal rank fusion (RRF). Each list contributes
1 / (60 + position)and the scores are added: whoever appears high in several lists moves up, without comparing different scales. - Reformulation with a model. Only if all of the above finds nothing. A small model returns up to six keywords and a real category from the community, the search is repeated and at most ten results are added.
Why two thresholds for the embeddings?
An embedding always returns “the closest thing”, even if it resembles nothing. If you search “patent leather shoes” in a neighbourhood with no shoe shops, the nearest business still exists, just far away. An absolute ceiling (0.68) discards what is far; a margin relative to the best result (0.05) removes the noise that accompanies it. With a ceiling of 0.62 alone we got a precision of 0.88 and a recall of 0.72. With a ceiling of 0.68 and a 0.05 margin, precision held at 0.88 and recall rose to 0.91.
And the AI reformulation?
It is the safety net. When text and meaning search come back empty, the model translates the user’s intent into words and into a category that exists in that community. The output is validated with Zod and the user’s text is always treated as data, never as instructions. By design it happens rarely: it is the expensive exception in a search that is almost always cheap.
Cost and degradation
- The vector for each query is computed once: process memory, then a cache table, and only then the provider. If it takes more than 1.5 seconds, that search runs on text alone.
- The vectors for businesses are computed in the background when one is published or edited. A hash of the text avoids paying again if it has not changed: changing opening hours or the address costs nothing.
- Without a provider key, without credit or without budget, the search keeps working on text. AI improves the result, but it is not a single point of failure.
How did we measure whether it works?
On 27 October 2026 we labelled 37 queries over 14 businesses in one community: 31 with an expected business and 6 with none. We treat those figures (an F1 of 0.89) as guidance, not as a guarantee: it is a small sample from a single community. The most useful thing we found is that no threshold fully separates the queries without an answer: “patent leather shoes” sat between 0.61 and 0.74 from the nearest business, overlapping with legitimate queries. It is rescued or emptied by the reformulation step, not by a magic number. We will recalibrate when the real catalogue exceeds a few hundred businesses or we change embedding model, because distances are not comparable between models.
What limits do we know about?
- The HNSW index filters after searching. With very restrictive filters in a huge community it could return few candidates. It does not happen with current communities; if it grows, we would need pgvector 0.8’s iterative scan.
- “Open now” and proximity do not score in relevance: they are explicit filters and sort orders chosen by the person searching.
- An embedding does not understand a neighbourhood. What counts is the text each business writes about itself, so search quality depends on the quality of the listings.
What lessons do we take to other projects?
- AI as a last resort, not as the first layer. Text and meaning cover almost everything at nearly zero cost. The language model handles the rest.
- Budget, logging and degradation from day one. If you cannot answer “how much does this cost and what happens if it fails?”, you are not ready to put it in production. I cover this in more depth in RAG for startups: costs and privacy.
- Measure with your own data. A handful of labelled queries is worth more than any generic threshold advice.
- Use the database you already have. PostgreSQL with pgvector saves one more service. To choose well in an MVP, see how to integrate AI into an MVP without technical debt.
Quick questions
Did we need a separate vector database?
No. With communities of hundreds or a few thousand businesses, pgvector inside PostgreSQL is enough, and it keeps filters, text and meaning in a single query.
Which AI provider does it use?
Embeddings come from OpenAI’s text-embedding-3-small. Reformulation uses a small, configurable model through a shared layer that supports Anthropic, AWS Bedrock and OpenAI.
Can you build something like this for my product?
Yes. I launch MVPs in 2-3 weeks on this same base, with meaning-based search if your case justifies it. Before building, define the scope with MVP Factory.
Sounds familiar?
Tell me your case. I reply within 24 business hours and tell you honestly whether I can help.
Tell me your case