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

https://github.com/sedokina/teniry.crudgenerator

Instantly generate CRUD for a .NET application ๐Ÿš€
https://github.com/sedokina/teniry.crudgenerator

api-generator cqrs crud crud-generator dotnet prototyping

Last synced: about 1 month ago
JSON representation

Instantly generate CRUD for a .NET application ๐Ÿš€

Awesome Lists containing this project

README

          


Teniry.CrudGenerator


Instantly generate CRUD for an application

[Report Bug][github-issues-url] ยท [Request Feature][github-issues-url]

[github-issues-url]:https://github.com/Sedokina/Teniry.CrudGenerator/issues

# โœจ Features:

- Automatically generate CRUD operations for your domain models
- Generate only the endpoints and handlers you require
- Tailor the generated code to your specific needs with fully customizable configuration
- Use PostgreSQL or MongoDB as your database with Entity Framework Core
- Use minimal APIs for lightweight and efficient endpoint generation
- Provides clear and readable autogenerated code, making it easy to extend and debug
- Based on CQRS pattern (see [Teniry.CQRS](https://github.com/Sedokina/Teniry.CQRS))
- Ideal for both rapid prototyping and large-scale projects with numerous entities.

# ๐Ÿ”ญ Overview

* [Installation](#-installation)
* [Quick start](#-quick-start)
* [Examples](#examples)
* [FAQ](#faq)
* [Who is this library for and would it be a good fit for my project?](#who-is-this-library-for-and-would-it-be-a-good-fit-for-my-project)
* [What is the difference between this library and other libraries that generate CRUD?](#what-is-the-difference-between-this-library-and-other-libraries-that-generate-crud)
* [Is it production ready?](#is-it-production-ready)
* Docs
* [Generator Configuration](docs/entity-generator-configuration.md)
* [DbContext](docs/db-context.md)
* [MongoDb limitations](docs/mongo-limitations.md)

# ๐Ÿ“ฆ Installation

You can install the package via NuGet:

```
Install-Package Teniry.CrudGenerator
```

# ๐Ÿ”จ Quick start

* Create domain model
* Create DBContext
* Create basic generator configuration
* Map autogenerated endpoints
* ๐Ÿš€ Done! You have working CRUD API!

## Create domain model

```csharp
public class Todo {
public Guid Id { get; set; }
public string Description { get; set; }
public bool IsDone { get; set; }
}
```

## Create DBContext

```csharp
using Microsoft.EntityFrameworkCore;
using Teniry.CrudGenerator.Abstractions.DbContext;

[UseDbContext(DbContextDbProvider.Mongo)]
public class TodoDb : DbContext {
public TodoDb(DbContextOptions options) : base(options) { }

public DbSet Todos { get; set; }
}
```

see [DbContext](docs/db-context.md) for more information

## Create basic generator configuration

```csharp
using Teniry.CrudGenerator.Abstractions.Configuration;

public class TodoConfiguration : EntityGeneratorConfiguration { }
```

see [Generator Configuration](docs/entity-generator-configuration.md) for more information on customization

## Map autogenerated endpoints

Add the following code to your `Program.cs` file, to register all necessary services for library to work

```csharp
using AutogeneratedEndpoints;

// your configuration
// ...

// This required because generated code uses CQRS pattern library
builder.Services.AddCqrs();

// This required to provide generated endpoints to the application
app.MapGeneratedEndpoints();

// your other app.Map() calls
// ...
```

> [!NOTE]
> `using AutogeneratedEndpoints;` namespace does not exist if the application is not built yet. It is generated by
> the library

# FAQ

## Who is this library for and would it be a good fit for my project?

This library is for developers who want to quickly generate CRUD for their application.

It would fit you if:

* You need to create a simple CRUD for a small project
* You want to create a prototype quickly
* You have a large project that includes lots of entities that requires CRUD operations and don't include much business
logic
* You want to focus on the business logic, don't want to write a lot of boilerplate code for an application, and stay
flexible in the same time

## What is the difference between this library and other libraries that generate CRUD?

This library is based on the CQRS pattern and generates code that is easy to understand and maintain.
It generates only the necessary endpoints and handlers, which makes the code more readable and maintainable.
It also provides a way to customize the configuration to fit your needs.

## Is it production ready?

Yes! Teniry.CodeGenerator is production ready. But it would be fair to notice that it is quite new library and it may
lack some features that you might need.

# Examples

Check out the [Mongo Todo Web App Example](samples/Teniry.CrudGenerator.Mongo.TodoSampleApi)
and [PostgreSql Todo Web App Example](samples/Teniry.CrudGenerator.PostgreSql.TodoSampleApi)
examples on using Teniry.CrudGenerator library

# Contributing

Feel free to share your ideas through Pull Requests or GitHub Issues. Any contribution or feedback is appreciated!