Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

🚀 Process Analyzer API

.NET C# License

AI-powered business process analysis REST API | Analyze business processes and get intelligent recommendations for automation and optimization using Claude AI.

📋 Table of Contents

🎯 Overview

The Process Analyzer API is a production-ready .NET 8 REST API that leverages AI (Claude) to analyze business processes. Users submit process descriptions, and the API returns:

  • Bottlenecks: Identified pain points and inefficiencies
  • Suggestions: Practical automation solutions
  • Priority Score: Urgency rating (1-10)

This project demonstrates enterprise-level .NET development practices including:

  • Clean Architecture & SOLID principles
  • JWT Authentication & Security
  • Comprehensive Testing
  • Docker Containerization
  • CI/CD Pipeline
  • Structured Logging
  • API Documentation

✨ Features

Core Functionality

  • ✅ AI-powered process analysis using Claude API
  • ✅ RESTful API with OpenAPI/Swagger documentation
  • ✅ SQLite database with Entity Framework Core
  • ✅ Data persistence and retrieval

Security & Quality

  • ✅ JWT Bearer Authentication
  • ✅ Rate Limiting (60 requests/minute)
  • ✅ CORS Configuration
  • ✅ Global Exception Handling
  • ✅ Input Validation (FluentValidation)
  • ✅ Structured Logging (Serilog)

Advanced Features

  • ✅ Pagination & Filtering
  • ✅ Sorting (by priority, date, ID)
  • ✅ Health Check Endpoints
  • ✅ Comprehensive Error Responses

DevOps

  • ✅ Docker Support
  • ✅ Docker Compose for local development
  • ✅ GitHub Actions CI/CD Pipeline
  • ✅ Environment-based Configuration

🛠 Tech Stack

Category Technology
Framework .NET 8.0
Language C# 12
Web Framework ASP.NET Core Web API
ORM Entity Framework Core 8.0
Database SQLite
Authentication JWT Bearer Tokens
Validation FluentValidation
Logging Serilog
Testing xUnit, Moq, ASP.NET Core Testing
Documentation Swagger/OpenAPI
Containerization Docker

🏗 Architecture

High-Level Architecture

┌─────────────┐
│   Client    │
│  (Browser/  │
│   Mobile)   │
└──────┬──────┘
       │ HTTP/REST
       ▼
┌─────────────────────────────────┐
│      ASP.NET Core API           │
│  ┌──────────────────────────┐  │
│  │   Controllers Layer       │  │
│  │  - AnalysisController     │  │
│  │  - AuthController         │  │
│  └───────────┬───────────────┘  │
│              │                   │
│  ┌───────────▼───────────────┐  │
│  │   Services Layer          │  │
│  │  - AnalysisService        │  │
│  │  - LlmService             │  │
│  │  - AuthService            │  │
│  └───────────┬───────────────┘  │
│              │                   │
│  ┌───────────▼───────────────┐  │
│  │   Data Layer             │  │
│  │  - AppDbContext           │  │
│  │  - ProcessAnalysis Entity │  │
│  └───────────┬───────────────┘  │
└──────────────┼───────────────────┘
               │
       ┌───────▼────────┐
       │   SQLite DB    │
       └────────────────┘
               │
       ┌───────▼────────┐
       │  Claude API    │
       │  (External)    │
       └────────────────┘

Request Flow

  1. Client sends HTTP request to API endpoint
  2. Middleware processes request (authentication, rate limiting, CORS)
  3. Controller receives request and validates input
  4. Service handles business logic
  5. LLM Service calls Claude API for analysis
  6. Database persists analysis results
  7. Response returned to client with analysis data

Design Patterns

  • Repository Pattern: Data access abstraction via DbContext
  • Dependency Injection: All services registered in Program.cs
  • Middleware Pattern: Global exception handling, rate limiting
  • DTO Pattern: Separation of API contracts from domain models
  • Strategy Pattern: LLM service abstraction for different providers

🚀 Getting Started

Prerequisites

Local Development

1. Clone the Repository

git clone https://github.com/aymandakir/process-analyzer-api.git
cd process-analyzer-api/ProcessAnalyzerApi

2. Configure API Key

Edit appsettings.Development.json:

{
  "LlmSettings": {
    "ApiKey": "your-claude-api-key-here"
  }
}

3. Run Database Migrations

dotnet ef database update

4. Run the Application

dotnet run

