SmartRAG 1.0.0
See the version list below for details.
dotnet add package SmartRAG --version 1.0.0
NuGet\Install-Package SmartRAG -Version 1.0.0
<PackageReference Include="SmartRAG" Version="1.0.0" />
<PackageVersion Include="SmartRAG" Version="1.0.0" />
<PackageReference Include="SmartRAG" />
paket add SmartRAG --version 1.0.0
#r "nuget: SmartRAG, 1.0.0"
#:package SmartRAG@1.0.0
#addin nuget:?package=SmartRAG&version=1.0.0
#tool nuget:?package=SmartRAG&version=1.0.0
π SmartRAG - Enterprise-Grade RAG Solution
SmartRAG is a production-ready .NET 9.0 library that provides a complete Retrieval-Augmented Generation (RAG) solution for building AI-powered question answering systems. Upload your documents, ask questions in natural language, and get intelligent answers based on your content - all with enterprise-grade AI providers and storage options.
β¨ Key Highlights
- π― AI Question Answering: Ask questions about your documents and get intelligent, contextual answers
- π€ Universal AI Support: 5 dedicated providers + CustomProvider for unlimited AI APIs
- π’ Enterprise Storage: Vector databases, Redis, SQL, FileSystem with advanced configurations
- π§ Advanced RAG Pipeline: Smart chunking, semantic retrieval, AI-powered answer generation
- β‘ Lightning Fast: Optimized vector search with context-aware answer synthesis
- π Plug & Play: Single-line integration with dependency injection
- π Multi-Format: PDF, Word, text files with intelligent parsing
π― What Makes SmartRAG Special
π Complete RAG Workflow
π Document Upload β π Smart Chunking β π§ AI Embeddings β πΎ Vector Storage
β
πββοΈ User Question β π Find Relevant Chunks β π€ AI Answer Generation β β¨ Smart Response
π Production Features
- Smart Chunking: Maintains context continuity between document segments
- Multiple Storage Options: From in-memory to enterprise vector databases
- AI Provider Flexibility: Switch between providers without code changes
- Document Intelligence: Advanced parsing for PDF, Word, and text formats
- Configuration-First: Environment-based configuration with sensible defaults
- Dependency Injection: Full DI container integration
π¦ Installation
NuGet Package Manager
Install-Package SmartRAG
.NET CLI
dotnet add package SmartRAG
PackageReference
<PackageReference Include="SmartRAG" Version="1.0.0" />
π Quick Start
1. Basic Setup
using SmartRAG.Extensions;
using SmartRAG.Enums;
var builder = WebApplication.CreateBuilder(args);
// Add SmartRAG with minimal configuration
builder.Services.UseSmartRAG(builder.Configuration,
storageProvider: StorageProvider.InMemory, // Start simple
aiProvider: AIProvider.OpenAI // Your preferred AI
);
var app = builder.Build();
2. Upload Documents
public class DocumentController : ControllerBase
{
private readonly IDocumentService _documentService;
[HttpPost("upload")]
public async Task<IActionResult> Upload(IFormFile file)
{
var document = await _documentService.UploadDocumentAsync(
file.OpenReadStream(),
file.FileName,
file.ContentType,
"user-123"
);
return Ok(document);
}
}
3. AI-Powered Question Answering
public class QAController : ControllerBase
{
private readonly IDocumentService _documentService;
[HttpPost("ask")]
public async Task<IActionResult> AskQuestion([FromBody] QuestionRequest request)
{
// User asks: "What are the main benefits mentioned in the contract?"
var response = await _documentService.GenerateRagAnswerAsync(
request.Question,
maxResults: 5
);
// Returns intelligent answer based on document content
return Ok(response);
}
}
4. Configuration
β οΈ Security Note: Never commit real API keys! Use appsettings.Development.json for local development.
# Copy template and add your real keys
cp src/SmartRAG.API/appsettings.json src/SmartRAG.API/appsettings.Development.json
appsettings.Development.json (your real keys):
{
"AI": {
"OpenAI": {
"ApiKey": "sk-proj-YOUR_REAL_KEY",
"Model": "gpt-4",
"EmbeddingModel": "text-embedding-ada-002"
}
},
"Storage": {
"InMemory": {
"MaxDocuments": 1000
}
}
}
π Complete Configuration Guide
π€ AI Providers - Universal Support
π― Dedicated Providers (Optimized & Battle-Tested)
| Provider | Capabilities | Special Features |
|---|---|---|
| π€ OpenAI | β Latest GPT models<br/>β Advanced embeddings | Industry standard, reliable, extensive model family |
| π§ Anthropic | β Claude family models<br/>β High-quality embeddings | Safety-focused, constitutional AI, long context |
| π Google Gemini | β Gemini models<br/>β Multimodal embeddings | Multimodal support, latest Google AI innovations |
| βοΈ Azure OpenAI | β Enterprise GPT models<br/>β Enterprise embeddings | GDPR compliant, enterprise security, SLA support |
π οΈ CustomProvider - Universal API Support
One provider to rule them all! Connect to any OpenAI-compatible API:
{
"AI": {
"Custom": {
"ApiKey": "your-api-key",
"Endpoint": "https://api.openrouter.ai/v1/chat/completions",
"Model": "anthropic/claude-3.5-sonnet",
"EmbeddingModel": "text-embedding-ada-002"
}
}
}
Supported APIs via CustomProvider:
- π OpenRouter - Access 100+ models
- β‘ Groq - Lightning-fast inference
- π Together AI - Open source models
- π Perplexity - Search + AI
- π«π· Mistral AI - European AI leader
- π₯ Fireworks AI - Ultra-fast inference
- π¦ Ollama - Local models
- π LM Studio - Local AI playground
- π οΈ Any OpenAI-compatible API
ποΈ Storage Solutions - Enterprise Grade
π― Vector Databases
{
"Storage": {
"Qdrant": {
"Host": "your-qdrant-host.com",
"ApiKey": "your-api-key",
"CollectionName": "documents",
"VectorSize": 1536
},
"Redis": {
"ConnectionString": "localhost:6379",
"KeyPrefix": "smartrag:",
"Database": 0
}
}
}
π’ Traditional Databases
{
"Storage": {
"Sqlite": {
"DatabasePath": "smartrag.db",
"EnableForeignKeys": true
},
"FileSystem": {
"FileSystemPath": "Documents"
}
}
}
β‘ Development
{
"Storage": {
"InMemory": {
"MaxDocuments": 1000
}
}
}
π Document Processing
Supported Formats
- π PDF: Advanced text extraction with iText7
- π Word: .docx and .doc support with OpenXML
- π Text: .txt, .md, .json, .xml, .csv, .html
- π€ Plain Text: UTF-8 encoding with BOM detection
Smart Document Parsing
// Automatic format detection and parsing
var document = await documentService.UploadDocumentAsync(
fileStream,
"contract.pdf", // Automatically detects PDF
"application/pdf",
"legal-team"
);
// Smart chunking with overlap for context preservation
var chunks = document.Chunks; // Automatically chunked with smart boundaries
Advanced Chunking Options
services.AddSmartRAG(configuration, options =>
{
options.MaxChunkSize = 1000; // Maximum chunk size
options.MinChunkSize = 100; // Minimum chunk size
options.ChunkOverlap = 200; // Overlap between chunks
options.SemanticSearchThreshold = 0.3; // Similarity threshold
});
π§ Advanced Configuration
Complete Configuration Example
{
"AI": {
"OpenAI": {
"ApiKey": "sk-...",
"Endpoint": "https://api.openai.com/v1",
"Model": "gpt-4",
"EmbeddingModel": "text-embedding-ada-002",
"MaxTokens": 4096,
"Temperature": 0.7
},
"Anthropic": {
"ApiKey": "sk-ant-...",
"Model": "claude-3.5-sonnet",
"MaxTokens": 4096,
"Temperature": 0.3
}
},
"Storage": {
"Qdrant": {
"Host": "localhost:6334",
"UseHttps": false,
"CollectionName": "smartrag_docs",
"VectorSize": 1536,
"DistanceMetric": "Cosine"
},
"Redis": {
"ConnectionString": "localhost:6379",
"Password": "",
"Database": 0,
"KeyPrefix": "smartrag:",
"ConnectionTimeout": 30,
"EnableSsl": false
}
}
}
Runtime Provider Switching
services.AddSmartRAG(configuration, options =>
{
options.AIProvider = AIProvider.OpenAI;
options.StorageProvider = StorageProvider.Qdrant;
options.EnableFallbackProviders = true;
options.FallbackProviders = [AIProvider.Anthropic, AIProvider.Gemini];
});
ποΈ Architecture
SmartRAG follows clean architecture principles with clear separation of concerns:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β API Layer β β Service Layer β β Repository Layerβ
β β β β β β
β β’ Controllers βββββΆβ β’ DocumentServiceβββββΆβ β’ Redis Repo β
β β’ DTOs β β β’ AIService β β β’ Qdrant Repo β
β β’ Validation β β β’ ParserService β β β’ SQLite Repo β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β AI Providers β
β β
β β’ OpenAI β
β β’ Anthropic β
β β’ Gemini β
β β’ CustomProvider β
ββββββββββββββββββββ
Key Components
- π DocumentService: Main orchestrator for document operations
- π€ AIService: Handles AI provider interactions and embeddings
- π DocumentParserService: Multi-format document parsing
- π Factories: Provider instantiation and configuration
- π Repositories: Storage abstraction layer
- π§ Extensions: Dependency injection configuration
π¨ API Examples
Document Management
# Upload document
curl -X POST "http://localhost:5000/api/documents/upload" \
-F "file=@research-paper.pdf"
# Get document
curl "http://localhost:5000/api/documents/{document-id}"
# Delete document
curl -X DELETE "http://localhost:5000/api/documents/{document-id}"
# List all documents
curl "http://localhost:5000/api/documents/search"
AI Question Answering
# Ask questions about your documents
curl -X POST "http://localhost:5000/api/search/search" \
-H "Content-Type: application/json" \
-d '{
"query": "What are the main risks mentioned in the financial report?",
"maxResults": 5
}'
Response Example:
{
"query": "What are the main risks mentioned in the financial report?",
"answer": "Based on the financial documents, the main risks identified include: 1) Market volatility affecting revenue projections, 2) Regulatory changes in the European market, 3) Currency exchange fluctuations, and 4) Supply chain disruptions. The report emphasizes that market volatility poses the highest risk with potential 15-20% impact on quarterly earnings...",
"sources": [
{
"documentId": "doc-456",
"fileName": "Q3-financial-report.pdf",
"chunkContent": "Market volatility remains our primary concern, with projected impact of 15-20% on quarterly earnings...",
"relevanceScore": 0.94
}
],
"processingTimeMs": 1180
}
π Performance & Scaling
Benchmarks
- Document Upload: ~500ms for 10MB PDF
- Semantic Search: ~200ms with 10K documents
- AI Response: ~2-5s depending on provider
- Memory Usage: ~50MB base + documents in memory
Scaling Tips
- Use Redis or Qdrant for production workloads
- Enable connection pooling for database connections
- Implement caching for frequently accessed documents
- Use background services for bulk document processing
π οΈ Development
Building from Source
git clone https://github.com/byerlikaya/SmartRAG.git
cd SmartRAG
dotnet restore
dotnet build
dotnet test
Running the Sample API
cd src/SmartRAG.API
dotnet run
Browse to https://localhost:5001/scalar/v1 for interactive API documentation.
π€ Contributing
We welcome contributions!
Development Setup
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
π Roadmap
Version 1.1.0
- Excel file support with EPPlus
- Batch document processing
- Advanced search filters
- Performance monitoring
Version 1.2.0
- Multi-modal document support (images, tables)
- Real-time collaboration features
- Advanced analytics dashboard
- GraphQL API support
π Resources
- π§ Contact & Support
- πΌ LinkedIn
- π GitHub Profile
- π¦ NuGet Packages
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Star History
Built with β€οΈ by BarΔ±Ε Yerlikaya
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- coverlet.collector (>= 6.0.0)
- DocumentFormat.OpenXml (>= 3.0.1)
- EPPlus (>= 7.0.5)
- itext7 (>= 8.0.2)
- Microsoft.Data.Sqlite (>= 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Qdrant.Client (>= 1.7.0)
- StackExchange.Redis (>= 2.7.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.0 | 288 | 11/13/2025 |
| 3.0.3 | 337 | 11/6/2025 |
| 3.0.2 | 307 | 10/23/2025 |
| 3.0.1 | 373 | 10/22/2025 |
| 3.0.0 | 364 | 10/22/2025 |
| 2.3.1 | 226 | 10/8/2025 |
| 2.3.0 | 349 | 9/16/2025 |
| 2.2.0 | 383 | 9/15/2025 |
| 2.1.0 | 153 | 9/5/2025 |
| 2.0.0 | 314 | 8/27/2025 |
| 1.1.0 | 171 | 8/22/2025 |
| 1.0.3 | 186 | 8/20/2025 |
| 1.0.2 | 190 | 8/19/2025 |
| 1.0.1 | 158 | 8/17/2025 |
| 1.0.0 | 118 | 8/15/2025 |
🚀 Initial Release: High-performance RAG implementation with multi-provider AI support, enterprise vector storage, and plug-and-play .NET integration