Skip to content

afonsoft/EAF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enterprise Application Foundation (EAF)

GitHub GitHub version Commits History

English | Português

Line Coverage Branch Coverage Method Coverage Test Success Rate Total Tests Passing Tests API Template Tests API Template Passing

Table of Contents

About the Project

What is EAF?

The EAF (Enterprise Application Foundation) is an open-source middleware platform that provides a solid foundation for developing modern applications. Based on ASP.NET Boilerplate (ABP), EAF has been optimized to work with the latest versions of ASP.NET Core and Entity Framework Core.

Key Benefits

  • Integrated Security: Authentication and authorization with support for Azure Active Directory and LDAP
  • Complete Auditing: Automatic tracking of all system operations
  • Multi-tenancy: Native support for multi-tenant applications
  • Observability: Integration with OpenTelemetry for monitoring and telemetry
  • Distributed Cache: Support for Redis, SQL Server, and SQLite
  • Secret Management: Integration with Azure Key Vault and Oracle Cloud Infrastructure
  • Advanced Logging: Replacement of log4net with Serilog for better performance

Use Cases

  • Web Applications: Management systems, CRMs, ERPs, and other applications
  • RESTful APIs: Development of scalable APIs
  • Microservices: Foundation for microservice architectures
  • Multi-tenant Applications: SaaS and shared applications

ASP.NET Boilerplate

What is ASP.NET Boilerplate?

ASP.NET Boilerplate (ABP) is an open-source web application framework that provides a robust infrastructure for developing modern applications. Complete documentation available at: https://aspnetboilerplate.com/Pages/Documents

EAF: Enhanced Open Source Implementation

The EAF (Enterprise Application Foundation) is an open-source implementation based on ASP.NET Boilerplate, designed to offer a more user-friendly interface for API and UI development. EAF complements the base framework with various improvements and additional modules:

Modules and Improvements

Authentication and Authorization

  • External Login: Support for social login (Google, Facebook, Twitter, Microsoft)
  • Azure Active Directory: Complete integration
  • LDAP/Active Directory: Authentication via directories
  • Two-Factor Authentication: Two-factor authentication
  • Permission Management: Granular permission and role system

Auditing and Logging

  • Automatic Auditing: Tracking of all CRUD operations
  • Structured Logging: Integration with Serilog for detailed logs
  • Entity Change Tracking: Monitoring of entity changes
  • Error Logging: Capture and analysis of exceptions

Real-time Communication

  • Chat System: Chat system between users
  • SignalR Integration: WebSockets for bidirectional communication
  • Push Notifications: Real-time notification system
  • Tenant-to-Host Chat: Chat between tenants and host
  • Group Chat: Group chat for collaboration

Multi-Tenancy

  • Data Isolation: Complete data separation by tenant
  • Tenant Management: Tenant management
  • Tenant Resolution: Automatic tenant resolution
  • Feature Management: Enable/disable features by tenant

Cache and Performance

  • Distributed Cache: Support for Redis, SQL Server, SQLite
  • Cache Abstraction: Unified interface for different backends
  • Cache Manager: Intelligent cache management
  • Performance Optimization: Integrated performance optimizations

Background Jobs

  • Hangfire Integration: Background task processing
  • Job Management: Job scheduling and monitoring
  • Recurring Jobs: Automated recurring tasks
  • Worker Services: Scalable background services

UI and Frontend

  • Angular Integration: Complete Angular template
  • UI Components: Reusable and styled components
  • Client-Side Validation: Automatic frontend validation
  • Internationalization: Support for multiple languages

Configuration and Settings

  • Setting Management: Configuration management
  • Feature Flags: Feature flags
  • Environment Configuration: Configuration by environment
  • Key Vault Integration: Secret security

Other Features

  • Event Bus: Domain event system
  • Data Filters: Automatic data filters (SoftDelete, TenantId)
  • Repository Pattern: Data access abstraction
  • Unit of Work: Transaction management
  • Dependency Injection: Configured dependency injection
  • Object Mapping: Integrated AutoMapper
  • API Documentation: Automatic Swagger/OpenAPI

