Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Tasks": [
{
"Title": "Generate README for FluentCMS.Infrastructure.Common",
"AgentName": "DocumentationGenerator",
"DetailedInstructions": "Create a README.md file in the project root (src/Common/FluentCMS.Infrastructure.Common/) for NuGet publishing. Include: project description as common utilities for FluentCMS Infrastructure, key features (shared base classes, utilities), installation via NuGet (dotnet add package FluentCMS.Infrastructure.Common), basic usage example, dependencies (none external), and MIT license reference.",
"ContextPath": "src/Common/FluentCMS.Infrastructure.Common/",
"Priority": 5,
"Status": 0
}
],
"CreatedAt": "2026-02-09T08:45:35.5079343Z"
}
86 changes: 84 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,84 @@
# FluentCMS.Infrastructure
FluentCMS Infrastructure
# Plugins

> A modular plugin system for FluentCMS infrastructure, enabling dynamic discovery, loading, and initialization of plugins to extend core functionality.

## 📖 About
The Plugins project is a collection of libraries that enable a flexible plugin architecture for FluentCMS. It provides mechanisms for discovering plugins from directories, loading them in isolated AssemblyLoadContexts to prevent memory leaks, initializing plugin instances, and managing their lifecycles. This allows developers to extend the CMS capabilities dynamically without modifying the core codebase, ensuring modularity, safety, and ease of integration.

## 🚀 Getting Started

### Prerequisites
* .NET 10.0

### Installation
```bash
# Build the projects
dotnet build FluentCMS.Infrastructure.Plugins.Abstractions.csproj
dotnet build FluentCMS.Infrastructure.Plugins.csproj
```

Since this project consists of multiple .NET libraries, build them and reference the resulting assemblies in your application.

### Setup
Configure the plugin system in your application:

```csharp
using FluentCMS.Infrastructure.Plugins;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPluginSystem(options =>
{
// Configure options, e.g.
options.PluginDirectories = ["path/to/plugins"];
});
var app = builder.Build();
app.UsePluginSystem();
```

### Usage Examples
To create a plugin, implement the `IPluginStartup` interface from `FluentCMS.Infrastructure.Plugins.Abstractions`, and mark the class with the `Plugin` attribute.

Example plugin:
```csharp
using FluentCMS.Infrastructure.Plugins.Abstractions;

[Plugin]
public class MyPlugin : IPluginStartup
{
public void ConfigureServices(IServiceCollection services, IConfiguration? configuration)
{
// Register plugin-specific services
services.AddScoped<IMyPluginService, MyPluginService>();
}

public void Configure(IApplicationBuilder app)
{
// Configure middleware or routes
app.MapGet("/myplugin", () => "Hello from Plugin!");
}

// Optionally override Name, Version, Priorities
public override string Name => "My Custom Plugin";
}
```

Build this as a separate assembly and place it in a directory configured in `PluginDirectories`.

The system will discover, load, initialize, and start the plugin automatically.

## 📦 Key Features
- **Dynamic Discovery**: Scans directories for plugin assemblies based on file patterns.
- **Isolated Loading**: Uses custom `AssemblyLoadContext` to load plugins collectibly, preventing memory leaks and allowing unloading.
- **Initialization and Lifecycle**: Handles plugin instantiation, service registration, and application configuration with priority ordering.
- **Error Handling**: Provides robust exception handling, logging, and optional error ignoring for resilient operation.
- **Abstraction-Based Design**: Extensible through interfaces like `IPluginDiscovery`, `IPluginLoader`, `IPluginInitializer`, and `IPluginManager`.
- **Configuration Scoping**: Each plugin receives its own configuration section under 'Plugins:{PluginName}'.

