Skip to main content

Start with NuGet packages

Use these steps if you want to add SharpOMatic to an existing ASP.NET Core project.
You could start from scratch by creating a new ASP.NET Core project and then running these steps.

Install packages

dotnet add package SharpOMatic.Engine
dotnet add package SharpOMatic.Engine.Sqlite
dotnet add package SharpOMatic.Editor

For SQL Server, install SharpOMatic.Engine.SqlServer instead of SharpOMatic.Engine.Sqlite.

If you also want to accept AG-UI clients, install the optional package:

dotnet add package SharpOMatic.AGUI

Register services

Update Program.cs to add the required services. The following example stores library assets and a SQLite database in your user profile. This gets you up and running quickly and isolates the data to the current user.

For example, if your username is JohnDoe, then the files will be at:
C:\Users\JohnDoe\AppData\Local\SharpOMatic

  // Assets are stored in the current user's profile
builder.Services.Configure<FileSystemAssetStoreOptions>(
builder.Configuration.GetSection("AssetStorage:FileSystem"));
builder.Services.AddSingleton<IAssetStore, FileSystemAssetStore>();

builder.Services.AddSharpOMaticEditor();
builder.Services.AddSharpOMaticTransfer();
builder.Services.AddSharpOMaticAgUi();
builder.Services.AddSharpOMaticEngine()
.AddSqliteRepository(
connectionString: $"Data Source={Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "sharpomatic.db")}");

The first 3 lines are used to setup how assets are stored. It uses the file system implementation which is the easiest for getting started. We want to use the browser based editor and so need to call AddSharpOMaticEditor. To enable import and export we then add AddSharpOMaticTransfer. If you want AG-UI protocol clients, add AddSharpOMaticAgUi. Finally the AddSharpOMaticEngine call is used to setup the repository. For simplicity we use SQLite, it will create the database automatically on first start.

If you want SQL Server:

dotnet add package SharpOMatic.Engine.SqlServer
  builder.Services.AddSharpOMaticEngine()
.AddSqlServerRepository(
connectionString: builder.Configuration.GetConnectionString("SharpOMatic")!);

Map the editor UI

  app.MapSharpOMaticEditor();

By default SharpOMatic uses a base path of /sharpomatic. That gives you:

  • Editor UI: /sharpomatic/editor
  • Editor and transfer APIs: /sharpomatic/api/...
  • AG-UI: /sharpomatic/api/agui

If you want a different base path, define one variable and use it consistently:

  var sharpOMaticBasePath = "/banana";

builder.Services.AddSharpOMaticEditor(sharpOMaticBasePath);
builder.Services.AddSharpOMaticTransfer(sharpOMaticBasePath);
builder.Services.AddSharpOMaticAgUi(sharpOMaticBasePath);

app.MapSharpOMaticEditor(sharpOMaticBasePath);

MapSharpOMaticEditor automatically appends /editor to the base path. AddSharpOMaticAgUi defaults its child path to /api/agui, but you can override that too:

  builder.Services.AddSharpOMaticAgUi("/banana", "/integrations/chat");

Open visual editor

Check the generated port number for new project in the launchSettings.json.
NOTE: The demo server uses https://localhost:9001 and http://localhost:9000 by default. Replace those ports if your host uses different values.

Use your favorite browser to open https://localhost:9001/sharpomatic/editor