Building the DeryCode Search Engine in C
The DeryCode Search engine is a web-based search tool deployed at derycode-search-c.vercel.app. It provides answers about DeryCode's services, projects, and technical capabilities. What makes it unusual is that the core search logic is written in C — not Python, not JavaScript, not Go. Here's why we made that choice and how it works.
The Problem
We needed a search interface for the DeryCode knowledge base — information about our 20+ projects, service offerings, pricing, and technical expertise. The search needed to be fast, accurate, and deployable on Vercel's serverless platform. The obvious choices were Algolia, Elasticsearch, or a simple full-text search in a database. We chose to build our own — in C.
Why C?
Two reasons. First, performance. C gives us predictable, minimal-latency text processing with zero garbage collection overhead. For a search engine where every millisecond matters, this matters. Second, learning. Building a search engine from scratch in a systems language forces you to understand every detail: how text is tokenized, how relevance is scored, how memory is managed. Using a pre-built search library would have been faster to ship, but we'd have learned less about how search actually works under the hood.
How It Works
The search engine maintains an in-memory index of 21 documented projects. Each project entry contains structured data: name, description, technologies used, client, deployment URL, and category. When a query comes in, the C code tokenizes the search terms, builds a relevance score for each project entry, and returns ranked results.
The scoring algorithm is a custom variant of TF-IDF (Term Frequency - Inverse Document Frequency). It weights matches in the project name higher than matches in the description, and gives bonus weight to technology keyword matches. The result is a ranked list that surfaces the most relevant project for any given query.
Deployment Architecture
Deploying C on Vercel is unconventional. Vercel is designed for JavaScript/TypeScript serverless functions. We compile the C code to a standalone binary and wrap it in a thin Node.js serverless function that handles HTTP requests, passes the query to the C binary via stdin, and returns the JSON output. The C binary does the heavy lifting; Node.js handles the HTTP layer.
This architecture means cold starts include a process spawn, which adds latency on the first request. For subsequent requests, the binary stays warm. The trade-off is acceptable for our use case — the search engine serves a knowledge base, not a high-traffic consumer product.
What We Learned
Building a search engine in C taught us three things. First, most "search" problems are simpler than they look. A well-tuned TF-IDF implementation on a small, curated dataset outperforms many heavyweight search engines that are optimized for billions of documents. Second, deployment constraints drive architecture. If we'd used AWS EC2 instead of Vercel, we'd have deployed differently. The serverless constraint forced a creative solution. Third, rolling your own infrastructure is educational but not always the right business decision. For a client project, we'd use Algolia or Typesense. For our own learning and a controlled dataset, building from scratch was the right call.
PWA Features
The search engine frontend is also a PWA — installable on mobile, with voice input support using the Web Speech API. Users can speak their query instead of typing, which is useful for mobile users and accessibility. The results include confidence indicators so users know how reliable the answer is.
Current State
The search engine is live and handles queries about DeryCode's 21 projects and service categories. It's not a general-purpose search engine — it's a specialized tool for our knowledge base. But it's fast, it works, and it was built from first principles in a language most web developers would never choose for this task. Sometimes that's the point.
Need help with your project?
DeryCode builds enterprise software, AI systems, blockchain infrastructure, and digital platforms.
Start a Conversation →Related reading
- What is DeryCoin? Uganda's First Community Blockchain Token — ⭐ Featured · Blockchain
- How Digital Banking Software is Transforming SACCOs in Uganda — Banking Tech
- Building a PWA: Why Progressive Web Apps Are Perfect for Uganda — Web Development