## 📚 Dependencies
Key dependencies include:
- .NET 10.0
- Microsoft.AspNetCore.Http.Abstractions (2.3.9)
- Microsoft.Extensions.Configuration.Abstractions (10.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (10.0.2)
- Microsoft.Extensions.Logging.Abstractions (10.0.2)
- System.Reflection.MetadataLoadContext (10.0.2)
2,235 changes: 2,235 additions & 0 deletions llm.json

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions src/Common/FluentCMS.Infrastructure.Common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# FluentCMS.Infrastructure.Common

This project provides common utilities and base classes for FluentCMS infrastructure components, enabling consistent entity management, auditing, and user context handling across the FluentCMS ecosystem.

## Key Features

- **Base Entity Classes**:
- `Entity`: A simple base entity with a unique `Id` property.
- `AuditableEntity`: Extends `Entity` with auditing fields like `CreatedAt`, `UpdatedAt`, `CreatedBy`, `UpdatedBy`, and `Version` for concurrency control.
- **User Context Interface**: `IUserContext` for managing user-related information.
- **Global Usings**: Automatically includes common namespaces like `System.ComponentModel.DataAnnotations` globally to reduce boilerplate code.

## Installation

Install the package via NuGet:

```bash
dotnet add package FluentCMS.Infrastructure.Common
```

## Usage

### Basic Entity

To create a simple entity, inherit from the `Entity` class:

```csharp
using FluentCMS.Infrastructure;

public class MyEntity : Entity
{
public string Name { get; set; }
// Add more properties as needed
}
```

### Auditable Entity

For entities that require auditing and versioning, inherit from `AuditableEntity`:

```csharp
using FluentCMS.Infrastructure;

public class MyAuditableEntity : AuditableEntity
{
public string Title { get; set; }
public string Content { get; set; }
// Add more properties as needed
}
```

### User Context

To use the user context, you can implement or inject the `IUserContext` interface to access user information:

```csharp
using FluentCMS.Infrastructure;

public interface IUserContext
{
// Define properties like UserId, Username, etc.
}

// Implement or inject IUserContext in your services.
```

## Dependencies

This library has no external dependencies. It targets .NET 10.0 and uses standard .NET frameworks.

## License

This project is licensed under the MIT License.
17 changes: 17 additions & 0 deletions src/Common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Common

> Shared infrastructure library for FluentCMS containing reusable components and utilities.

## 📖 About
The Common project is a .NET class library that provides essential, reusable infrastructure components such as base entity classes, auditable entities with versioning, and user context interfaces. It forms the foundation for consistent data handling, auditing, and user management across the entire FluentCMS system, ensuring modularity and maintainability in the broader application architecture.

## 🚀 Getting Started

### Prerequisites
* .NET 10.0 (or compatible runtime/SDK for the target framework)

### Installation
```bash
# Add as a project reference in your solution
dotnet add reference src/Common/FluentCMS.Infrastructure.Common/FluentCMS.Infrastructure.Common.csproj
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# FluentCMS.Infrastructure.Configuration.EntityFramework.SqlServer

A SQL Server-specific Entity Framework configuration provider for the FluentCMS Infrastructure. This package enables using SQL Server as the backend for storing and retrieving application configuration data via Entity Framework.

## Key Features

- SQL Server database provider integration for FluentCMS configuration.
- Extension methods to easily set up SQL Server-backed configuration in .NET applications.
- Leverages Entity Framework Core for ORM-based configuration storage and retrieval.
- Supports automatic configuration reloading with optional intervals.

## Installation

Install the package via NuGet Package Manager:

```
dotnet add package FluentCMS.Infrastructure.Configuration.EntityFramework.SqlServer --version 1.0.0
```

## Usage

To use SQL Server for configuration, add the SQL Server configuration extension to your `IConfigurationBuilder`:

```csharp
using FluentCMS.Configuration.EntityFramework.SqlServer;
using Microsoft.Extensions.Configuration;

var builder = new ConfigurationBuilder()
.AddSqlServerConfiguration("Server=your-server;Database=your-db;Trusted_Connection=True;");

// Build the configuration
var configuration = builder.Build();
```

Replace `"Server=your-server;Database=your-db;Trusted_Connection=True;"` with your actual SQL Server connection string.

For configuration with automatic reloading, specify a reload interval:

```csharp
builder.AddSqlServerConfiguration(connectionString, TimeSpan.FromSeconds(30));
```

## Dependencies

This package depends on:

- `Microsoft.EntityFrameworkCore.SqlServer` (version 10.0.2)
- `FluentCMS.Infrastructure.Configuration.EntityFramework` (project reference, included as a dependency in NuGet package)

Ensure your project targets .NET 10.0 or later.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# FluentCMS.Infrastructure.Configuration.EntityFramework.Sqlite

This package provides SQLite-specific Entity Framework configuration for the FluentCMS Infrastructure layer. It enables storing application configuration in an SQLite database using Entity Framework as the ORM, extending the base FluentCMS configuration capabilities to support SQLite as a lightweight, file-based database option.

## Key Features

- SQLite provider for storing and retrieving application configuration.
- Seamless integration with Entity Framework and the FluentCMS configuration system.
- Support for automatic configuration reloading based on a specified interval.

## Installation

Install this package via NuGet:

```bash
dotnet add package FluentCMS.Infrastructure.Configuration.EntityFramework.Sqlite
```

## Usage

To use SQLite for configuration storage, add the SQLite configuration provider to your configuration builder. Ensure you have the connection string defined in your appsettings.json or environment variables.

```csharp
using FluentCMS.Infrastructure.Configuration.EntityFramework.Sqlite;

var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddSqliteConfiguration("DefaultConnection", TimeSpan.FromSeconds(30)); // Reload every 30 seconds
```

Make sure to register the required services and configure the database context as needed in your application. This extension method relies on the base Entity Framework configuration from `FluentCMS.Infrastructure.Configuration.EntityFramework`.

## Dependencies

- Microsoft.EntityFrameworkCore.Sqlite (latest stable version)
- FluentCMS.Infrastructure.Configuration.EntityFramework

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# FluentCMS.Infrastructure.Configuration.EntityFramework

## Description

This package provides Entity Framework-based configuration storage for FluentCMS Infrastructure. It allows storing and retrieving application configuration data dynamically from a database, enabling runtime configuration updates without application restarts.

## Key Features

- **EF-backed Configuration**: Store and manage configuration settings in a database using Entity Framework Core.
- **Automatic Caching**: In-memory caching for improved performance.
- **Periodic Reload**: Configurable automatic reloading of configuration from the database.
- **JSON Deserialization**: Supports nested JSON structures, flattened into key-value pairs for .NET configuration providers.
- **Data Seeding**: Includes data seeders for initializing configuration data.

## Installation

Install the package via NuGet:

```bash
dotnet add package FluentCMS.Infrastructure.Configuration.EntityFramework
```

## Basic Usage

To set up Entity Framework-based configuration in your application, follow these steps:

1. Configure the service in `Program.cs` or your startup code:

```csharp
using FluentCMS.Infrastructure.Configuration.EntityFramework;

// In your Program.cs or Startup.cs
builder.Configuration.AddDatabaseConfiguration(options =>
{
options.UseSqlite("Data Source=configurations.db"); // or other EF provider
options.ReloadOnChange = TimeSpan.FromMinutes(5); // optional auto-reload
});

// For database migration/seeding
builder.Services.AddFluentCmsInfrastructure(options =>
{
options.AddDatabaseConfiguration();
});
```

2. The configuration will be loaded from the database and flattened for use with `IConfiguration`.

Note: Ensure the database is created and seeded appropriately using the provided migrations and seeders.

## Dependencies

- Microsoft.Extensions.Configuration (10.0.2)
- Microsoft.Extensions.Configuration.EnvironmentVariables (10.0.2)
- Microsoft.Extensions.Configuration.Json (10.0.2)
- Microsoft.EntityFrameworkCore.Sqlite (10.0.2)
- FluentCMS.Infrastructure.Repositories.EntityFramework
- FluentCMS.Infrastructure.Configuration

## License

This project is licensed under the MIT License.
Loading