Benefits of EAF over Pure ABP

  1. More User-Friendly Interface: Simplified and intuitive APIs
  2. Ready-to-Use Modules: Pre-configured components for immediate use
  3. Best Practices: Applied modern development patterns
  4. Optimized Performance: Integrated performance optimizations
  5. Portuguese Documentation: Native support for Portuguese language
  6. BDD Tests: Tests with Given/When/Then pattern
  7. Observability: OpenTelemetry for advanced monitoring
  8. Enhanced Security: Multiple authentication and authorization options

Technical Overview

Architecture

EAF follows Domain-Driven Design (DDD) principles and implements patterns such as:

  • Repository Pattern: Data layer abstraction
  • Unit of Work: Transaction management
  • Dependency Injection: Inversion of control
  • CQRS: Separation of commands and queries
  • Event Sourcing: Domain event tracking

Supported Technologies

Technology Version Status
ASP.NET Core 10.0 Supported
Entity Framework Core 10.0 Supported
Angular 18 Supported
.NET 10.0 Supported

Main Components

Middleware Core

  • Eaf.Middleware.Core: Central domain layer with entities, services, configurations, authorization, auditing, and base framework features.
  • Eaf.Middleware.Application: Application layer with DTOs, application services, validations, and intermediate business logic.
  • Eaf.Middleware.Web.Core: Web components for ASP.NET Core including startup configuration, middleware, filters, and HTTP integration.

Authentication and Authorization

  • Eaf.Middleware.AzureActiveDirectory: Complete integration with Azure Active Directory for external authentication and user synchronization.
  • Eaf.Middleware.Ldap: LDAP/Active Directory authentication for integration with existing directories.

Cache and Persistence

  • Eaf.SqlServerCache: Distributed cache implementation using SQL Server as backend for high availability scenarios.
  • Eaf.SqliteCache: Local cache implementation using SQLite for development and low-scale scenarios.

Security

  • Eaf.KeyVault: Secret management supporting Azure Key Vault and Oracle Cloud Infrastructure (OCI) for secure credential storage.
  • Eaf.KeyVault.AspNetCore: ASP.NET Core integration for automatic loading of configurations and secrets from Key Vault.

Observability

  • Eaf.OpenTelemetry: Complete OpenTelemetry implementation for distributed telemetry, tracing, and metrics with support for multiple exporters.
  • Eaf.Castle.Serilog: Logging adapter integrating Castle Windsor with Serilog for structured and configurable logging.

Processing

  • Eaf.Middleware.Worker: Background services (Worker Services) for asynchronous processing, scheduled jobs, and long-running tasks.
  • Eaf.Log4NetServiceBus: Integration with Azure Service Bus using log4net for message logging and messaging events.

Tech Stack

Backend (.NET)

  • .NET 10.0: Main framework
  • ASP.NET Core 10.0: Web API and MVC
  • Entity Framework Core 10.0: ORM for data access
  • AutoMapper: Object mapping
  • Castle Windsor: Dependency injection
  • Hangfire: Background task processing
  • SignalR: Real-time communication
  • Swagger/OpenAPI: API documentation
  • xUnit: Testing framework
  • Shouldly: Fluent assertions
  • NSubstitute: Mocking framework

Frontend (Template)

  • Angular 18: SPA framework
  • Node.js 20.20.0: JavaScript runtime
  • TypeScript 5.2: Main language
  • Bootstrap 5: CSS framework
  • PrimeNG 17: UI components
  • Chart.js: Charts and visualizations
  • RxJS 7: Reactive programming

Infrastructure

  • SQLite: Local database
  • SQL Server: Main database
  • Redis: Distributed cache
  • Azure Key Vault: Secret management
  • OpenTelemetry: Observability
  • Serilog: Structured logging

Documentation

The detailed technical documentation of the EAF system, covering architecture, modules, development guides, and more, can be found in our documentation portal.

Access Complete Documentation


Installation and Configuration

Prerequisites

Required:

  • .NET 10.0 SDK or higher
  • Node.js 20.20.0 (for frontend development)
  • Git

For Frontend Development:

npm install -g @angular/cli@19

