An open API service indexing awesome lists of open source software.

https://github.com/quangxuan98765/data-processing-api

ASP.NET Core Web API for Excel Data Processing & Bulk Database Operations
https://github.com/quangxuan98765/data-processing-api

aspnet-core bulk-insert demo-project dotnet-core excel-processing power-automate sql-server web-api

Last synced: 26 days ago
JSON representation

ASP.NET Core Web API for Excel Data Processing & Bulk Database Operations

Awesome Lists containing this project

README

          

# ๐Ÿข DataProcessingAPI - Enterprise Business Management System

> **Enterprise .NET 8 Web API with JWT Authentication & Power Platform Integration**

## ๐Ÿš€ Overview

DataProcessingAPI is an enterprise-grade .NET 8 Web API built with Clean Architecture principles for comprehensive business data management. Features JWT authentication, reusable authentication library, and dual API architecture for enterprise scalability.

### โœจ Key Features

- ๐Ÿ” **JWT Authentication** - Secure token-based authentication with BCrypt password hashing
- ๐Ÿ“š **Reusable AuthLibrary** - Standalone authentication library for code reuse
- ๐Ÿ—๏ธ **Enterprise Architecture** - Separate Auth & Financial API documentation
- ๐Ÿ’ฐ **Financial Management** - Secure revenue and expense tracking with authorization
- ๐Ÿ”„ **CRUD Operations** - Complete data management with proper security
- ๐Ÿ“Š **Excel Integration** - Bulk import/export with Power Automate
- โœ… **Data Validation** - Multi-layer validation with business rules
- ๐Ÿ›ก๏ธ **Security** - JWT tokens, [Authorize] attributes, SQL injection protection
- ๐Ÿ”— **Power Platform** - Custom Connectors for Power Apps and Power Automate
- ๐Ÿ“ˆ **Scalable** - Modular design for easy domain extensions

## ๐Ÿ› ๏ธ Technology Stack

- **.NET 8** - Latest LTS framework
- **ASP.NET Core** - Web API with dual Swagger documentation
- **SQL Server** - Database with stored procedures
- **JWT Authentication** - Secure token-based auth with BCrypt
- **AuthLibrary** - Reusable authentication components
- **Clean Architecture** - Domain-driven design pattern
- **Dependency Injection** - Built-in .NET Core DI
- **Power Platform** - Custom Connectors for enterprise integration

## ๐Ÿ—๏ธ Project Structure

```
DataProcessingAPI/
โ”œโ”€โ”€ AuthLibrary/ # Reusable JWT + BCrypt authentication library
โ”‚ โ”œโ”€โ”€ Models/ # User, token models
โ”‚ โ”œโ”€โ”€ DTOs/ # Request/response DTOs
โ”‚ โ”œโ”€โ”€ Services/ # Auth, password, token services
โ”‚ โ”œโ”€โ”€ Interfaces/ # Service contracts
โ”‚ โ””โ”€โ”€ SQL/ # Database stored procedures
โ”œโ”€โ”€ DataAccess/ # Database service layer
โ”œโ”€โ”€ DataProcessingAPI/ # Main API project
โ”‚ โ”œโ”€โ”€ Controllers/
โ”‚ โ”‚ โ”œโ”€โ”€ Auth/ # Authentication endpoints
โ”‚ โ”‚ โ””โ”€โ”€ Financial/ # Financial management (protected)
โ”‚ โ”œโ”€โ”€ Application/ # Business logic
โ”‚ โ”œโ”€โ”€ Domain/ # Domain entities
โ”‚ โ””โ”€โ”€ Shared/ # Common utilities
โ””โ”€โ”€ publish/ # IIS deployment artifacts
```

## ๐ŸŽฏ API Architecture

### ๐Ÿ” Authentication API (Auth Group)
- **POST /api/auth/login** - User authentication with JWT token
- **POST /api/auth/register** - New user registration
- **POST /api/auth/logout** - Token revocation
- **POST /api/auth/change-password** - Secure password updates
- **GET /api/auth/profile** - Get user profile

### ๐Ÿ’ฐ Financial API (Financial Group) - ๐Ÿ”’ JWT Protected

#### Revenue Management
- **GET /api/revenue** - Get all revenue records
- **GET /api/revenue/{id}** - Get specific revenue by ID
- **POST /api/revenue** - Create new revenue record
- **PUT /api/revenue/{id}** - Update existing revenue
- **DELETE /api/revenue/{id}** - Delete revenue record
- **POST /api/revenue/bulk-import** - Excel bulk import with validation

#### Expense Management
- **GET /api/expense** - Get all expense records
- **GET /api/expense/{id}** - Get specific expense by ID
- **POST /api/expense** - Create new expense record
- **PUT /api/expense/{id}** - Update existing expense
- **DELETE /api/expense/{id}** - Delete expense record
- **POST /api/expense/bulk-import** - Excel bulk import with validation

