{"id":31017214,"url":"https://github.com/donpotts/localsqlragclientserver","last_synced_at":"2026-05-01T21:35:01.546Z","repository":{"id":313983849,"uuid":"1053695195","full_name":"donpotts/LocalSqlRagClientServer","owner":"donpotts","description":"Simple sample using Ollama RAG with Sqlite database and Blazor WASM UI","archived":false,"fork":false,"pushed_at":"2025-09-09T19:55:42.000Z","size":860,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-09T23:29:36.814Z","etag":null,"topics":["blazor-webassembly","dotnet","rag-chatbot","semantic-kernel","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/donpotts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-09T19:49:38.000Z","updated_at":"2025-09-09T19:59:31.000Z","dependencies_parsed_at":"2025-09-09T23:29:39.099Z","dependency_job_id":"e6672225-ec63-485e-8c88-690af1e04098","html_url":"https://github.com/donpotts/LocalSqlRagClientServer","commit_stats":null,"previous_names":["donpotts/localsqlragclientserver"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/donpotts/LocalSqlRagClientServer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donpotts%2FLocalSqlRagClientServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donpotts%2FLocalSqlRagClientServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donpotts%2FLocalSqlRagClientServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donpotts%2FLocalSqlRagClientServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donpotts","download_url":"https://codeload.github.com/donpotts/LocalSqlRagClientServer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donpotts%2FLocalSqlRagClientServer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32513898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor-webassembly","dotnet","rag-chatbot","semantic-kernel","sqlite"],"created_at":"2025-09-13T07:52:51.325Z","updated_at":"2026-05-01T21:35:01.519Z","avatar_url":"https://github.com/donpotts.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LocalSQL RAG Client-Server 🚀\n\n\u003e **A Modern Natural Language to SQL Interface with AI Integration**\n\n[![.NET](https://img.shields.io/badge/.NET-9.0-512BD4?style=flat-square\u0026logo=dotnet)](https://dotnet.microsoft.com/)\n[![Blazor](https://img.shields.io/badge/Blazor-WebAssembly-512BD4?style=flat-square\u0026logo=blazor)](https://blazor.net/)\n[![SQLite](https://img.shields.io/badge/SQLite-003B57?style=flat-square\u0026logo=sqlite)](https://sqlite.org/)\n\nA sophisticated client-server application that transforms natural language queries into SQL using local AI models. Built with .NET 9, Blazor WebAssembly, and integrated with Ollama for privacy-focused AI processing.\n\n## 🌟 Features\n\n### 🤖 AI-Powered SQL Generation\n- **Natural Language Processing**: Convert English questions to SQL queries\n- **Local AI Models**: Uses Ollama (Phi3) for complete privacy\n- **Smart Query Optimization**: Context-aware SQL generation with few-shot learning\n- **Multi-layered Security**: SQL injection protection and query validation\n\n### 🔐 Enterprise-Grade Security\n- **JWT Authentication**: Stateless, secure token-based authentication\n- **Role-Based Access**: Admin/User roles with granular permissions\n- **Query Restrictions**: Read-only mode for regular users\n- **Input Sanitization**: Comprehensive SQL and input validation\n\n### 💼 Professional UI/UX\n- **Modern Blazor Interface**: Responsive, component-based architecture\n- **Real-time Chat**: Interactive query interface with typing indicators\n- **Admin Dashboard**: User management and system administration\n- **Professional Design**: Bootstrap 5 with custom styling\n\n### 📊 Data Management\n- **Employee Database**: Complete CRUD operations with smart defaults\n- **Database Schema**: Optimized SQLite with proper constraints\n- **Data Validation**: Comprehensive validation at model and database levels\n- **Query History**: Track and manage query interactions\n\n## 🏗️ Architecture\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    Client (Blazor WASM)                     │\n├─────────────────────────────────────────────────────────────┤\n│  • Authentication Service     • Admin Service              │\n│  • Chat Interface            • Employee Management         │\n│  • Bootstrap UI              • Local Storage               │\n└─────────────────────┬───────────────────────────────────────┘\n                      │ HTTPS/JWT\n┌─────────────────────▼───────────────────────────────────────┐\n│                 Server (ASP.NET Core)                      │\n├─────────────────────────────────────────────────────────────┤\n│  • JWT Authentication        • SQL Query Validation        │\n│  • Text-to-SQL Service       • Database Service            │\n│  • Semantic Kernel           • Admin Controller            │\n└─────────────────────┬───────────────────────────────────────┘\n                      │\n            ┌─────────▼────────┐    ┌─────────────────────┐\n            │   SQLite DBs     │    │   Ollama (Phi3)     │\n            │                  │    │                     │\n            │ • app.db         │    │ • Local AI Model    │\n            │ • company.db     │    │ • Privacy-focused   │\n            └──────────────────┘    └─────────────────────┘\n```\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)\n- [Ollama](https://ollama.com/) with Phi3 model\n- Modern web browser with WebAssembly support\n\n### Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/yourusername/LocalSQLRAGClientServer.git\n   cd LocalSQLRAGClientServer\n   ```\n\n2. **Install Ollama and Phi3 model**\n   ```bash\n   # Install Ollama from https://ollama.com/\n   ollama pull phi3:3.8b\n   ollama serve\n   ```\n\n3. **Configure environment variables** (Production)\n   ```bash\n   # Set a secure JWT secret (32+ characters)\n   export JWT_SECRET_KEY=\"your-super-secure-jwt-secret-key-here-32-chars-minimum\"\n   ```\n\n4. **Run the application**\n   ```bash\n   # Start the server (Terminal 1)\n   cd LocalTextToSqlChat.Server\n   dotnet run\n\n   # Start the client (Terminal 2)\n   cd LocalTextToSqlChat.Client\n   dotnet run\n   ```\n\n5. **Access the application**\n   - Client: `https://localhost:7115`\n   - Server API: `https://localhost:7267`\n   - Health Check: `https://localhost:7267/health`\n\n## 💻 Usage\n\n### Getting Started\n\n1. **Create an account** - First user automatically becomes admin\n2. **Start chatting** - Ask natural language questions about employees\n3. **Explore examples** - Click suggested prompts to see capabilities\n\n### Example Queries\n\n```sql\n-- Natural Language → Generated SQL\n\"Show me all employees\"\n→ SELECT * FROM Employees\n\n\"Who earns more than 80000?\"\n→ SELECT Name, Department, Salary FROM Employees WHERE Salary \u003e 80000\n\n\"List employees by department\"\n→ SELECT Name, Department, Salary FROM Employees ORDER BY Department, Name\n\n\"Add new employee John Smith to Engineering\"\n→ INSERT INTO Employees (Name, Department) VALUES ('John Smith', 'Engineering')\n```\n\n### Admin Features\n\n- **User Management**: Create, update, delete users\n- **Role Assignment**: Promote users to admin\n- **Employee CRUD**: Full employee management via API\n- **System Monitoring**: Health checks and diagnostics\n\n## 🔧 Configuration\n\n### Environment Variables\n\n| Variable | Description | Default | Required |\n|----------|-------------|---------|----------|\n| `JWT_SECRET_KEY` | JWT signing key (32+ chars) | - | Yes (Production) |\n| `ASPNETCORE_ENVIRONMENT` | Environment name | Development | No |\n\n### Configuration Files\n\n**appsettings.json**\n```json\n{\n  \"Jwt\": {\n    \"SecretKey\": \"\",  // Leave empty for production\n    \"Issuer\": \"LocalTextToSqlChat\",\n    \"Audience\": \"LocalTextToSqlChat.Client\"\n  },\n  \"OllamaSettings\": {\n    \"BaseUrl\": \"http://localhost:11434\",\n    \"ModelId\": \"phi3:3.8b\"\n  }\n}\n```\n\n## 🛡️ Security Features\n\n### Multi-Layer Protection\n- **SQL Injection Prevention**: Parameterized queries + validation\n- **Query Intent Analysis**: Prevents unauthorized write operations\n- **JWT Security**: Environment-based secrets + proper validation\n- **CORS Protection**: Environment-specific allowed origins\n- **Security Headers**: XSS, CSRF, content-type protection\n\n### Best Practices Implemented\n- ✅ Secure password hashing (BCrypt)\n- ✅ Token expiration and validation\n- ✅ Role-based authorization\n- ✅ Input sanitization and validation\n- ✅ Environment-based configuration\n- ✅ Health monitoring endpoints\n\n## 🧪 Testing\n\n### API Testing\n```bash\n# Health check\ncurl https://localhost:7267/health\n\n# Authentication\ncurl -X POST https://localhost:7267/api/auth/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"username\":\"test\",\"email\":\"test@example.com\",\"password\":\"Test123!\"}'\n```\n\n### Database Testing\nThe application includes comprehensive employee management with smart defaults:\n- **HireDate**: Automatically set to current date\n- **Department**: Defaults to \"Unknown\" if not specified\n- **Salary**: Defaults to 0 if not provided\n\n## 🏗️ Development\n\n### Project Structure\n```\nLocalSQLRAGClientServer/\n├── LocalTextToSqlChat.Client/     # Blazor WebAssembly\n│   ├── Pages/                     # Razor pages\n│   ├── Services/                  # Client services\n│   └── Models/                    # Client models\n├── LocalTextToSqlChat.Server/     # ASP.NET Core API\n│   ├── Controllers/               # API controllers\n│   ├── Services/                  # Business logic\n│   ├── Data/                      # Database layer\n│   └── Models/                    # Data models\n└── README.md\n```\n\n### Key Technologies\n- **Frontend**: Blazor WebAssembly, Bootstrap 5, SignalR-ready\n- **Backend**: ASP.NET Core 9, Entity Framework alternative\n- **Database**: SQLite with migration support\n- **AI/ML**: Semantic Kernel, Ollama integration\n- **Authentication**: JWT Bearer tokens\n- **Security**: BCrypt, CORS, Security Headers\n\n## 🚀 Deployment\n\n### Production Checklist\n\n- [ ] Set `JWT_SECRET_KEY` environment variable\n- [ ] Configure production database connection\n- [ ] Set up HTTPS certificates\n- [ ] Configure CORS for production domains\n- [ ] Enable application logging\n- [ ] Set up monitoring and health checks\n- [ ] Review and test security configurations\n\n### Docker Support (Coming Soon)\n```dockerfile\n# Dockerfile example (future enhancement)\nFROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base\n# ... Docker configuration\n```\n\n### Development Guidelines\n- Follow C# coding standards\n- Add unit tests for new features\n- Update documentation\n- Ensure security best practices\n\n## 🙏 Acknowledgments\n\n- **Ollama Team** - Local AI model hosting\n- **Microsoft** - Semantic Kernel framework\n- **Blazor Community** - WebAssembly innovations\n- **.NET Foundation** - Outstanding development platform\n\n---\n\n**Built with ❤️ using .NET 9 and Blazor WebAssembly**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonpotts%2Flocalsqlragclientserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonpotts%2Flocalsqlragclientserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonpotts%2Flocalsqlragclientserver/lists"}