Skip to content

About

Distributed file ingestion pipeline built with Go and Python, leveraging OCR, Sentence-Transformers embeddings, SQLite vector storage, and semantic retrieval.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Smart File Manager (Local Semantic Search Engine)

A local AI-powered file management system that enables semantic search over your files โ€” find documents based on meaning, not just filenames.


๐Ÿš€ Overview

Traditional file systems rely on exact filename matching or keyword search, which often fails when:

  • File names donโ€™t reflect content
  • You forget exact keywords
  • Documents contain rich semantic information

This project solves that by building a real-time ingestion + semantic retrieval pipeline.

๐Ÿ” Search files like: โ€œdocuments about reinforcement learningโ€ instead of remembering filenames.


โš™๏ธ What It Does

โœ… Real-time File Monitoring

  • Watches a directory for new or modified files
  • Uses fsnotify + polling fallback for reliability across environments (Docker, Windows)

โœ… Automatic Content Extraction

  • Extracts text from:

    • Images (OCR via EasyOCR)
    • Documents (PDFs, text files)
  • Uses a Python microservice

โœ… Embedding Generation

  • Converts extracted text into vector embeddings using:

    • sentence-transformers (all-MiniLM-L6-v2)
  • CPU-optimized for local machines

โœ… Persistent Storage

  • Stores:

    • File metadata
    • Extracted text
    • Vector embeddings
  • Uses SQLite (3NF schema design)

โœ… Semantic Search API

  • Accepts natural language queries
  • Converts query โ†’ embedding
  • Computes similarity (Cosine Similarity)
  • Returns top-k most relevant files

๐Ÿงฑ Architecture

          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚  File System โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
        (fsnotify + poller)
                 โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚   Watcher (Go) โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚ Worker Pool     โ”‚
         โ”‚ (Concurrency)   โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚ HTTP
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚ Extraction Service   โ”‚
         โ”‚ (Python + AI Models) โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚ SQLite Storage โ”‚
         โ”‚ (Metadata + Vectors)
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚ Search API (Go)โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿง  Core Concepts & Logic

๐Ÿ” Event-driven + Polling Hybrid Watcher

  • Uses fsnotify for real-time events
  • Adds polling fallback to handle Docker/Windows filesystem inconsistencies
  • Ensures no file changes are missed

โšก Worker Pool (Concurrency)

  • Implements a bounded worker pool in Go
  • Handles multiple file events concurrently
  • Prevents blocking of the watcher thread

๐Ÿ”„ Transactional DB Writes

Each file ingestion follows:

Begin Transaction
  โ†’ Upsert File
  โ†’ Insert Extraction
  โ†’ Insert Embedding
Commit

Ensures:

  • Consistency
  • No partial writes
  • Safe concurrent processing

๐Ÿงฎ Semantic Search (Vector Similarity)

  • Query โ†’ embedding vector
  • Stored embeddings โ†’ loaded from DB
  • Similarity computed using:
Cosine Similarity
  • Top-K results returned based on ranking

๐Ÿงฉ Microservice Separation

Service Responsibility
Watcher (Go) File monitoring + ingestion
Extractor (Python) OCR + embeddings
API (Go) Semantic search

๐Ÿ›  Tech Stack

Backend

  • Go (Golang)

    • Concurrency (goroutines, channels)
    • Worker pool design
    • HTTP server

AI / ML

  • Python
  • FastAPI
  • Sentence-Transformers
  • EasyOCR

Database

  • SQLite

    • Relational schema (3NF)
    • Vector storage (BLOB)

Infrastructure

  • Docker + Docker Compose

  • Volume mounts for:

    • watched/ (input files)
    • data/ (database)
    • models/ (AI models)

๐Ÿ“ฆ Features

  • ๐Ÿ” Semantic file search (meaning-based)
  • โšก Real-time ingestion pipeline
  • ๐Ÿงต Concurrent processing with worker pool
  • ๐Ÿง  AI-powered embeddings
  • ๐Ÿ’พ Persistent local storage
  • ๐Ÿณ Fully containerized setup
  • ๐Ÿ” Robust file watching (polling fallback)

โ–ถ๏ธ Getting Started

1. Clone the repository

git clone <repo-url>
cd AIFileManager

2. Start services

docker compose up --build

3. Add files

Place files inside:

watched/

They will be automatically indexed.


4. Search

curl -X POST http://localhost:8080/search \
-H "Content-Type: application/json" \
-d '{"query":"machine learning","top_k":3}'

๐Ÿ“ Project Structure

cmd/
  โ”œโ”€โ”€ watcher/
  โ””โ”€โ”€ api/

internal/
  โ”œโ”€โ”€ watcher/
  โ”œโ”€โ”€ worker/
  โ”œโ”€โ”€ storage/
  โ”œโ”€โ”€ search/
  โ”œโ”€โ”€ client/
  โ”œโ”€โ”€ model/
  โ””โ”€โ”€ debounce/

extraction-service/
  โ”œโ”€โ”€ app/
  โ””โ”€โ”€ Dockerfile

data/
watched/
models/
docker-compose.yml

โš ๏ธ Known Challenges & Solutions

โŒ File events not detected in Docker

โœ” Solved using polling fallback


โŒ Extractor not ready at startup

โœ” Add retry logic / health checks


โŒ Large Docker image size

โœ” Optimized using:

  • CPU-only PyTorch
  • Slim base images
  • External model volume

๐Ÿš€ Future Improvements

  • ANN indexing (FAISS / HNSW)
  • UI for browsing/search
  • File preview support
  • Incremental re-indexing
  • Distributed storage
  • Streaming ingestion pipeline

๐ŸŽฏ Key Learnings

  • Building event-driven systems
  • Handling cross-platform filesystem issues
  • Designing concurrent pipelines in Go
  • Integrating AI into backend systems
  • Managing multi-service architectures

๐Ÿ“Œ Summary

This project demonstrates how to build a production-style AI system combining:

  • Backend engineering (Go)
  • AI/ML (Python)
  • Data systems (SQLite)
  • Infrastructure (Docker)

๐Ÿ‘‰ Result: A local semantic search engine for your files


๐Ÿค Acknowledgement

Built as a hands-on project to explore:

  • Backend system design
  • AI integration
  • Real-world data pipelines

About

Distributed file ingestion pipeline built with Go and Python, leveraging OCR, Sentence-Transformers embeddings, SQLite vector storage, and semantic retrieval.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages