https://github.com/nithinmohantk/genai-boilerplate-dotnet
.NET version of GenAI boilerplate with ASP.NET Core Web API backend, React frontend, multi-tenant architecture, JWT authentication, PostgreSQL/Redis integration, and AI chat capabilities using OpenAI API
https://github.com/nithinmohantk/genai-boilerplate-dotnet
boilerplate boilerplate-application boilerplate-front-end dotnet genai-chatbot llm multi-model reactjs
Last synced: 2 months ago
JSON representation
.NET version of GenAI boilerplate with ASP.NET Core Web API backend, React frontend, multi-tenant architecture, JWT authentication, PostgreSQL/Redis integration, and AI chat capabilities using OpenAI API
- Host: GitHub
- URL: https://github.com/nithinmohantk/genai-boilerplate-dotnet
- Owner: nithinmohantk
- License: mit
- Created: 2025-08-12T10:39:59.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-12T11:37:48.000Z (2 months ago)
- Last Synced: 2025-08-12T12:38:19.968Z (2 months ago)
- Topics: boilerplate, boilerplate-application, boilerplate-front-end, dotnet, genai-chatbot, llm, multi-model, reactjs
- Language: C#
- Homepage:
- Size: 200 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π€ GenAI Chatbot Boilerplate (.NET)
A production-ready, multi-tenant GenAI chatbot platform built with **ASP.NET Core**, **React**, and **PostgreSQL**. Features real-time chat, document processing, RAG capabilities, and comprehensive admin management.
## β¨ Key Features
### π― **Core Functionality**
- **Real-time WebSocket Chat** with typing indicators and message broadcasting
- **Multi-tenant Architecture** with complete tenant isolation
- **Document Upload & RAG** with automatic text extraction and chunking
- **AI Model Integration** supporting OpenAI, Anthropic, Google, and custom models
- **Chat History Persistence** with full message search and session management### π **Authentication & Security**
- **JWT Authentication** with refresh token rotation
- **OAuth Support** framework (Google, Microsoft, Apple ready)
- **Role-Based Access Control** (Super Admin, Tenant Admin, User, Viewer)
- **Multi-factor Security** with BCrypt password hashing
- **API Key Management** for tenant-specific AI provider keys### π **Admin Center**
- **Tenant Management** - Create, configure, and monitor tenants
- **User Management** - Role assignment, activation/deactivation
- **System Statistics** - Usage metrics and analytics
- **API Key Configuration** - Secure AI provider key management
- **Real-time Monitoring** - Connection stats and system health### ποΈ **Technical Excellence**
- **Clean Architecture** - Domain-driven design with proper layer separation
- **Entity Framework Core** - Code-first approach with PostgreSQL
- **Type Safety** - Full C# type safety and validation
- **Dependency Injection** - Built-in ASP.NET Core DI container
- **Health Checks & Metrics** - Kubernetes-ready with health endpoints## π Quick Start
### Prerequisites
- **.NET 9.0+** and **Node.js 18+**
- **PostgreSQL 13+** and **Redis 6+**
- **Git** for cloning### 1. Clone & Setup
```bash
git clone https://github.com/nithinmohantk/genai-boilerplate-dotnet.git
cd genai-boilerplate-dotnet
```### 2. Backend Setup
```bash
# Navigate to backend
cd backend# Restore packages
dotnet restore# Update database connection string in appsettings.json
# Then run the application
dotnet run --project GenAIBoilerplate.API
```
π **Backend running at https://localhost:5001**### 3. Frontend Setup
```bash
# In a new terminal, navigate to frontend
cd frontend
npm install
npm start
```
π **Frontend running at http://localhost:3000**### 4. Database Setup
The application will automatically create the database on first run. For production, use Entity Framework migrations:```bash
# Add migration
dotnet ef migrations add InitialCreate --project GenAIBoilerplate.Infrastructure --startup-project GenAIBoilerplate.API# Update database
dotnet ef database update --project GenAIBoilerplate.Infrastructure --startup-project GenAIBoilerplate.API
```## π API Documentation
### Authentication Endpoints
```bash
POST /api/v1/auth/login # User login
POST /api/v1/auth/register # User registration
POST /api/v1/auth/refresh # Token refresh
GET /api/v1/auth/me # Current user info
PUT /api/v1/auth/me # Update profile
POST /api/v1/auth/logout # User logout
```### Chat Endpoints
```bash
POST /api/v1/chat/sessions # Create chat session
GET /api/v1/chat/sessions # List user sessions
GET /api/v1/chat/sessions/{id} # Get session with messages
POST /api/v1/chat/completions # Generate AI response
GET /api/v1/chat/models # Available AI models
GET /api/v1/chat/search # Search sessions
```### Document Endpoints
```bash
POST /api/v1/documents/upload # Upload document
GET /api/v1/documents/ # List documents
POST /api/v1/documents/{id}/process # Process for RAG
GET /api/v1/documents/{id}/chunks # View document chunks
```### Admin Endpoints
```bash
GET /api/v1/admin/tenants # Manage tenants (Super Admin)
GET /api/v1/admin/users # Manage users (Tenant Admin)
GET /api/v1/admin/api-keys # Manage API keys
GET /api/v1/admin/system/stats # System statistics
```### Health Check Endpoints
```bash
GET /health # Application health
GET /api/v1/health/live # Liveness probe
GET /api/v1/health/ready # Readiness probe
```## ποΈ Architecture Overview
```
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React SPA β β ASP.NET Core β β PostgreSQL β
β β β Web API β β β
β β’ Chat UI βββββΊβ β’ REST API βββββΊβ β’ Multi-tenant β
β β’ Admin Panel β β β’ SignalR Hub β β β’ Chat History β
β β’ Auth Flow β β β’ Auth & RBAC β β β’ Documents β
βββββββββββββββββββ β β’ Document RAG β β β’ Users/Tenants β
β β’ AI Integrationβ βββββββββββββββββββ
βββββββββββββββββββ β
β β
βββββββββββββββββββ βββββββββββββββββββ
β Redis β β AI Providers β
β β β β
β β’ Sessions β β β’ OpenAI β
β β’ Cache β β β’ Anthropic β
β β’ SignalR β β β’ Google β
βββββββββββββββββββ β β’ Custom APIs β
βββββββββββββββββββ
```## π οΈ Project Structure
```
genai-boilerplate-dotnet/
βββ backend/
β βββ GenAIBoilerplate.API/ # Web API project
β β βββ Controllers/ # API controllers
β β βββ Program.cs # Application entry point
β β βββ appsettings.json # Configuration
β βββ GenAIBoilerplate.Core/ # Domain layer
β β βββ Entities/ # Domain entities
β β βββ Enums/ # Domain enums
β β βββ Interfaces/ # Repository interfaces
β β βββ Common/ # Base classes
β βββ GenAIBoilerplate.Application/ # Application layer
β β βββ Services/ # Application services
β β βββ DTOs/ # Data transfer objects
β β βββ Mappings/ # Object mappings
β βββ GenAIBoilerplate.Infrastructure/ # Infrastructure layer
β βββ Persistence/ # Database context & repositories
β βββ Services/ # External service implementations
β βββ Migrations/ # EF Core migrations
βββ frontend/ # React frontend (same as Python version)
β βββ src/
β β βββ components/
β β βββ pages/
β β βββ contexts/
β βββ package.json
βββ data/ # Data directories
β βββ documents/
β βββ embeddings/
β βββ uploads/
βββ GenAIBoilerplate.sln # Solution file
```## π§ Configuration
### Environment Variables
```bash
# Database
ConnectionStrings__DefaultConnection="Host=localhost;Database=genai_chatbot;Username=genai_user;Password=genai_password"# JWT
JwtSettings__SecretKey="your-super-secret-key-here-change-in-production"
JwtSettings__Issuer="GenAIBoilerplateAPI"
JwtSettings__Audience="GenAIBoilerplateClient"# Redis
RedisSettings__ConnectionString="localhost:6379"# AI Providers
AIProviders__OpenAI__ApiKey="sk-your-openai-key"
AIProviders__Anthropic__ApiKey="claude-your-key"
```### Multi-Model Configuration
Each tenant can configure their own AI provider keys through the admin panel with support for the latest AI models:#### **OpenAI Models**
- **GPT-4 Series**: GPT-4, GPT-4 Turbo, GPT-4o, GPT-4o Mini, GPT-4.1, GPT-4.1 Mini, GPT-4.1 Nano
- **GPT-3.5 Series**: GPT-3.5 Turbo, GPT-3.5 Turbo 16K
- **GPT-5 Series**: GPT-5, GPT-5.0 Mini, GPT-5.0 Nano β¨ **Latest Release**#### **Anthropic Models**
- **Claude 3 Series**: Claude 3 Haiku, Claude 3 Sonnet, Claude 3 Opus
- **Claude 3.5 Series**: Claude 3.5 Sonnet, Claude 3.5 Haiku
- **Claude 4.0 Series**: Claude 4.0 Opus, Claude 4.0 Sonnet β¨ **Latest Release**## π User Roles & Permissions
### Role Hierarchy
```
Super Admin π Full system access, manage all tenants
β
Tenant Admin π Manage tenant users, settings, API keys
β
Tenant User π€ Chat, upload documents, personal settings
β
Tenant Viewer ποΈ Read-only access to tenant resources
```## π³ Docker Deployment
### Quick Docker Setup
```bash
# Build and run with docker-compose
docker-compose up --build# Or run individual services
docker build -t genai-backend ./backend
docker build -t genai-frontend ./frontenddocker run -p 5000:8080 genai-backend
docker run -p 3000:3000 genai-frontend
```## π§ͺ Testing
### Backend Tests
```bash
cd backend# Run tests
dotnet test# Run with coverage
dotnet test --collect:"XPlat Code Coverage"
```### Frontend Tests
```bash
cd frontend# Run component tests
npm test# Run E2E tests
npm run test:e2e
```## π Monitoring & Observability
### Health Checks
- `GET /health` - Application health
- `GET /api/v1/health/live` - Liveness probe
- `GET /api/v1/health/ready` - Readiness probe### Swagger Documentation
- Development: `https://localhost:5001/swagger`
- Comprehensive API documentation with authentication support## π¨ Security Features
### Authentication Security
- **JWT with configurable algorithms** (HS256, RS256)
- **Refresh Token Rotation** - Automatic token renewal
- **Session Management** - Device tracking and revocation
- **Rate Limiting** - Built-in ASP.NET Core rate limiting### Data Protection
- **Tenant Isolation** - Complete data separation with EF Core
- **Encrypted Storage** - Passwords with BCrypt
- **Input Validation** - Model validation and sanitization
- **HTTPS Enforcement** - Production security headers## π€ Contributing
### Development Setup
```bash
# Backend development
cd backend
dotnet restore
dotnet build# Frontend development
cd frontend
npm install
npm run dev
```### Code Standards
- **C#**: .NET coding standards, nullable reference types
- **JavaScript**: Prettier, ESLint, TypeScript
- **Commits**: Conventional commits format
- **Testing**: Unit + integration test coverage## π Support & Documentation
- **π Issues**: [GitHub Issues](https://github.com/nithinmohantk/genai-boilerplate-dotnet/issues)
- **π¬ Discussions**: [GitHub Discussions](https://github.com/nithinmohantk/genai-boilerplate-dotnet/discussions)
- **π Wiki**: [Project Wiki](https://github.com/nithinmohantk/genai-boilerplate-dotnet/wiki)
- **π Releases**: [Release Notes](https://github.com/nithinmohantk/genai-boilerplate-dotnet/releases)## π License
This project is licensed under the **MIT License** - see [LICENSE](LICENSE) file for details.
---
## π― What's Next?
This boilerplate provides a solid foundation for building production GenAI applications with .NET. Here are some potential enhancements:
### Immediate Extensions
- **SignalR Integration** for real-time chat
- **Vector Database Integration** (Pinecone, Weaviate, Chroma)
- **Advanced RAG** with semantic chunking and reranking
- **Background Jobs** with Hangfire or Quartz.NET### Advanced Features
- **Multi-language Support** with localization
- **Custom Model Fine-tuning** workflows
- **Analytics Dashboard** with usage insights
- **gRPC Services** for high-performance APIs### Enterprise Features
- **Azure AD / Identity Server** integration
- **Audit Logging** with compliance reports
- **Multi-database Support** (SQL Server, MySQL)
- **Microservices Architecture** with service mesh---
**π Ready to build the next generation of AI-powered applications with .NET!**
*Built with β€οΈ by [Nithin Mohan](https://github.com/nithinmohantk)*