Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A2Search

A search engine that only knows agriculture in Africa. It crawls agricultural sites for pages, PDFs, spreadsheets, images and videos, indexes everything locally, and answers questions the way a farmer or agripreneur actually asks them. Type "tanzania vs kenya maize" and you get a production chart next to the results. Type "gross margin" and you get a working calculator, not ten links about accounting.

The full plan, including which open source projects we reuse and why, is in .plan.md. Progress lives on the project board.

How it is put together

Three services share one Postgres database, one Meilisearch index and one MinIO file store.

The crawler starts from about a hundred trusted seed domains (FAO, CGIAR centers, ministry sites, statistics bureaus) and scores every link against an agriculture word list in English and Swahili before fetching it. Pages that turn out not to be about agriculture get dropped. PDF, CSV and Excel files go into MinIO. Images and YouTube links from accepted pages go into a media table. Built on Crawl4AI.

The indexer parses each file, splits the text into pieces, embeds them with a local Ollama model (or Hugging Face, one line in .env switches it), and writes to Meilisearch for keyword search and pgvector for meaning search.

The API combines both search results, streams a short cited answer from whatever model you point it at (Groq, OpenAI, or local Ollama, same client), and routes questions to instant answers: country comparisons, crop and region panels, a feed mix solver, gross margin and break even calculators. Country data comes from a local copy of FAOSTAT covering all 52 African countries.

The frontend is Next.js. It follows your system's light or dark setting.

Running it

You need Postgres with pgvector, Meilisearch, MinIO and Ollama installed (all available through Homebrew), plus Python 3.11+ with uv and Node.

cp .env.example .env        # pick your embedding provider and answer model
uv venv .venv
uv pip install -e ./indexer -e ./api -e ./crawler
createdb agrisearch
.venv/bin/a2-ingest data/seed              # index your own documents
.venv/bin/uvicorn a2search_api.main:app --port 8000
cd frontend && npm install && npm run dev  # interface on localhost:3000

To grow the index, check the seed list is healthy and crawl:

.venv/bin/python scripts/validate_seeds.py
.venv/bin/a2-crawl --max-pages 100

The first FAOSTAT question you ask downloads and caches the dataset, or run .venv/bin/a2-load-faostat ahead of time.

Where it stands

Search, the AI answer, the calculators and the country, crop and region panels all work locally. The crawler has indexed a few hundred pages from Tanzanian government and university sites so far. Next: a larger crawl, better ranking for trusted sources, proper Swahili query handling, and deployment.

About

Agriculture search engine for Africa. Documents, data, images, videos and instant farm business answers.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages