Skip to content

Latest commit

Β 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”Ž FindMyRepo

Python React FastAPI MongoDB Gemini

An AI-powered platform for discovering open-source GitHub repositories through semantic natural language search.


🎬 Demo

FindMyRepo demo


✨ Core Features

  • 🧠 Semantic Search β€” Describe what you need in plain English. Atlas Vector Search finds the most relevant repositories across a corpus of 43k+ repos using cosine similarity on 384-dimension embeddings.
  • 🎯 Personalized Recommendations β€” Onboard with your role, expertise, and preferred languages. Gemini AI maps your profile to a multi-factor scoring algorithm covering language match, domain relevance, popularity, and recency.
  • πŸ’Ž Hidden Gems β€” A curated feed of high-quality, under-1k-star repositories that are actively maintained and well-documented β€” repos you won't find on any trending page.
  • πŸŽƒ Hacktoberfest Explorer β€” Dedicated page to browse Hacktoberfest-tagged repos with advanced filters for first-time contributors.
  • πŸ”– Saved Repos β€” Bookmark any repository locally. Your collection persists across sessions via localStorage.
  • πŸ”— Shareable Search URLs β€” Every search syncs to the browser URL (?q=your+query). Share a link and your recipients land on the same results.
  • ♾️ Relevance-Filtered Infinite Scroll β€” Results stream in 20 at a time. Only repositories above a cosine similarity threshold are shown; the feed ends naturally when relevance drops.
  • 🧭 Advanced Filtering β€” Filter the full catalog by language, topics, star range, fork range, name, description, and special categories (GSoC, Hacktoberfest, underrated).

πŸ— Architecture & Engineering Decisions

System Diagram

FindMyRepo system architecture

Key Engineering Decisions

MongoDB Atlas Vector Search (HNSW) Search was originally backed by Weaviate and a Gemini-generated MongoDB filter. The filter approach limited coverage to repos with exact matching topic tags β€” as few as 28 results from 43k. Migrating to Atlas Vector Search's HNSW index on the embedding field (384-dim cosine similarity) queries the full corpus semantically, consistently returning 60–100 relevant results without any filter generation overhead.

all-MiniLM-L6-v2 Embeddings Each repository is embedded as a concatenation of its title, primary language, topics, and README excerpt. At inference time, the user query is embedded with the same model. The 384-dimension space is large enough for strong semantic resolution while remaining fast enough to embed queries in under 100ms on CPU.

Gemini AI β€” Scoped to /userpreferences Only Gemini is deliberately kept out of the search path after the Vector Search migration. It is retained exclusively for the /userpreferences endpoint, where it maps a structured user profile (role, domains, languages) into a MongoDB filter for personalized recommendations. Isolating AI generation to structured inputs reduces latency and eliminates the risk of hallucinated search filters.

Relevance Cutoff on the Frontend Each search result carries a similarity_score (0–1) from Atlas Vector Search. The frontend filters out results below 0.6 and renders the rest in batches of 20 via IntersectionObserver. This means the page ends organically when the results are no longer meaningfully relevant β€” without any hard-coded result cap visible to the user.


πŸ’» Tech Stack

Component Technology
Frontend React 18, TypeScript, Vite, Tailwind CSS, shadcn/ui, React Query
Backend FastAPI, Pydantic v2, Uvicorn
AI / Search MongoDB Atlas Vector Search (HNSW), sentence-transformers (all-MiniLM-L6-v2), Google Gemini AI
Database MongoDB Atlas
Testing pytest, mongomock, FastAPI TestClient Β· Vitest, Testing Library

πŸ“‚ Project Structure

FindMyRepo/
β”œβ”€β”€ backend/                 # FastAPI service
β”‚   β”œβ”€β”€ main.py              # Routes, lifespan, CORS
β”‚   β”œβ”€β”€ models.py            # Pydantic schemas
β”‚   β”œβ”€β”€ database.py          # MongoDB connection singleton
β”‚   β”œβ”€β”€ ingest_repos.py      # GitHub data ingestion script
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ search.py        # Atlas Vector Search pipeline
β”‚   β”‚   β”œβ”€β”€ recommendations.py
β”‚   β”‚   └── repository.py    # Filtering, pagination, hidden gems
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ gemini_service.py
β”‚   β”‚   β”œβ”€β”€ embeddings.py
β”‚   β”‚   └── helpers.py
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   └── create_indexes.py
β”‚   └── tests/               # pytest suite (99 tests)
β”‚
└── frontend/                # React + Vite client
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ pages/           # Home, Search, AllRepos, HiddenGems,
    β”‚   β”‚   β”‚                #   Hacktoberfest, Saved, Onboarding
    β”‚   β”œβ”€β”€ components/      # Navbar, RepoCard, ErrorBoundary, …
    β”‚   β”œβ”€β”€ contexts/        # BookmarksContext, PreferencesContext
    β”‚   β”œβ”€β”€ lib/             # api.ts, transforms.ts, utils.ts
    β”‚   └── __tests__/       # Vitest suite (27 tests)
    └── public/

