How hapijul-trigent/esearch works
Project type and purpose
• This is a microservice‐style search API built with FastAPI.
• Purpose: Provide intelligent, natural‐language–driven search over employee records using LangChain + Ollama (Gemma 3:1b) + FAISS for vector retrieval.
File structure
• Top-level:
• app/ – main application package
• data/ – static JSON data fallback
• requirements.txt, README.md
• app/ submodules:
• main.py – FastAPI app & endpoints
• data_loader.py – loads employees.json → in-memory list
• retriever.py – builds FAISS vector store from loaded data
• llm_chain.py – configures LangChain chain with Ollama model
• schema.py – Pydantic request/response models
• retriever.py & llm_chain.py handle two distinct flows (filter search vs. chat LLM)
• data/employees.json – primary data source
README for architectural cues
• Endpoints: /employees/search, /chat, /health
• External dependency: Ollama service running Gemma 3:1b
• In-process vector store (FAISS)
• Core flow: HTTP Request → FastAPI → Retriever/LLM chain → Ollama → Response
Main components and relationships
a. Client (Browser/CLI/Postman)
b. FastAPI Server (uvicorn/app.main)
• Endpoints layer (routes/controllers)
• Business logic layer:
• DataLoader (loads JSON)
• Retriever (FAISS index & similarity search)
• LLMChain (LangChain wrapper calling Ollama)
c. Data store
• Static JSON (app/data/employees.json)
• FAISS in-memory vector store (built at startup)
d. External service
• Ollama API (Gemma 3:1b model)
Interactions:
1. Client sends HTTP GET /employees/search → FastAPI → DataLoader → Retriever → return filtered + vector search results
2. Client sends HTTP POST /chat → FastAPI → LLMChain → Ollama API → return LLM response
Architectural patterns & design principles
• Layered architecture: Controllers → Services (loader, retriever, chain) → External services
• Single‐process microservice: no separate DB server; uses file + memory store
• Dependency injection via function parameters in FastAPI routes
• Separation of concerns: data loading vs. vector retrieval vs. LLM orchestration
Specific elements
• Labels: module names, endpoint names, data formats
• Notes:
• FAISS is in-memory, built at startup
• Ollama must be running separately
• DataLoader reads from app/data/employees.json