StackTrace.AI
1.0.6
dotnet add package StackTrace.AI --version 1.0.6
NuGet\Install-Package StackTrace.AI -Version 1.0.6
<PackageReference Include="StackTrace.AI" Version="1.0.6" />
<PackageVersion Include="StackTrace.AI" Version="1.0.6" />
<PackageReference Include="StackTrace.AI" />
paket add StackTrace.AI --version 1.0.6
#r "nuget: StackTrace.AI, 1.0.6"
#:package StackTrace.AI@1.0.6
#addin nuget:?package=StackTrace.AI&version=1.0.6
#tool nuget:?package=StackTrace.AI&version=1.0.6
StackTrace.AI
Intelligent error analysis for .NET applications
📋 What is StackTrace.AI?
StackTrace.AI automatically captures exceptions in your .NET application, analyzes them using AI (Groq/OpenAI/Gemini), and provides detailed explanations, causes, solutions, and best practices.
❓ Why StackTrace.AI?
Debugging exceptions can be time-consuming and frustrating.
StackTrace.AI automates error analysis using AI, helping developers:
- ⚡ Understand errors instantly
- ⏱️ Save debugging time
- 📚 Learn best practices from real-world scenarios
✨ Features
| Feature | Description |
|---|---|
| 🎯 Auto Capture | Middleware catches all unhandled exceptions automatically |
| 🤖 AI Analysis | Uses Groq, OpenAI, or Gemini to analyze errors |
| 🌐 Bilingual | Full support for Arabic (ar) and English (en) |
| 📊 Reports | Export to Excel and PDF with complete error analysis |
| 💾 Solution Tracking | Mark errors as solved, track recurrence |
| 🎨 Dashboard | Interactive dark mode HTML report |
🧠 How AI Analysis Works (Prompt Engineering)
StackTrace.AI uses carefully crafted prompts to ensure high-quality, consistent AI responses. Each error analysis follows a structured approach:
System Prompt (English)
You are a senior .NET and C# expert with 10 years of experience.
Analyze errors precisely and provide actionable solutions.
Important instructions:
1. Response must be ONLY JSON, no text before or after
2. Use clear, professional English
3. Provide detailed explanation of the problem and root cause
4. Possible causes must be accurate and specific
5. Solution steps must be sequential and applicable
6. Best practices tips should provide real value
System Prompt (Arabic)
أنت خبير متخصص في .NET و C# مع خبرة 10 سنوات.
تحليل الأخطاء بدقة وتقديم حلول عملية قابلة للتنفيذ فوراً.
تعليمات مهمة:
1. يجب أن يكون الرد JSON فقط بدون أي كلام قبله أو بعده
2. استخدم لغة عربية فصحى واضحة
3. قدم شرحاً مفصلاً للمشكلة وجذرها
4. الأسباب المحتملة يجب أن تكون دقيقة ومحددة
5. خطوات الحل يجب أن تكون متسلسلة وقابلة للتطبيق
6. نصائح أفضل الممارسات يجب أن تكون ذات قيمة حقيقية
AI Output Format
The AI always returns a consistent JSON structure:
{
"error_type": "NullReferenceException",
"explanation": "Detailed explanation of what caused the error...",
"possible_causes": ["Cause 1", "Cause 2"],
"solution_steps": ["Step 1", "Step 2"],
"best_practices": ["Tip 1", "Tip 2"]
}
Why This Matters
| Principle | How It's Applied |
|---|---|
| Role Definition | "Senior .NET expert with 10 years experience" ensures expert-level responses |
| Output Format | JSON-only responses enable reliable parsing and consistent display |
| Language Consistency | Separate Arabic and English prompts maintain quality in both languages |
| Structured Information | Fixed schema (causes, steps, practices) makes solutions easy to follow |
| Actionable Guidance | Emphasis on practical, implementable solutions |
| Context Awareness | Includes exception type, stack trace, project type, and affected code |
This prompt engineering approach ensures every error analysis is:
- ✅ Consistent — Same structure every time
- ✅ Actionable — Clear steps you can implement immediately
- ✅ Educational — Learn best practices with each error
- ✅ Bilingual — High quality in both Arabic and English
🚀 Quick Start
1. Install the Package
dotnet add package StackTrace.AI --version 1.0.6
2. Configure in Program.cs
using StackTraceAI.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add StackTrace.AI services
builder.Services.AddStackTraceAI(builder.Configuration);
var app = builder.Build();
// Enable static files for dashboard
app.UseStaticFiles();
// Use StackTrace.AI middleware
app.UseStackTraceAI();
app.Run();
3. Set API Key
Add your API key to appsettings.json:
{
"DefaultLanguage": "ar", // or "en"
"AI": {
"DefaultModel": "groq"
},
"Groq": {
"ApiKey": "your-groq-key-here"
}
}
4. Test
# Create a test error
curl -X GET https://localhost:5001/api/errors/test-error/null
# Open interactive dashboard
open https://localhost:5001/api/report/dashboard-url
5. Dashboard Access
After running the application, you can access the interactive dashboard in two ways:
1. Via API Endpoint (Recommended)
https://localhost:5001/api/report/dashboard-url
This returns a JSON response with the dashboard URL.
2. Via Static File
https://localhost:5001/StackTraceAI/StackTraceDashboard.html
Note: Replace localhost:5001 with your actual application URL (the port shown when you run dotnet run).
📚 API Endpoints
Errors
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/errors |
Get all captured errors |
| POST | /api/errors/explain |
Analyze a specific error |
| POST | /api/errors/solve/{id} |
Mark error as solved |
| GET | /api/errors/test-error/{type} |
Generate test error |
| GET | /api/errors/models |
List available AI models |
Report
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/report/dashboard-url |
Interactive dashboard |
| GET | /api/report/excel?filter=solved |
Export to Excel |
| GET | /api/report/pdf?filter=recurring |
Export to PDF |
Settings
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/settings |
View all settings |
| POST | /api/settings/language/{lang} |
Set language (ar/en) |
| POST | /api/settings/api-key/{provider} |
Set API key (groq/openai) |
| GET | /api/settings/api-keys-status |
Check API key status |
🤖 Supported AI Models
| Model | Cost | Speed | Arabic Support |
|---|---|---|---|
| Groq (LLaMA 3.3) | Free | ⚡ Very Fast | ✅ Excellent |
| OpenAI (GPT-3.5) | Paid | 🐢 Moderate | ✅ Excellent |
| Google Gemini | Free | ⚡ Fast | ✅ Good |
🔧 Troubleshooting
| Issue | Solution |
|---|---|
| API Key not working | Ensure the key is valid and has the correct permissions. |
| Database errors | Delete any existing *.db files (if using SQLite) and restart the application. |
| Hangfire jobs stuck | Visit /hangfire dashboard to check jobs and retry or delete failed jobs. |
| PDF generation fails | Ensure QuestPDF license is set and valid. |
StackTraceDashboard.html not accessible |
Make sure UseStaticFiles() is enabled in Program.cs and the file exists in wwwroot/StackTraceAI. |
| Middleware not applied | Ensure app.UseStackTraceAI(); is called after UseRouting() but before UseEndpoints(). |
| Services not registered | Make sure builder.Services.AddStackTraceAI(builder.Configuration); is present in Program.cs. |
| Semantic Kernel errors | Ensure correct version of Microsoft.SemanticKernel and connectors are installed. |
| UI not displaying correctly | Clear browser cache or check that static files are served from correct path (wwwroot/StackTraceAI). |
📄 License
MIT License
Made with curiosity and love — to help every .NET developer build better software ✨
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- ClosedXML (>= 0.105.0)
- Hangfire (>= 1.8.23)
- Hangfire.Storage.SQLite (>= 0.4.3)
- Microsoft.AspNetCore.Hosting.Abstractions (>= 2.3.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.2)
- Microsoft.SemanticKernel (>= 1.74.0)
- Microsoft.SemanticKernel.Connectors.Google (>= 1.74.0-alpha)
- QuestPDF (>= 2026.2.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.