πŸš€ Getting Started

Prerequisites

  • Python 3.14+
  • Node.js 18+
  • MongoDB Atlas cluster (free tier works)
  • Google Gemini API key β€” Get one here
  • GitHub Personal Access Token β€” Generate here (ingestion only)

βš™οΈ Environment Variables

Backend β€” backend/.env
MONGO_URI=mongodb+srv://<user>:<pass>@cluster0.xxxxx.mongodb.net/?appName=Cluster0
GEMINI_API_KEY=your_gemini_api_key
GITHUB_TOKEN=github_pat_...          # ingestion only
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:8080
HOST=0.0.0.0
PORT=8000
Frontend β€” frontend/.env
VITE_API_BASE_URL=http://localhost:8000
VITE_SEARCH_API_URL=http://localhost:8000/search
VITE_USER_PREFERENCES_API=http://localhost:8000/userpreferences
VITE_ALL_REPOS_ENDPOINT=/allrepos
VITE_HIDDEN_GEMS_ENDPOINT=/hiddengem

πŸ’» Running Locally

Backend

cd backend
python -m venv venv && source venv/bin/activate   # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env   # fill in credentials
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

API base: http://localhost:8000 Β· Swagger UI: http://localhost:8000/docs

Frontend

cd frontend
npm install
cp .env.example .env   # set VITE_API_BASE_URL
npm run dev

Client: http://localhost:8080


πŸ“₯ Data Ingestion

The ingestion script fetches GitHub repositories, enriches each with full language lists and a cleaned README, generates a 384-dim embedding, and upserts into MongoDB.

cd backend
python ingest_repos.py
  • Progress is checkpointed to ingestion_state.json β€” interrupted runs resume automatically.
  • GitHub API rate limits are respected; the script pauses when limits are approached.
  • After ingestion, create the required MongoDB indexes:
python scripts/create_indexes.py

Then create the Atlas Vector Search index manually in the Atlas UI:

  1. Atlas β†’ Cluster β†’ Atlas Search β†’ Create Search Index β†’ Atlas Vector Search β†’ JSON Editor
  2. Use this definition and name the index embedding_vector_index:
{
  "fields": [
    {
      "type": "vector",
      "path": "embedding",
      "numDimensions": 384,
      "similarity": "cosine"
    }
  ]
}

🌐 API Overview

Endpoint Method Description
/ GET Health ping
/health GET DB connection check + repository count
/search POST Semantic search via Atlas Vector Search
/userpreferences POST Personalized recommendations from user profile
/allrepos GET Paginated catalog with filtering and sorting
/hiddengem GET Paginated hidden gems feed
/repo/{owner}/{name} GET Single repository detail with README

πŸ§ͺ Tests

# Backend β€” 99 tests
cd backend && pytest tests/ -v

# Frontend β€” 27 tests
cd frontend && npm test

☁️ Deployment

Backend (Railway, Render, Fly.io)
  • Root directory: backend/
  • Build command: pip install -r requirements.txt
  • Start command: uvicorn main:app --host 0.0.0.0 --port $PORT
  • Inject MONGO_URI, GEMINI_API_KEY, and ALLOWED_ORIGINS as environment variables.
Frontend (Vercel, Netlify)
  • Root directory: frontend/
  • Build command: npm run build
  • Output directory: dist
  • Set VITE_API_BASE_URL to your production backend URL.
  • frontend/vercel.json includes SPA rewrites β€” no extra configuration needed for Vercel.

πŸ›‘οΈ Production Considerations

  • CORS β€” Restrict ALLOWED_ORIGINS to your exact frontend domain in production.
  • Secrets β€” Store all API keys in your platform's secret manager, never in committed files.
  • Atlas Network Access β€” Restrict MongoDB Atlas IP whitelist to your backend's egress IPs in production (avoid 0.0.0.0/0).


Built by Team DOTENV

Releases

Packages

Contributors

Languages