For Coverage Reports:

dotnet tool install -g dotnet-reportgenerator-globaltool

Platform Compatibility

Platform Status Notes
Windows Full Support Use PowerShell or Command Prompt
Linux Full Support Bash scripts provided
macOS Full Support Use Terminal with bash

Cloning the Repository

git clone https://github.com/afonsoft/EAF.git
cd EAF

Environment Setup

  1. Restore dependencies:
dotnet restore Eaf.sln
  1. Build the project:
dotnet build Eaf.sln

Running and Testing

Quick Start

Linux/macOS:

# Make the script executable
chmod +x build-and-test.sh

# Run build and tests with coverage
./build-and-test.sh

Windows (PowerShell):

# Run build and tests
dotnet build Eaf.sln
dotnet test Eaf.sln --collect:"XPlat Code Coverage" --settings coverlet.runsettings

# Generate coverage report (if reportgenerator is installed)
reportgenerator -reports:"TestResults/*/coverage.cobertura.xml" -targetdir:"TestResults/CoverageReport" -reporttypes:"Html;TextSummary"

Running Only Tests

Linux/macOS:

# Make the script executable
chmod +x run-tests-with-coverage.sh

# Run all tests with coverage
./run-tests-with-coverage.sh

Windows (PowerShell):

# Run all tests with coverage
dotnet test Eaf.sln --collect:"XPlat Code Coverage" --settings coverlet.runsettings

# Generate coverage report
reportgenerator -reports:"TestResults/*/coverage.cobertura.xml" -targetdir:"TestResults/CoverageReport" -reporttypes:"Html;TextSummary"

Manual Test Execution

# Run a specific test project with coverage
dotnet test test/Eaf.KeyVault.Tests/Eaf.KeyVault.Tests.csproj --collect:"XPlat Code Coverage" --settings coverlet.runsettings

# Run all tests in the solution
dotnet test Eaf.sln --collect:"XPlat Code Coverage" --settings coverlet.runsettings

# Generate coverage report
reportgenerator -reports:"TestResults/*/coverage.cobertura.xml" -targetdir:"TestResults/CoverageReport" -reporttypes:"Html;Badges;TextSummary"

Usage Example

Let's examine a simple class to see the benefits of EAF:

public class TaskAppService : ApplicationService, ITaskAppService
{
    private readonly IRepository<Task> _taskRepository;

    public TaskAppService(IRepository<Task> taskRepository)
    {
        _taskRepository = taskRepository;
    }

    [AbpAuthorize(MyPermissions.UpdateTasks)]
    public async Task UpdateTask(UpdateTaskInput input)
    {
        Logger.Info("Updating a task for input: " + input);

        var task = await _taskRepository.FirstOrDefaultAsync(input.TaskId);
        if (task == null)
        {
            throw new UserFriendlyException(L("CouldNotFindTheTaskMessage"));
        }

        ObjectMapper.MapTo(input, task);
    }
}

This example demonstrates several EAF features:

  • Dependency Injection: EAF uses and provides a conventional DI infrastructure
  • Repository: EAF can create a default repository for each entity
  • Authorization: EAF can check permissions declaratively
  • Validation: EAF automatically checks if input is null
  • Audit Logging: Information is automatically saved for each request
  • Unit of Work: Each application service method is a unit of work by default

Code Coverage

Test Status (Updated)

Module Line Coverage Branch Coverage New Tests Status
Eaf.SqlServerCache 86.6% 81.8% +2 Good coverage
Eaf.SqliteCache 75.5% 34.9% +4 Good coverage
Eaf.OpenTelemetry 70.1% 75.0% +2 Good coverage
Eaf.Middleware.Worker 24.6% N/A +4 Needs +65.4%
Eaf.Middleware.Ldap 5.1% N/A +4 Needs +84.9%
Eaf.Middleware.AzureActiveDirectory N/A N/A +4 Tests added
Eaf.Middleware.Web.Core 0.63% 0.16% +10 Needs +89.4%
Eaf.Middleware.Core 15.31% 5.59% +7 Needs +74.7%
Eaf.Middleware.Application 4.45% 1.35% +15 Needs +85.6%
Eaf.KeyVault 66.0% 51.6% +3 Tests added
TOTAL 28.4% 21.3% +47 In progress

