CodeLogic Libraries
CodeLogic Libraries (CL.*) is a suite of 12 production-ready .NET 10 libraries designed to integrate seamlessly with the CodeLogic 4 framework. Each library is a self-contained CodeLogic library that manages its own configuration, lifecycle, and health checks.
What are CL.* Libraries?
Each CL.* package is a ILibrary implementation that plugs directly into the CodeLogic 4 boot sequence. You register it with Libraries.LoadAsync<T>(), configure it via the auto-generated JSON config file, and the framework handles initialization, dependency ordering, and graceful shutdown.
// Program.cs
await Libraries.LoadAsync<CL.MySQL2.MySQL2Library>();
await Libraries.LoadAsync<CL.Mail.MailLibrary>();
await Libraries.LoadAsync<CL.TwoFactorAuth.TwoFactorAuthLibrary>();
CodeLogic.RegisterApplication(new MyApp());
await CodeLogic.ConfigureAsync();
await CodeLogic.StartAsync();
Library Reference
| Library | Description |
|---|---|
| CL.Common | General-purpose utilities: hashing (SHA-256/SHA-512/MD5/bcrypt), ID generation (ULID, UUID), string extensions, date helpers |
| CL.GitHelper | Git repository operations and automation: clone, pull, commit, push, branch management via LibGit2Sharp |
| CL.Mail | SMTP/IMAP email with Handlebars-style template engine, HTML and plain-text, attachments |
| CL.MySQL2 | MySQL with connection pooling, Repository<T> CRUD, QueryBuilder<T> LINQ-style queries, migrations |
| CL.NetUtils | DNSBL spam checking and MaxMind GeoIP2 database lookup for IP intelligence |
| CL.PostgreSQL | PostgreSQL with multi-database support, Repository<T>, QueryBuilder<T>, schema migrations |
| CL.SQLite | SQLite with custom connection pool, Repository<T>, QueryBuilder<T>, migration runner |
| CL.SocialConnect | Discord webhooks plus Steam Web API profile lookups and ticket-based authentication |
| CL.StorageS3 | Amazon S3 and MinIO object storage: upload, download, delete, presigned URLs, bucket management |
| CL.SystemStats | Cross-platform CPU usage, memory (total/available/used), and per-process statistics |
| CL.TwoFactorAuth | TOTP-based 2FA with QR code generation (compatible with Google Authenticator, Authy) |
| CL.GameNetQuery | Game server queries: Valve RCON, Source UDP (A2S), Minecraft UDP/RCON |
Design Principles
- CodeLogic-native — each library implements
ILibrarywith the full 4-phase lifecycle - Zero shared state — each library owns its config directory, log directory, and data directory
- Self-configuring — config files are auto-generated with defaults on first run
- Health-aware — every library implements
HealthCheckAsync()for operational monitoring - Dependency-safe —
LibraryManifest.Dependenciesdeclares ordering requirements
Quick Integration Example
// 1. Reference the library project
// <ProjectReference Include="path/to/CodeLogic.Libs/CL.MySQL2/CL.MySQL2.csproj" />
// 2. Load it
await Libraries.LoadAsync<CL.MySQL2.MySQL2Library>();
// 3. After StartAsync(), use it from your application or other libraries
public class MyApp : IApplication
{
private IMySqlRepository<User> _users = null!;
public async Task RunAsync(ApplicationContext context)
{
var mysql = context.GetLibrary<CL.MySQL2.MySQL2Library>();
_users = mysql.GetRepository<User>();
var user = await _users.FindAsync(u => u.Email == "alice@example.com");
}
}
Next Steps
- Getting Started — how to reference, register, and use any CL.* library
- Database Libraries — MySQL, PostgreSQL, SQLite with Repository pattern
- Mail — sending email with templates
- Storage — S3 and MinIO object storage
- Security — TOTP two-factor authentication
- System Monitoring — CPU and memory stats
- Social — Discord webhooks and Steam auth
- Game Server Queries — Valve RCON, Source UDP, Minecraft
- API Reference — full API documentation