### ๐Ÿš€ Future Extensions
- **HR Management** - Employee and payroll systems
- **Inventory** - Stock and product management
- **Accounting** - Ledger and financial reporting

## ๐Ÿš€ Quick Start

```bash
# Clone repository
git clone https://github.com/quangxuan98765/excel-data-processing-api

# Navigate to project
cd DataProcessingAPI

# Setup database (run SQL scripts)
# 1. Run AuthLibrary/SQL/AuthStoredProcedures.sql
# 2. Configure connection string in appsettings.json

# Configure JWT settings in appsettings.json
{
"JwtSettings": {
"SecretKey": "YourSecretKey32CharactersMinimum!",
"Issuer": "DataProcessingAPI",
"Audience": "DataProcessingAPI",
"ExpiryMinutes": 60
}
}

# Run the API
dotnet run
```

**Swagger Documentation**:
- **Auth API**: `https://localhost:7xxx/swagger-auth`
- **Financial API**: `https://localhost:7xxx/swagger-financial`

## ๐Ÿ” Authentication Flow

1. **Register/Login** โ†’ Get JWT token
2. **Include token** in Authorization header: `Bearer `
3. **Access protected endpoints** (Financial APIs require authentication)

```http
# Login
POST /api/auth/login
{ "username": "admin", "password": "Password123!" }

# Use token for protected endpoints
GET /api/expense
Authorization: Bearer
```

## ๐Ÿ“Š Enterprise DTOs & Clean Architecture

### Request/Response Pattern
```csharp
// API Request DTOs (Client โ†’ Server)
CreateRevenueRequest // POST /api/revenue
UpdateRevenueRequest // PUT /api/revenue/{id}
CreateExpenseRequest // POST /api/expense
UpdateExpenseRequest // PUT /api/expense/{id}

// API Response DTOs (Server โ†’ Client)
RevenueResponse // GET operations
ExpenseResponse // GET operations

// Import DTOs (Excel โ†’ API)
RevenueImportDto // Bulk import from Excel
ExpenseImportDto // Bulk import from Excel
```

### Benefits
- โœ… **Security**: Request DTOs prevent ID/timestamp manipulation
- โœ… **Validation**: Separate validation rules for create vs update
- โœ… **Documentation**: Clear API contracts in Swagger
- โœ… **Maintainability**: Easy to extend without breaking changes

## ๐Ÿ“Š API Endpoints

### Authentication Endpoints
```
POST /api/auth/login # User login with JWT token
POST /api/auth/register # New user registration
POST /api/auth/logout # Token revocation
POST /api/auth/change-password # Password updates
GET /api/auth/profile # Get user profile
```

### Financial Endpoints (๐Ÿ”’ JWT Required)
```
# Revenue Management
GET /api/revenue # Get all revenue records
GET /api/revenue/{id} # Get revenue by ID
POST /api/revenue # Create new revenue
PUT /api/revenue/{id} # Update revenue
DELETE /api/revenue/{id} # Delete revenue
POST /api/revenue/bulk-import # Excel bulk import

# Expense Management
GET /api/expense # Get all expense records
GET /api/expense/{id} # Get expense by ID
POST /api/expense # Create new expense
PUT /api/expense/{id} # Update expense
DELETE /api/expense/{id} # Delete expense
POST /api/expense/bulk-import # Excel bulk import
```

## ๐Ÿ”— Power Platform Integration

### Custom Connectors
- **Financial Data API Connector** - Complete CRUD operations with JWT authentication
- **Swagger-based Definition** - Auto-generated from API documentation
- **Request/Response DTOs** - Clean API contracts for Power Platform

### Power Apps Integration
- **JWT Authentication Flow** - Secure login with token management
- **Financial Data Management** - Full CRUD operations with proper authorization
- **Form Validation** - Client-side + server-side validation
- **Data Binding** - Clean Response DTOs for easy Power Apps binding

### Power Automate Flows
- **Excel Data Import** - Bulk processing with validation and error handling
- **Automated Workflows** - Scheduled data processing and reporting
- **Error Handling** - Comprehensive error logging and retry mechanisms

### Integration Benefits
- โœ… **Type Safety** - Strongly typed Request/Response DTOs
- โœ… **Error Handling** - Structured error responses
- โœ… **Security** - JWT authentication for all protected endpoints
- โœ… **Scalability** - Enterprise-grade API design patterns

## ๐Ÿ“„ License

MIT License - see [LICENSE](LICENSE) file for details.

## ๐Ÿ“ž Contact

**Developer**: Quang Xuรขn
**Email**: acongchuongheo@gmail.com
**GitHub**: [@quangxuan98765](https://github.com/quangxuan98765)

---

โญ **Professional .NET development with Clean Architecture principles**