A high-performance search engine for spare parts catalogs, built with a Thin Backend + Fat Database architecture. This project demonstrates advanced sub-string search optimization techniques for datasets exceeding 1,000,000 records.
The primary challenge with standard LIKE %query% searches in relational databases is the inability to utilize standard indexes, leading to a "Full Table Scan," which is unacceptable under high load.
This project implements Triad-based Indexing (n-gram approach):
- Data Layer: Every string is decomposed into 3-character segments (triads) upon insertion.
- Hashing: Triads are converted into numeric hashes and stored in a dedicated indexed table.
- Search: Instead of expensive text matching, the engine performs a lookup by the numeric hash of the first triad. This allows the database to use a B-Tree index, reducing search latency to milliseconds.
- Backend: Helidon (Java) serves as an ultra-lightweight proxy, delegating all business logic and JSON response formatting to the PostgreSQL layer (PL/pgSQL).
This project was architected and implemented in collaboration with Google Gemini over a 3-day intensive sprint. It showcases a modern "AI + Human" workflow, where complex database optimizations and cloud-native configurations were co-developed through iterative technical dialogue.
- Java 21 & Helidon MicroProfile 4.x/6.x: Minimalist RESTful API layer.
- PostgreSQL 17: Data processing, triggers, and core business logic.
- Docker & Docker Compose: Orchestration with integrated health checks.
- PL/pgSQL: "Database-as-a-Service" pattern implementation.
The core logic is implemented using a "Database-as-a-Service" pattern. While this version uses PostgreSQL 17, the architectural design is fully compatible with Oracle DB. The PL/pgSQL logic can be seamlessly ported to Oracle PL/SQL, making this solution ideal for enterprise environments transitioning between different database engines.
All CRUD and search logic is encapsulated within a single entry point in the database. This minimizes network overhead between the application and the database by transmitting only the final JSONB result.
A specialized trigger, trigger_index_triads, automatically updates the search index in real-time during INSERT or UPDATE operations on the parts_catalog table.
The system natively supports bulk data insertion and updates via JSONB arrays in a single request, which is critical for high-throughput enterprise systems.
To demonstrate production-grade performance, a data population script is included:
- Start the infrastructure:
docker-compose up -d
- Run the load test:
chmod +x load_test.sh ./load_test.sh
The script appends 900,000 records to the initial 100,000. You will observe that search latency remains stable even with a million-row catalog.
- Clone the repository.
- Run the build and start command:
docker-compose up --build
- The UI will be available at:
http://localhost:8080/search/ui(static frontend bundled in resources).
| Method | Path | Description |
|---|---|---|
GET |
/search?q=PART-100 |
Search by part number (Triad index) |
POST |
/search |
Single or Bulk data insertion |
PUT |
/search |
Single or Bulk data update |
DELETE |
/search?q={id} |
Delete record by ID |
This project is licensed under the MIT License - see the LICENSE file for details.
Developed in 3 days with ❤️, Java, and Google Gemini.