The API will be available at:

  • HTTP: http://localhost:5043
  • HTTPS: https://localhost:7052
  • Swagger UI: http://localhost:5043 (root)

Docker Development

Using Docker Compose

docker-compose up -d

The API will be available at http://localhost:8080

Using Docker

docker build -t process-analyzer-api .
docker run -p 8080:8080 \
  -e LlmSettings__ApiKey=your-api-key \
  process-analyzer-api

📚 API Documentation

Authentication

Login

POST /api/auth/login
Content-Type: application/json

{
  "username": "admin",
  "password": "admin123"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresAt": "2024-12-22T12:00:00Z"
}

Process Analysis

Analyze Process

POST /api/analysis/analyze
Authorization: Bearer {token}
Content-Type: application/json

{
  "processDescription": "Our employee onboarding process involves HR manually creating accounts in 8 different systems..."
}

Response:

{
  "id": 1,
  "inputDescription": "Our employee onboarding process...",
  "bottlenecks": "Manual account creation across multiple systems creates delays...",
  "suggestions": "Implement SSO solution, use automation tools like Zapier...",
  "priorityScore": 9,
  "createdAt": "2024-12-20T12:00:00Z"
}

Get All Analyses (Paginated)

GET /api/analysis/analyses?page=1&pageSize=10&minPriority=5&sortBy=priority&sortDescending=true

Query Parameters:

  • page (int): Page number (default: 1)
  • pageSize (int): Items per page (default: 10, max: 100)
  • minPriority (int?): Minimum priority filter
  • maxPriority (int?): Maximum priority filter
  • fromDate (DateTime?): Filter from date
  • toDate (DateTime?): Filter to date
  • sortBy (string): Sort field (id, priority, date)
  • sortDescending (bool): Sort direction

Response:

{
  "items": [...],
  "page": 1,
  "pageSize": 10,
  "totalCount": 25,
  "totalPages": 3,
  "hasPreviousPage": false,
  "hasNextPage": true
}

Get Analysis by ID

GET /api/analysis/analyses/{id}

Health Check

GET /health

🧪 Testing

Run All Tests

dotnet test

Run with Coverage

dotnet test /p:CollectCoverage=true

Test Structure

Tests/
├── AnalysisServiceTests.cs    # Unit tests for AnalysisService
└── (More tests can be added)

🐳 Deployment

Environment Variables

Variable Description Required
LlmSettings__ApiKey Claude API key Yes
JwtSettings__SecretKey JWT signing key (min 32 chars) Yes
ConnectionStrings__DefaultConnection Database connection string Yes
ASPNETCORE_ENVIRONMENT Environment (Development/Production) No

Railway Deployment

  1. Connect GitHub repository to Railway
  2. Set environment variables
  3. Deploy automatically on push to main

Render Deployment

  1. Create new Web Service
  2. Connect GitHub repository
  3. Set build command: dotnet publish -c Release -o ./publish
  4. Set start command: dotnet ./publish/ProcessAnalyzerApi.dll
  5. Configure environment variables

📁 Project Structure

ProcessAnalyzerApi/
├── Controllers/          # API endpoints
│   ├── AnalysisController.cs
│   └── AuthController.cs
├── Services/            # Business logic
│   ├── IAnalysisService.cs
│   ├── AnalysisService.cs
│   ├── ILlmService.cs
│   ├── LlmService.cs
│   ├── IAuthService.cs
│   └── AuthService.cs
├── Models/              # Domain entities
│   └── ProcessAnalysis.cs
├── DTOs/                # Data transfer objects
│   ├── AnalyzeRequestDto.cs
│   ├── AnalysisResponseDto.cs
│   ├── LoginRequestDto.cs
│   ├── LoginResponseDto.cs
│   ├── LlmResponseDto.cs
│   └── PagedResultDto.cs
├── Data/                # Data access
│   └── AppDbContext.cs
├── Middleware/          # Custom middleware
│   └── GlobalExceptionHandlerMiddleware.cs
├── Validators/          # FluentValidation rules
│   └── AnalyzeRequestDtoValidator.cs
├── Migrations/          # EF Core migrations
├── Tests/               # Unit & integration tests
│   └── AnalysisServiceTests.cs
├── Program.cs           # Application entry point
├── appsettings.json     # Configuration
├── Dockerfile           # Docker configuration
├── docker-compose.yml   # Docker Compose config
└── README.md            # This file

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments


Built with ❤️ using .NET 8

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages