A modern enterprise AI chat application with RAG (Retrieval-Augmented Generation) capabilities. Chat with an AI that understands your documents and databases.
- AI-Powered Chat - Interactive chat interface with streaming responses powered by OpenAI, Azure OpenAI, or Ollama
- RAG (Retrieval-Augmented Generation) - AI responses grounded in your documents and data
- File Uploads - Upload images, PDFs, Excel files, CSV, and documents directly in chat for AI analysis
- Multi-Provider LLM Support - Choose between OpenAI, Azure OpenAI, or Ollama for chat and embeddings
- SQL Data Sources - Connect to SQL Server databases and query tables/views as knowledge sources
- File System Indexing - Index documents from folders with pattern matching
- Vector Search - SQL Server 2025 native VECTOR type for semantic search
- User Management - Role-based access control with local or Windows authentication
- Data Source Permissions - Control who can access which data sources
- Personal Documents - Users can upload private documents only they can search
- Message Reactions - Thumbs up/down feedback on AI responses with optional comments
- AI Memory - Persistent memory that remembers user preferences and context across conversations
- Dark Mode - Full dark theme support with automatic persistence
- Configuration Status - Visual dashboard showing red/yellow/green status for all system components
- Analytics Dashboard - Usage metrics, daily activity charts, top users, and engagement statistics
- Audit Log Viewer - Searchable log of all system actions with filtering and export
- Cost Tracking - Monitor API token usage and costs with budget alerts
- Announcement Banner - Display system-wide announcements with scheduling and styling options
- Branding Configuration - Customize application name, colors, and logo
- User Management - Manage users, roles, and AD group mappings
- Data Source Management - Configure and monitor knowledge base sync status
- Authentication Configuration - Configure Local or Windows Authentication with domain restrictions
| Category | Technologies |
|---|---|
| Backend | .NET 8, ASP.NET Core, Entity Framework Core 8 |
| Frontend | Blazor Server, Microsoft Fluent UI |
| Database | SQL Server 2025 (native VECTOR support) |
| AI | OpenAI, Azure OpenAI, or Ollama (GPT-4o, GPT-4, Llama, etc.) |
| Architecture | Clean Architecture, CQRS with MediatR |
| Real-time | SignalR for streaming responses |
Before you begin, ensure you have the following installed:
- .NET 8 SDK
- SQL Server 2025 (required for native VECTOR type)
- One of the following AI providers:
- OpenAI API Key
- Azure OpenAI Service
- Ollama (for local/self-hosted models)
git clone https://github.com/Chrisrokc/DataChat.git
cd DataChatOption A: Environment Variable (Recommended for Production)
Set the connection string via environment variable to avoid storing credentials in config files:
# Linux/macOS
export ConnectionStrings__DefaultConnection="Server=YOUR_SERVER;Database=DataChat;User Id=sa;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
# Windows PowerShell
$env:ConnectionStrings__DefaultConnection="Server=YOUR_SERVER;Database=DataChat;User Id=sa;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
# Windows Command Prompt
set ConnectionStrings__DefaultConnection=Server=YOUR_SERVER;Database=DataChat;User Id=sa;Password=YOUR_PASSWORD;TrustServerCertificate=True;Option B: appsettings.json (Development Only)
For local development, you can edit src/Presentation/DataChat.Web/appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=DataChat;User Id=sa;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
}
}Security Note: Never commit credentials to source control. The default
appsettings.jsonships with an empty connection string to prevent accidental credential exposure.
For Windows Authentication:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=DataChat;Integrated Security=True;TrustServerCertificate=True;"
}
}cd src/Presentation/DataChat.Web
dotnet runThe application will start on http://localhost:5159.
On first run, DataChat automatically detects that setup is needed and redirects you to the Setup Wizard. The wizard guides you through three steps:
-
Database Connection
- Enter your SQL Server connection details (server, database, credentials)
- Click Test Connection to verify connectivity
- The database will be created automatically if it doesn't exist
- Click Save & Continue
-
Apply Migrations
- Review the pending database migrations
- Click Apply Migrations to create the database schema
- Progress is displayed in real-time
-
Create Admin Account
- Enter a username, display name, and password for the administrator account
- Click Create Admin & Finish
After setup completes, you'll be redirected to the login page.
After logging in as admin:
- Go to Admin > Configuration > AI Settings
- Select your LLM Provider (OpenAI, Azure OpenAI, or Ollama)
- Enter the required credentials for your provider
- Click Test & Save Settings to verify the configuration
The Status tab will show green indicators when everything is configured correctly.
To test the RAG functionality with sample data, you can create an example employee directory database.
Connect to your SQL Server and run:
-- Create a sample database for testing
CREATE DATABASE CompanyData;
GO
USE CompanyData;
GO
-- Create Departments table
CREATE TABLE Departments (
DepartmentId INT PRIMARY KEY IDENTITY(1,1),
DepartmentName NVARCHAR(100) NOT NULL,
Location NVARCHAR(100),
Budget DECIMAL(18,2)
);
-- Create Employees table
CREATE TABLE Employees (
EmployeeId INT PRIMARY KEY IDENTITY(1,1),
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
Email NVARCHAR(100),
JobTitle NVARCHAR(100),
DepartmentId INT FOREIGN KEY REFERENCES Departments(DepartmentId),
HireDate DATE,
Salary DECIMAL(18,2),
ManagerId INT NULL FOREIGN KEY REFERENCES Employees(EmployeeId)
);
-- Insert sample departments
INSERT INTO Departments (DepartmentName, Location, Budget) VALUES
('Engineering', 'Building A, Floor 3', 2500000.00),
('Marketing', 'Building B, Floor 1', 800000.00),
('Human Resources', 'Building A, Floor 1', 400000.00),
('Finance', 'Building C, Floor 2', 600000.00),
('Sales', 'Building B, Floor 2', 1200000.00),
('IT Support', 'Building A, Floor 2', 350000.00),
('Legal', 'Building C, Floor 3', 500000.00),
('Product', 'Building A, Floor 4', 900000.00);
-- Insert sample employees
INSERT INTO Employees (FirstName, LastName, Email, JobTitle, DepartmentId, HireDate, Salary, ManagerId) VALUES
-- Engineering
('Sarah', 'Chen', 'sarah.chen@company.com', 'VP of Engineering', 1, '2018-03-15', 185000.00, NULL),
('Michael', 'Johnson', 'michael.johnson@company.com', 'Senior Software Engineer', 1, '2019-06-01', 145000.00, 1),
('Emily', 'Williams', 'emily.williams@company.com', 'Software Engineer', 1, '2021-02-14', 115000.00, 2),
('David', 'Kim', 'david.kim@company.com', 'Software Engineer', 1, '2022-08-22', 105000.00, 2),
('Jessica', 'Martinez', 'jessica.martinez@company.com', 'Junior Developer', 1, '2023-11-01', 75000.00, 2),
-- Marketing
('Robert', 'Brown', 'robert.brown@company.com', 'Marketing Director', 2, '2017-09-10', 155000.00, NULL),
('Amanda', 'Davis', 'amanda.davis@company.com', 'Marketing Manager', 2, '2020-01-20', 95000.00, 6),
('Christopher', 'Wilson', 'chris.wilson@company.com', 'Content Specialist', 2, '2022-04-15', 65000.00, 7),
-- Human Resources
('Jennifer', 'Taylor', 'jennifer.taylor@company.com', 'HR Director', 3, '2016-11-08', 135000.00, NULL),
('Daniel', 'Anderson', 'daniel.anderson@company.com', 'HR Specialist', 3, '2021-07-12', 72000.00, 9),
-- Finance
('Michelle', 'Thomas', 'michelle.thomas@company.com', 'CFO', 4, '2015-05-20', 210000.00, NULL),
('Kevin', 'Garcia', 'kevin.garcia@company.com', 'Financial Analyst', 4, '2020-09-14', 85000.00, 11),
-- Sales
('Brian', 'Rodriguez', 'brian.rodriguez@company.com', 'Sales Director', 5, '2018-02-28', 160000.00, NULL),
('Stephanie', 'Lee', 'stephanie.lee@company.com', 'Account Executive', 5, '2021-05-03', 78000.00, 13),
('Jason', 'White', 'jason.white@company.com', 'Account Executive', 5, '2022-01-17', 75000.00, 13),
-- IT Support
('Nicole', 'Harris', 'nicole.harris@company.com', 'IT Manager', 6, '2019-04-22', 110000.00, NULL),
('Ryan', 'Clark', 'ryan.clark@company.com', 'IT Support Specialist', 6, '2022-06-30', 62000.00, 16),
-- Legal
('Patricia', 'Lewis', 'patricia.lewis@company.com', 'General Counsel', 7, '2017-08-14', 195000.00, NULL),
-- Product
('Andrew', 'Walker', 'andrew.walker@company.com', 'Product Manager', 8, '2020-03-09', 130000.00, NULL),
('Rachel', 'Hall', 'rachel.hall@company.com', 'UX Designer', 8, '2021-10-25', 95000.00, 19);
GO
-- Create a view for the Employee Directory (this is what DataChat will index)
CREATE VIEW vw_EmployeeDirectory AS
SELECT
e.EmployeeId,
e.FirstName + ' ' + e.LastName AS FullName,
e.Email,
e.JobTitle,
d.DepartmentName,
d.Location AS DepartmentLocation,
e.HireDate,
e.Salary,
CASE
WHEN m.EmployeeId IS NOT NULL
THEN m.FirstName + ' ' + m.LastName
ELSE 'N/A'
END AS ManagerName
FROM Employees e
JOIN Departments d ON e.DepartmentId = d.DepartmentId
LEFT JOIN Employees m ON e.ManagerId = m.EmployeeId;
GO- Log in as admin
- Go to Admin > Data Sources
- Click Manage Connections
- Click Add Connection
- Fill in:
- Name:
Company Database - Server: Your SQL Server address
- Database:
CompanyData - Authentication: SQL Server or Windows Auth
- If SQL Auth, enter username/password
- Name:
- Click Test Connection to verify
- Click Save
- Go to Admin > Data Sources
- Click Add Data Source
- Select SQL View
- Fill in:
- Name:
Employee Directory - Description:
Company employee information including names, titles, and departments - Connection: Select
Company Database - View/Table Name:
vw_EmployeeDirectory
- Name:
- Click Create
- Click Sync Now to index the data
Go to the chat and try these questions:
- "Who works in the Engineering department?"
- "What is Sarah Chen's job title?"
- "List all employees hired in 2022"
- "Who is the highest paid employee?"
- "Which department has the largest budget?"
- "Who reports to Robert Brown?"
- "How many employees are in Sales?"
All configuration is managed through the Admin > Configuration panel, which provides a visual status dashboard and organized tabs for each configuration area.
The Status tab provides at-a-glance health indicators:
- 🟢 Green - Configured and working
- 🟡 Yellow - Configured with warnings
- đź”´ Red - Not configured or error
Components monitored:
- SQL Server Connection
- Chat Model
- Embedding Model
- RAG Settings
- Authentication
Configure your LLM provider for chat and embeddings.
| Setting | Description | Default |
|---|---|---|
| API Key | Your OpenAI API key | Required |
| Chat Model | GPT model for chat | gpt-4o |
| Embedding Model | Model for vector embeddings | text-embedding-ada-002 |
| Temperature | Response creativity (0-1) | 0.7 |
| Max Tokens | Maximum response length | 4096 |
| Setting | Description | Example |
|---|---|---|
| Endpoint | Azure OpenAI endpoint URL | https://myinstance.openai.azure.com |
| API Key | Azure OpenAI API key | Required |
| Chat Deployment | Deployment name for chat model | gpt-4o-deployment |
| Embedding Deployment | Deployment name for embeddings | text-embedding-deployment |
| API Version | Azure OpenAI API version | 2024-02-15-preview |
| Setting | Description | Default |
|---|---|---|
| Endpoint | Ollama server URL | http://localhost:11434 |
| Chat Model | Model name for chat | llama3.2 |
| Embedding Model | Model name for embeddings | nomic-embed-text |
Click Test & Save Settings to validate your configuration before saving.
Configure a SQL Server 2025 connection for queryable views as knowledge sources.
| Setting | Description |
|---|---|
| Host | SQL Server hostname or IP |
| Port | SQL Server port (default: 1433) |
| Database | Database name |
| Username/Password | SQL Server authentication |
| Use Integrated Security | Use Windows Authentication |
| Trust Server Certificate | Skip certificate validation |
Configure Retrieval-Augmented Generation behavior.
| Setting | Description | Default |
|---|---|---|
| Enable Source Preview | Allow users to see document chunks used in responses | Enabled |
| Enable Document Preview | Allow in-browser document viewing | Enabled |
| Enable Document Download | Allow document downloads | Enabled |
| Token Expiration | Document access token validity (minutes) | 10 |
| Min Relevance | Minimum relevance % to show sources (0 = show all) | 0 |
| Max Sources | Maximum sources to display per response | 5 |
Configure user authentication mode.
- Username/password stored in database
- Passwords encrypted with ASP.NET Core Data Protection
- Session-based with configurable expiration
| Setting | Description | Default |
|---|---|---|
| Auto-provision users | Create user accounts on first Windows login | Enabled |
| Default Role | Role for auto-provisioned users | User |
| Allowed Domains | Restrict to specific AD domains (semicolon-separated) | All domains |
Note: Windows Authentication settings require an application restart to take effect.
AD Group Permissions: Map Active Directory groups to application roles or data source permissions via the User Management page.
Base configuration file (authentication mode is now managed via Admin panel):
{
"ConnectionStrings": {
"DefaultConnection": "Server=...;Database=DataChat;..."
},
"Logging": {
"LogLevel": {
"Default": "Information"
}
}
}DataChat/
├── src/
│ ├── Core/
│ │ ├── DataChat.Domain/ # Entities, enums, value objects
│ │ └── DataChat.Application/ # CQRS commands/queries, interfaces
│ ├── Infrastructure/
│ │ └── DataChat.Infrastructure/ # EF Core, OpenAI, vector store
│ └── Presentation/
│ └── DataChat.Web/ # Blazor UI, API endpoints
├── docs/
│ └── images/ # Screenshots and documentation images
├── scripts/
│ └── create_test_data.sql # Sample data script
└── README.md
- Images: PNG, JPG, GIF, WebP (sent to vision API)
- PDFs: Rendered as images for AI analysis
- Spreadsheets: Excel (XLSX, XLS), CSV (parsed and converted to text)
- Text: TXT, MD, JSON (extracted as text)
- Documents: PDF, DOCX, DOC, TXT, MD
- Spreadsheets: Excel (XLSX, XLS), CSV
- Images: PNG, JPG, JPEG (for personal documents)
- Data: SQL Server tables and views
Authentication is configured via Admin > Configuration > Authentication.
- Username/password stored in database
- Passwords encrypted with ASP.NET Core Data Protection
- Session-based with 7-day sliding expiration
To enable Windows Authentication:
- Go to Admin > Configuration > Authentication
- Select Windows Authentication from the dropdown
- Configure options:
- Auto-provision users: Automatically create accounts for Windows users on first login
- Default Role: Role assigned to auto-provisioned users (User or Admin)
- Allowed Domains: Restrict login to specific AD domains (e.g.,
CORP;PARTNERS)
- Click Save Authentication Settings
- Restart the application for changes to take effect
Enter allowed domains separated by semicolons. Leave blank to allow all domains.
Example: CORP;MYDOMAIN;PARTNERS
Users from domains not in the list will see an "Access Denied" page.
Map Active Directory groups to application roles or data source permissions:
- Go to Admin > User Management
- Use the AD Group mappings section to configure permissions
dotnet run --project src/Presentation/DataChat.Webdotnet publish -c Release -o ./publish
cd publish
dotnet DataChat.Web.dllYou can override settings with environment variables:
export ConnectionStrings__DefaultConnection="Server=...;Database=...;"DataChat includes Docker support for containerized deployments.
The easiest way to run DataChat with Docker is using docker-compose.yml, which sets up both the application and SQL Server:
# Start DataChat and SQL Server
docker-compose up -d
# View logs
docker-compose logs -f datachatThe application will be available at http://localhost:8080. On first run, the Setup Wizard will guide you through configuration.
The default docker-compose.yml includes:
- DataChat on port 8080
- SQL Server 2022 on port 1433
To use an external SQL Server instead, set the connection string environment variable:
services:
datachat:
environment:
- ConnectionStrings__DefaultConnection=Server=your-server;Database=DataChat;User Id=sa;Password=YourPassword;TrustServerCertificate=True;# Build the image
docker build -t datachat:latest .
# Run standalone (requires external SQL Server)
docker run -d -p 8080:8080 \
-e ConnectionStrings__DefaultConnection="Server=host.docker.internal;Database=DataChat;User Id=sa;Password=YourPassword;TrustServerCertificate=True;" \
datachat:latest| Variable | Description | Default |
|---|---|---|
ConnectionStrings__DefaultConnection |
SQL Server connection string | (empty - triggers Setup Wizard) |
ASPNETCORE_ENVIRONMENT |
Runtime environment | Production |
Setup__Enabled |
Enable Setup Wizard | true |
The container includes a health check endpoint at /health:
curl http://localhost:8080/healthDataChat can be hosted on IIS (Internet Information Services) for production deployments on Windows Server.
- Windows Server with IIS installed
- .NET 8 Hosting Bundle - Download and install from Microsoft .NET Downloads
- SQL Server 2025 accessible from the IIS server
- Download the .NET 8.0 Hosting Bundle (not just the runtime)
- Run the installer on your Windows Server
- Restart IIS after installation:
net stop was /y net start w3svc
On your development machine, publish the application:
dotnet publish src/Presentation/DataChat.Web/DataChat.Web.csproj -c Release -o ./publishCopy the contents of the ./publish folder to your IIS server (e.g., C:\inetpub\wwwroot\DataChat).
- Open IIS Manager
- Right-click Sites > Add Website
- Configure:
- Site name:
DataChat - Physical path:
C:\inetpub\wwwroot\DataChat - Binding: Choose your IP, port (e.g., 80 or 443), and hostname
- Site name:
- Click OK
- In IIS Manager, go to Application Pools
- Find the pool created for DataChat (or create a new one)
- Right-click > Basic Settings:
- .NET CLR Version:
No Managed Code - Managed pipeline mode:
Integrated
- .NET CLR Version:
- Right-click > Advanced Settings:
- Start Mode:
AlwaysRunning(recommended for Blazor Server) - Idle Time-out (minutes):
0(prevents app pool recycling)
- Start Mode:
The publish process creates a web.config file. Verify it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet"
arguments=".\DataChat.Web.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>Create appsettings.Production.json in the publish folder:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SQL_SERVER;Database=DataChat;User Id=datachat_user;Password=YOUR_PASSWORD;TrustServerCertificate=True;"
},
"Serilog": {
"MinimumLevel": {
"Default": "Warning"
}
}
}The IIS application pool identity needs permissions:
- Right-click the DataChat folder > Properties > Security
- Click Edit > Add
- Enter:
IIS AppPool\DataChat(replace "DataChat" with your app pool name) - Grant Read & Execute permissions
- For the
logsfolder (if using stdout logging), grant Write permissions
- Obtain an SSL certificate (Let's Encrypt, commercial CA, or self-signed for testing)
- In IIS Manager, select your site > Bindings
- Add an HTTPS binding (port 443) and select your certificate
- Optionally, add URL Rewrite rules to redirect HTTP to HTTPS
Blazor Server requires WebSockets:
- In Server Manager > Add Roles and Features
- Navigate to Web Server (IIS) > Web Server > Application Development
- Check WebSocket Protocol
- Complete the installation
Or via PowerShell:
Install-WindowsFeature Web-WebSocketsIf using Windows Authentication:
- In IIS Manager, select your site
- Double-click Authentication
- Enable Windows Authentication
- Disable Anonymous Authentication (or keep both enabled for mixed mode)
- In the DataChat admin panel:
- Go to Admin > Configuration > Authentication
- Select Windows Authentication
- Configure auto-provisioning and allowed domains
- Save and restart the application
- Ensure the .NET Hosting Bundle is installed
- Check that the
web.configis valid XML
- Enable stdout logging in
web.config(stdoutLogEnabled="true") - Check
.\logs\stdout*.logfor errors - Verify the connection string is correct
- Ensure SQL Server is accessible from the IIS server
- Check if the Application Pool is running
- Verify the app pool identity has folder permissions
- Ensure WebSockets are enabled in IIS
- Check that no proxy/load balancer is blocking WebSocket connections
- Verify the app pool idle timeout is set to 0
Enable stdout logging temporarily:
<aspNetCore ... stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">Create the logs folder and grant write permissions to the app pool identity.
| Endpoint | Method | Description |
|---|---|---|
/api/login |
POST | Authenticate user |
/logout |
GET | Sign out |
/health |
GET | Health check endpoint |
/setup |
GET | Setup wizard (only available during initial setup) |
- Complete the Setup Wizard on first run to configure your database and create an admin account
- Use HTTPS in production
- Secure your OpenAI API key - it's encrypted in the database
- Regular backups - chat history and documents are stored in the database
- Review data source permissions - control who can access sensitive data
- Verify SQL Server 2025 is installed (required for VECTOR type)
- Check connection string in appsettings.json
- Ensure SQL Server allows TCP/IP connections
- Test with SQL Server Management Studio first
- Verify API key is valid and has credits
- Check model availability in your OpenAI account
- Review logs for rate limiting errors
- Ensure SQL Server 2025 with native VECTOR support
- Check that data sources are synced (green status)
- Verify embedding model is configured
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for the GPT and embedding models
- Microsoft Fluent UI for the component library
- MediatR for the CQRS implementation
