{"id":25890525,"url":"https://github.com/sajanv88/craft","last_synced_at":"2026-06-10T05:32:06.564Z","repository":{"id":280180803,"uuid":"941202572","full_name":"sajanv88/Craft","owner":"sajanv88","description":"Craft is the ultimate framework that supercharges ASP.NET Core! With its sleek layer of extension methods and powerful features, it transforms your code into a modular, clean, and effortlessly simple masterpiece. Build smarter, not harder!","archived":false,"fork":false,"pushed_at":"2025-04-07T05:42:54.000Z","size":93,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-28T02:53:48.247Z","etag":null,"topics":["asp-net-core","dotnet-core","middleware","minimal-api","modular"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sajanv88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-01T18:24:22.000Z","updated_at":"2026-02-14T14:44:31.000Z","dependencies_parsed_at":"2025-03-01T20:19:52.932Z","dependency_job_id":"e0d7224e-9ed4-4836-b676-f81757828f78","html_url":"https://github.com/sajanv88/Craft","commit_stats":null,"previous_names":["sajanv88/craft"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sajanv88/Craft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2FCraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2FCraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2FCraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2FCraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sajanv88","download_url":"https://codeload.github.com/sajanv88/Craft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajanv88%2FCraft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34139178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","dotnet-core","middleware","minimal-api","modular"],"created_at":"2025-03-02T19:28:01.059Z","updated_at":"2026-06-10T05:32:06.557Z","avatar_url":"https://github.com/sajanv88.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n## Craft\nCraft is the ultimate framework that supercharges ASP.NET Core! With its sleek layer of extension methods and powerful features, it transforms your code into a modular, clean, and effortlessly simple masterpiece. Build smarter, not harder!\n\nFor a better understanding, take a look at the `Craft.Api` project inside this repo. I have a demonstration usages of Craft extensions around common ASP.NET Core Web Api project.\n\n#### Routing\nCraft leverages the power of `IEndpointRouteBuilder` routing and harnesses all the extensions from `IEndpointConventionBuilder` aka Minimal APIs to keep your code sleek and efficient. Need a secure route? No problem! Define a route with built-in authorization in just a few lines. Clean, modern, and developer-friendly!\n\n\n### Get Started with Craft in Minutes! �\n\n```bash\ndotnet new webapi --output web-api\ncd web-api \u0026\u0026 dotnet add package Craft.CraftModule\n```\n\nOpen the `web-api` project in your favorite IDE and create a new module, e.g., `TodoModule.cs`.\n\nOpen `Program.cs` and call the Craft extension method to register your module(s):\n\n```csharp\n// Option 1: Automatically discover modules from the assembly\nbuilder.Services.AddCraftModulesFromAssembly(typeof(Program).Assembly);\n\n// Option 2: Manually specify modules\nbuilder.Services.AddCraftModules([typeof(TodoModule)]);\n```\nChoose whichever suits your style!\n\n\nFinally, add this line to automatically map all your module endpoints:\n```csharp\napp.UseCraftGeneralException(); //  general exception handler (optional)\n\napp.MapCraftModulesEndpoint();\n```\nAnd that’s it! Your endpoints are now ready to roll. 🚀\n\n\n\n### Simple todo api example\n\n```csharp\n\npublic sealed class Todo\n{\n    public int Id { get; set; }\n    public string Title { get; set; }\n}\n\npublic sealed class TodoModule : CraftModule\n{\n    private List\u003cTodo\u003e _todos = new List\u003cTodo\u003e\n    {\n        new Todo { Id = 1, Title = \"Buy milk\" },\n        new Todo { Id = 2, Title = \"Walk the dog\" },\n    };\n    \n    public override IEndpointRouteBuilder AddRoutes(\n        IEndpointRouteBuilder builder\n    {\n        var endpoints = builder.MapGroup(\"/api/todos\");\n        endpoints.MapGet(\"/\", () =\u003e _todos);\n        endpoints.MapGet(\"/{id}\", (int id) =\u003e _todos.FirstOrDefault(x =\u003e x.Id == id));\n        endpoints.MapPut(\"/\", (string title) =\u003e \n        {\n            var todo = new Todo { Id = _todos.Count + 1, Title = title };\n            _todos.Add(todo);\n            return Results.Created($\"/api/todos/{todo.Id}\", todo);\n        });\n        endpoints.MapDelete(\"/{id}\", (int id) =\u003e \n        {\n            var todo = _todos.FirstOrDefault(x =\u003e x.Id == id);\n            if (todo == null)\n            {\n                return Results.NotFound();\n            }\n            _todos.Remove(todo);\n            return Results.NoContent();\n        });\n        endpoints.MapPatch(\"/{id}\", (int id, string title) =\u003e \n        {\n            var todo = _todos.FirstOrDefault(x =\u003e x.Id == id);\n            if (todo == null)\n            {\n                return Results.NotFound();\n            }\n            todo.Title = title;\n            return Results.Ok(todo);\n        });\n        return builder;\n    }\n}\n```\n### Want to Use a Database in Your Module?\nCraft has you covered! You can seamlessly integrate Entity Framework Core into your module.\n\n#### Install the PostgreSQL Provider\nTo get started, install the Npgsql.EntityFrameworkCore.PostgreSQL package:\n\n```bash\ndotnet add package Npgsql.EntityFrameworkCore.PostgreSQL\n```\n#### Create a Database Context\nNext, create an ApiDbContext class that inherits from CraftDbContext and define a DbSet for your entity.\n\n`ApiDbContext.cs`\n\n```csharp\n\nusing Craft.Api.Domain;\nusing Craft.CraftModule.Infrastructure;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Craft.Api.Infrastructure;\n\npublic class ApiDbContext(DbContextOptions\u003cApiDbContext\u003e options)\n    : CraftDbContext\u003cApiDbContext\u003e(options)\n{\n    public DbSet\u003cTodoEntity\u003e Todos { get; set; }\n}\n\n```\n#### Configure Your Entity in the Module\nIn your `TodoModule.cs` file, override the ConfigureModelBuilder method to define your entity schema.\n\n```csharp\npublic sealed class TodoModule : CraftModule\n{\n    public override void ConfigureModelBuilder(ModelBuilder modelBuilder)\n    {\n        modelBuilder.Entity\u003cTodoEntity\u003e(entity =\u003e\n        {\n            entity.HasKey(e =\u003e e.Id);\n            entity.Property(e =\u003e e.Content).IsRequired();\n            entity.Property(e =\u003e e.IsCompleted).HasDefaultValue(false);\n        });\n    }\n}\n```\n#### Define Your Connection String\nAdd your database connection string to `appsettings.json`:\n\n```json\n{\n  \"ConnectionStrings\": {\n    \"DefaultConnection\": \"Host=localhost;Port=5432;Database=craft;Username=postgres;Password=postgres\"\n  }\n}\n```\n#### Configure the Database Context in `Program.cs`\nModify your `Program.cs` file to register the database context:\n\n```csharp\nbuilder.Services.AddDbContext\u003cApiDbContext\u003e(options =\u003e\n{\n    var connectionString = builder.Configuration.GetConnectionString(\"DefaultConnection\");\n    options.UseNpgsql(connectionString);\n});\n\n\n```\n#### Run Migrations and Update the Database\n```bash\n\ndotnet ef migrations add InitialCreate\ndotnet ef database update\n\n```\n\n🎉 That's It!\nYour module is now fully integrated with Entity Framework Core.\n\nFor a complete working example, check out the example `Craft.Api` project in this repository under the Modules folder. 🚀\n\nAdditionally, you can use a separate **DbContext** for each module.\n\nFor example, simply create a `TodoDbContext` and register it in the `PreInitialization` method:\n\n```csharp\nservices.AddDbContext\u003cTodoDbContext\u003e();\n```  \n\nThis allows each module to have its own isolated database context, improving modularity and maintainability. 🚀\n\n\n### Craft Available Modules\n\n- Craft.CraftModule\n- Craft.KeycloakModule\n  - [How to use Craft.KeycloakModule](docs/Keycloak.md)\n- Craft.LocalizationModule\n  - [How to use Craft.LocalizationModule](docs/Localization.md)\n\n### Future Plans\n- Craft.LocalizationModule\n- Craft.AIAgentModule\n- Craft.BackgroundTaskModule\n\n### Contributing\n\nCraft is an open-source project and welcomes contributions from the community.\nIf you have any ideas, suggestions, or improvements, feel free to open an issue or submit a pull request. \nLet’s make Craft the best framework for ASP.NET Core together!\n\n### Author\n\n- [Sajan](https://github.com/sajanv88)\n\n\n### License\nCraft is licensed under the MIT license. See the [LICENSE](LICENSE) file for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajanv88%2Fcraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsajanv88%2Fcraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajanv88%2Fcraft/lists"}