Skip to content
code matters edited this page Aug 12, 2024 · 9 revisions

Fluent CMS - CRUD (Create, Read, Update, Delete) for any entities

GitHub stars Welcome to Fluent CMS If you find it useful, please give it a star ⭐

What is it

Fluent CMS is an open-source content management system designed to simplify the workflow for web development.

  • It provides a set of CRUD(Create, Read, Update, Delete) Restful APIs for any entities based on your configuration.
  • You can add your own logic by registering hook functions before or after access databases.
  • It provides admin panel for you to manage data, the admin panel have a rich set of inputs, text, number, datetime, dropdown, image, image gallery, and rich text editor.
  • It provides a schema builder for you to define entity and attributes.

Live Demo - A blog website build by Fluent CMS

Add Fluent CMS to your own project

  1. Create your own WebApplication.
  2. Add FluentCMS package
    dotnet add package FluentCMS
    # the next command copy compiled Admin Panel code to your wwwroot, 
    # The frontend code was write in React and Jquery, source code is admin-ui, also in this repo
    # The following command is for Mac,
    # for windows the directory should be at $(NuGetPackageRoot)fluentcms\1.0.0\staticwebassets
    # Please change 0.0.4 to the correct version number    
    cp -a ~/.nuget/packages/fluentcms/0.0.4/staticwebassets wwwroot 
  3. Modify Program.cs, add the following line before builder.Build(), the input parameter is the connection string of database.
    //Currently FluentCMS support AddSqliteCms, AddSqlServerCms 
    builder.AddSqliteCms("Data Source=cms.db").PrintVersion();
    var app = builder.Build();
    
  4. Add the following line After builder.Build()
    //this function bootstrap router, initialize Fluent CMS schema table
    await app.UseCmsAsync(false);
    
  5. If everthing is good, when the app starts, when you go to the home page, you should see the empty Admin Panel Here is a quickstart on how to use the Admin Panel Quickstart.md
  6. If you want to have a look at how FluentCMS handles one to many, many-to-many relationships, just add the following code
    var schemaService = app.GetCmsSchemaService();
    await schemaService.AddOrSaveSimpleEntity("student", "Name", null, null);
    await schemaService.AddOrSaveSimpleEntity("teacher", "Name", null, null);
    await schemaService.AddOrSaveSimpleEntity("class", "Name", "teacher", "student");   
    
    These code created 3 entity, class and teacher has many-to-one relationship. class and student has many-to-many relationship
  7. To Add you own business logic, you can add hook, before or after CRUD. For more hook example, have a look at Program.cs
    var hooks = app.GetCmsHookFactory();
    hooks.AddHook("teacher", Occasion.BeforeInsert, Next.Continue, (IDictionary<string,object> payload) =>
    {
      payload["Name"] = "Teacher " + payload["Name"];
    });