Coverage Goal

  • Target: 90% code coverage
  • Current: 24.1% line, 15.5% branch, 54.5% method
  • Test Status (May 2026): 1492 total, 1491 passing, 1 ignored, 0 failures (100% success)
  • Next steps: Implement tests for modules with low coverage

Implemented Improvements

  • KeyVault: 206+ BDD tests implemented (99.5% success, 66% coverage)
  • XML Documentation: Portuguese summaries added
  • BDD Pattern: Given/When/Then implemented
  • Castle.Serilog: 44 BDD tests implemented (100% success, 90% coverage)
  • OpenTelemetry: 45/45 tests passing (100% success)
  • SqlServerCache: 38/38 tests passing (100% success)
  • Worker: 63/63 tests passing (100% success)
  • Test Expansion (April 2026): +65 new test files implemented
    • Eaf.Middleware.Web.Core: +10 tests (Swagger filters, TokenAuth, Impersonation models)
    • Eaf.MiddlewareCore: +30 tests (Entities, DTOs, Extensions, Cache items)
    • Eaf.Middleware.Application: +9 tests (constants, helpers, authorization)
    • Eaf.Middleware.Ldap: +4 tests (configuration, authentication)
    • Eaf.Middleware.AzureActiveDirectory: +4 tests (configuration, authentication)
    • Eaf.Middleware.Worker: +4 tests (folders, emailing, base classes)
    • Eaf.KeyVault: +3 tests (managers, interfaces)
    • Eaf.Castle.Serilog: +4 tests (module, factory, logger)
    • Eaf.KeyVault.AspNetCore: +1 test (extensions)
    • Eaf.Log4NetServiceBus: +3 tests (logging components)
    • Eaf.OpenTelemetry: +2 tests (module, extensions)
    • Eaf.SqlServerCache: +2 tests (helpers, extensions)
    • Eaf.SqliteCache: +4 tests (pool, commands, options)

Technical Fixes Implemented

SqliteCache - Static Initialization Fix

  • Problem: IndexOutOfRangeException during DbCommandPool initialization
  • Cause: Incorrect order of static property initialization
  • Solution: Moved Count before Commands to ensure correct initialization
  • Result: +21 tests passing (from 53 to 74), 39% improvement

Castle.Serilog - Complete Resolution

  • Problem: Conflicts between Castle.Core.Logging.ILogger and Serilog.ILogger
  • Solution: Alias SerilogILogger to resolve namespace ambiguity
  • Problematic Mocks: Replaced with actual Serilog instances
  • Invalid Tests: Removed tests that depended on unsupported runtime configuration
  • Result: 44/44 tests passing with BDD pattern in Portuguese

XML Documentation Status

  • Documented Files: 6/507 (1.2%)
  • Main Documented Classes:
    • SerilogLoggerFactory - Serilog logger factory
    • SerilogLogger - Logger implementation
    • EafSqliteCache - SQLite-based cache
    • MiddlewareAppServiceBase - Base class for services
    • AzureActiveDirectoryAuthenticationSource - Azure AD authentication
  • Next Modules: Entity Framework, Web API, Authorization

Coverage by Assembly (Updated)

Assembly Line Coverage Branch Coverage Method Coverage
Eaf.KeyVault 66.0% (200/303) 51.6% (33/64) 70.2% (40/57)
Eaf.SqlServerCache 78.3% (123/157) 81.8% (18/22) 71.4% (15/21)
Eaf.OpenTelemetry 68.9% (164/238) 75.0% (60/80) 95.2% (20/21)
Eaf.Log4NetServiceBus 85.0% (97/114) 62.5% (10/16) 87.1% (27/31)
Eaf.SqliteCache 45.0% (175/389) 34.9% (30/86) 58.5% (24/41)
Eaf.Castle.Serilog 10.0% (29/289) 3.6% (3/84) 16.9% (10/59)
Eaf.KeyVault.AspNetCore 85.7% (18/21) 100.0% (4/4) 50.0% (1/2)
Eaf.Middleware.Web.Core 0.63% (1/159) 0.16% (1/625) 1.35% (1/74)
Eaf.Middleware.Core 15.31% (24/157) 5.59% (5/90) 16.9% (10/59)
Eaf.Middleware.Application 4.45% (7/157) 1.35% (1/74) 5.59% (5/90)

