How michelabdelmalek/freightrag works
FreightRAG is a multi-tenant logistics-document RAG system; this repository’s implemented product covers document ingestion, tenant-scoped storage, and ranked-chunk search (not answer generation). The main workflow is tenant files → section chunks → Ollama embeddings → Postgres, followed by authenticated API search. The graph also includes document reads, tenant resolution, and migration as a distinct operational capability. Edges use README statements or indexed source references; links to unsampled search internals are marked unverified.
Main entry points: IngestDocument.cs Ingest handler · FolderIngestor.cs Folder ingestor · FreightRagDbContext.cs EF database context · SearchChunks.cs Chunk search use case
Components 25
Ingestion
- Folder ingestor
src/FreightRag.Ingest/FolderIngestor.cs - Ingest host
src/FreightRag.Ingest/Program.cs
Domain and application
- Ingest handler
src/FreightRag.Core/Application/IngestDocument.cs - Section chunker
src/FreightRag.Core/Domain/SectionChunker.cs - Document aggregate
src/FreightRag.Core/Domain/FreightDocument.cs - Embedding port
src/FreightRag.Core/Application/Ports/IEmbeddingService.cs - Document repository port
src/FreightRag.Core/Application/Ports/IDocumentRepository.cs - Chunk search use case
src/FreightRag.Core/Application/Search/SearchChunks.cs
Infrastructure
- Tenant directory
src/FreightRag.Core/Infrastructure/Tenants/ConfiguredTenantDirectory.cs - Ollama embeddings
src/FreightRag.Core/Infrastructure/Embedding/OllamaEmbeddingService.cs - EF document repository
src/FreightRag.Core/Infrastructure/Persistence/EfDocumentRepository.cs - EF database context
src/FreightRag.Core/Infrastructure/Persistence/FreightRagDbContext.cs - Chunk search adapter
src/FreightRag.Core/Infrastructure/Persistence/EfChunkSearch.cs - Document queries
src/FreightRag.Core/Infrastructure/Persistence/EfDocumentQueries.cs - Schema migrator
src/FreightRag.Migrator/Program.cs - Database migrator
src/FreightRag.Core/Infrastructure/Persistence/DatabaseMigrator.cs
HTTP API
- Search endpoint
src/FreightRag.Api/Endpoints/SearchEndpoints.cs - Document endpoints
src/FreightRag.Api/Endpoints/DocumentEndpoints.cs - API key authentication
src/FreightRag.Api/Security/ApiKeyAuthenticationHandler.cs - API key store
src/FreightRag.Api/Security/ApiKeyStore.cs
Other components
- Ingest operator
- Tenant text files
- Ollama model
- Postgres + pgvector
- API client
Connections 28
- Ingest operator → Ingest host: starts run
README.md - Tenant text files → Folder ingestor: reads files
src/FreightRag.Ingest/FolderIngestor.cs - Ingest host → Folder ingestor: runs
src/FreightRag.Ingest/Program.cs - Folder ingestor → Ingest handler: submits documents
src/FreightRag.Ingest/FolderIngestor.cs - Ingest handler → Section chunker: splits text
src/FreightRag.Core/Application/IngestDocument.cs - Ingest handler → Document aggregate: creates aggregate
src/FreightRag.Core/Application/IngestDocument.cs - Folder ingestor → Tenant directory: resolves tenant
src/FreightRag.Ingest/FolderIngestor.cs - Ingest handler → Tenant directory: resolves tenant
src/FreightRag.Core/Application/IngestDocument.cs - Ingest handler → Embedding port: embeds chunks
src/FreightRag.Core/Application/IngestDocument.cs - Ollama embeddings → Embedding port: implements
src/FreightRag.Core/Infrastructure/Embedding/OllamaEmbeddingService.cs - Ollama embeddings → Ollama model: requests vectors
src/FreightRag.Core/Infrastructure/Embedding/OllamaEmbeddingService.cs - Ingest handler → Document repository port: stores document
src/FreightRag.Core/Application/IngestDocument.cs - EF document repository → Document repository port: implements
src/FreightRag.Core/Infrastructure/Persistence/EfDocumentRepository.cs - EF document repository → EF database context: persists records
src/FreightRag.Core/Infrastructure/Persistence/EfDocumentRepository.cs - EF database context → Postgres + pgvector: reads and writes
README.md - API client → API key authentication: authenticates
README.md - API key authentication → API key store: checks key
src/FreightRag.Api/Security/ApiKeyAuthenticationHandler.cs - API client → Search endpoint: searches
README.md - Search endpoint → Chunk search use case: dispatches search
src/FreightRag.Api/Endpoints/SearchEndpoints.cs - Chunk search use case → Chunk search adapter: queries chunks
- Chunk search use case → Embedding port: embeds query
- Chunk search adapter → EF database context: queries vectors
- API client → Document endpoints: manages documents
README.md - Document endpoints → Ingest handler: uses ingestion
README.md - Document endpoints → Document queries: reads documents
- Document queries → EF database context: reads records
- Schema migrator → Database migrator: applies migrations
src/FreightRag.Migrator/Program.cs - Database migrator → Postgres + pgvector: upgrades schema
README.md