Test Project Status

Project Status Tests Line Coverage Notes
Eaf.KeyVault.Tests Passing 210 67.9% Excellent coverage
Eaf.SqlServerCache.Tests Passing 57 86.6% Excellent coverage
Eaf.OpenTelemetry.Tests Passing 10 68.9% Good coverage
Eaf.KeyVault.AspNetCore.Tests Passing 8 85.7% Excellent coverage
Eaf.Log4NetServiceBus.Tests Passing 12 85.0% Good coverage
Eaf.SqliteCache.Tests Passing 94 75.6% Good coverage
Eaf.Castle.Serilog.Tests Passing 44 10.0% Resolved with BDD in Portuguese
Eaf.Middleware.Web.Core.Tests Passing 78 0.63% EXPANDED: +35 tests (Swagger, TokenAuth, Impersonation)
Eaf.Middleware.Application.Tests Passing 58 4.45% Basic coverage
Eaf.Middleware.Worker.Tests Passing 70 25.97% Moderate coverage
Eaf.MiddlewareCore.Tests Passing 632 15.31% EXPANDED: +30 tests (Entities, DTOs, Extensions)

Legend:

  • Passing: All tests pass successfully
  • Problems: Tests run but have failures or warnings
  • Build Errors: Project fails to compile

BDD Test Pattern

Tests follow the BDD (Behavior-Driven Development) pattern in Portuguese:

[Fact]
public void Dado_ParametroValido_Quando_ChamarMetodo_Entao_DeveRetornarSucesso()
{
    // Dado (Given)
    var parametro = "valor_valido";
    
    // Quando (When)
    var resultado = _service.ProcessarParametro(parametro);
    
    // Então (Then)
    resultado.ShouldNotBeNull();
    resultado.Sucesso.ShouldBeTrue();
}

NuGet Packages

Package NuGet Description
Eaf.Middleware.Application NuGet version Application layer
Eaf.Middleware.AzureActiveDirectory NuGet version Azure AD integration
Eaf.Middleware.Core NuGet version Core features
Eaf.Middleware.Ldap NuGet version LDAP authentication
Eaf.Middleware.Web.Core NuGet version Web components
Eaf.Castle.Serilog NuGet version Structured logging
Eaf.KeyVault NuGet version Secret management
Eaf.KeyVault.AspNetCore NuGet version ASP.NET Core integration
Eaf.OpenTelemetry NuGet version Telemetry and observability
Eaf.Log4NetServiceBus NuGet version Service bus logging
Eaf.SqlServerCache NuGet version SQL Server cache
Eaf.SqliteCache NuGet version SQLite cache
Eaf.Middleware.Worker NuGet version Background services

Contributing

How to Contribute

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

Development Standards

  • Tests: All new features must have unit tests
  • Coverage: Maintain minimum 90% coverage
  • Documentation: Add XML documentation to public methods
  • BDD: Follow Given/When/Then pattern in Portuguese

Useful Links


Quality and Metrics

SonarCloud

Code Smell Bugs Tests Lang Quality
Code Smells Bugs AppVeyor tests GitHub top language Quality Gate Status

Statistics

Lines of Code Duplicated Lines Coverage Maintainability
Lines of Code Duplicated Lines (%) Coverage Maintainability Rating
Reliability Security Technical Debt Vulnerabilities
Reliability Rating Security Rating Technical Debt Vulnerabilities

Downloads

GitHub all releases

Issues

GitHub issues


Developed with ❤️ by the opensource community

Beyond this simple example, EAF provides a robust infrastructure and development model for modularity, multi-tenancy, cache, background jobs, data filters, setting management, domain events, unit and integration tests, and much more! You focus on your business code and don't repeat yourself!


Star History

Star History Chart

StarMapper

StarMapper

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors