Skip to content

Commit 7c74beb

Browse files
authored
flipped to RLS (#13)
* flipped to RLS * queries * v1my * fixed actor route * port update
1 parent b3da4b3 commit 7c74beb

128 files changed

Lines changed: 1364 additions & 3944 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[![Web & API & SQL CI/CD](https://github.com/goodtocode/agent-framework-quick-start/actions/workflows/gtc-agent-standalone-web-api-sql.yml/badge.svg)](https://github.com/goodtocode/agent-framework-quick-start/actions/workflows/gtc-agent-standalone-web-api-sql.yml)
99

10-
Microsoft Agent Framework Quick-start is a 100% Microsoft, enterprise-ready starter kit for building modern, agentic applications with C#, Blazor (Fluent UI), and ASP.NET Core Web API. This solution demonstrates how to use the Microsoft Agent Framework to create a Copilot-style chat client, fully integrated with SQL Server for persistent storage of authors, chat sessions, and messages—all orchestrated through a clean architecture pattern.
10+
Microsoft Agent Framework Quick-start is a enterprise-ready starter kit for building modern, agentic applications with C#, Blazor (Fluent UI), and ASP.NET Core Web API. This solution demonstrates how to use the Microsoft Agent Framework to create a Copilot-style chat client, fully integrated with SQL Server for persistent storage of authors, chat sessions, and messages—all orchestrated through a clean architecture pattern.
1111

1212
With built-in tools (plugins) for querying and managing your own data, automated Azure infrastructure (Bicep), and seamless CI/CD (GitHub Actions), this repo provides everything you need to build, deploy, and extend real-world AI-powered apps on a traditional .NET stack—no JavaScript, no raw HTML, just pure Blazor and Fluent UI. Perfect for teams looking to modernize with AI while leveraging familiar, pragmatic enterprise patterns.
1313

@@ -257,26 +257,15 @@ dotnet user-secrets set "ConnectionStrings:DefaultConnection" "YOUR_SQL_CONNECTI
257257

258258
1. Open Windows Terminal in Powershell or Cmd mode
259259
2. cd to root of repository
260-
3. (Optional) If you have an existing database, scaffold current entities into your project
261-
262-
```
263-
dotnet ef dbcontext scaffold "Data Source=localhost;Initial Catalog=AgentFramework;Min Pool Size=3;MultipleActiveResultSets=True;Trusted_Connection=Yes;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer -t WeatherForecastView -c WeatherChannelContext -f -o WebApi
264-
```
265-
266-
4. Create an initial migration
267-
```
268-
dotnet ef migrations add InitialCreate --project .\src\Infrastructure.SqlServer\Infrastructure.SqlServer.csproj --startup-project .\src\Presentation.WebApi\Presentation.WebApi.csproj --context AgentFrameworkContext
269-
```
270-
271-
5. Develop new entities and configurations
272-
6. When ready to deploy new entities and configurations
260+
3. Deploy new entities and configurations to database
273261

274262
```
275263
dotnet ef database update --project .\src\Infrastructure.SqlServer\Infrastructure.SqlServer.csproj --startup-project .\src\Presentation.WebApi\Presentation.WebApi.csproj --context AgentFrameworkContext --connection "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=AgentFramework;Min Pool Size=3;MultipleActiveResultSets=True;Trusted_Connection=Yes;TrustServerCertificate=True;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30"
276264
```
277-
7. When an entity changes, is created or deleted, create a new migration. Suggest doing this each new version.
265+
4. When an entity changes, is created or deleted, create a new migration. Suggest doing this each new version.
278266
```
279267
dotnet ef migrations add v1.1.1 --project .\src\Infrastructure.SqlServer\Infrastructure.SqlServer.csproj --startup-project .\src\Presentation.WebApi\Presentation.WebApi.csproj --context AgentFrameworkContext
268+
dotnet ef database update --project .\src\Infrastructure.SqlServer\Infrastructure.SqlServer.csproj --startup-project .\src\Presentation.WebApi\Presentation.WebApi.csproj --context AgentFrameworkContext --connection "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=AgentFramework;Min Pool Size=3;MultipleActiveResultSets=True;Trusted_Connection=Yes;TrustServerCertificate=True;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30"
280269
```
281270

282271
# Running the Application
@@ -286,9 +275,9 @@ Right-click Presentation.WebApi and select Set as Default Project
286275
dotnet run --project src/Presentation.WebApi/Presentation.WebApi.csproj
287276
```
288277

289-
## Open http://localhost:7777/swagger/index.html
278+
## Open http://localhost:7175/swagger/index.html
290279
Open Microsoft Edge or modern browser
291-
Navigate to: http://localhost:7777/swagger/index.html in your browser to the Swagger API Interface
280+
Navigate to: http://localhost:7175/swagger/index.html in your browser to the Swagger API Interface
292281

293282
# Github Actions for Azure IaC and CI/CD
294283
## GitHub Actions (.github folder)

data/Chat/Actor.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Select top 1000 *
2+
From Actors

data/Chat/ChatSessions.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Select Top 1000 *
2+
From ChatSessions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copilot Instructions
2+
3+
## General Guidelines
4+
- Use custom .NotEmpty("message") validation convention instead of .NotEmpty().WithMessage("message") in FluentValidation validators. The Goodtocode.Validation library extends FluentValidation with custom syntax where validation methods accept message as a parameter: .NotEmpty("message"), .NotEqual(value, "message"), etc. Do not use .WithMessage() - pass the message directly as a parameter to the validation method.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Goodtocode.AgentFramework.Core.Application.Abstractions;
2+
3+
public interface ICurrentUserContext
4+
{
5+
Guid OwnerId { get; }
6+
Guid TenantId { get; }
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Goodtocode.AgentFramework.Core.Domain.Auth;
2+
3+
namespace Goodtocode.AgentFramework.Core.Application.Abstractions;
4+
5+
/// <summary>
6+
/// Marker interface for requests that require user context to be injected via pipeline behavior.
7+
/// </summary>
8+
/// <remarks>This interface is used to identify requests that need authenticated user information.
9+
/// When a request implements this interface, the UserInfoBehavior pipeline will automatically
10+
/// populate the <see cref="UserContext"/> property with the current user's context before
11+
/// the request handler executes.</remarks>
12+
public interface IRequiresUserContext
13+
{
14+
/// <summary>
15+
/// Gets or sets the authenticated user's context.
16+
/// </summary>
17+
/// <remarks>This property is automatically populated by the pipeline behavior
18+
/// before the request handler is invoked.</remarks>
19+
IUserContext? UserContext { get; set; }
20+
}

src/Core.Application/Abstractions/IUserInfoRequest.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Core.Application/Actor/CreateActorCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class CreateActorCommand : IRequest<ActorDto>
1414
public Guid TenantId { get; set; }
1515
}
1616

17-
public class CreateAuthorCommandHandler(IAgentFrameworkContext context) : IRequestHandler<CreateActorCommand, ActorDto>
17+
public class CreateActorCommandHandler(IAgentFrameworkContext context) : IRequestHandler<CreateActorCommand, ActorDto>
1818
{
1919
private readonly IAgentFrameworkContext _context = context;
2020

@@ -23,7 +23,7 @@ public async Task<ActorDto> Handle(CreateActorCommand request, CancellationToken
2323
GuardAgainstEmptyOwnerId(request?.OwnerId);
2424
GuardAgainstIdExists(_context.Actors, request!.Id);
2525

26-
var Actor = ActorEntity.Create(request!.Id == Guid.Empty ? Guid.NewGuid() : request!.Id, request.OwnerId, request.TenantId, request.FirstName, request.LastName, request.Email);
26+
var Actor = ActorEntity.Create(request!.Id == Guid.Empty ? Guid.NewGuid() : request!.Id, request.FirstName, request.LastName, request.Email);
2727
_context.Actors.Add(Actor);
2828
try
2929
{

src/Core.Application/Actor/DeleteActorByExternalIdCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class DeleteActorByOwnerIdCommand : IRequest
99
public Guid OwnerId { get; set; }
1010
}
1111

12-
public class DeleteAuthorByOwnerIdCommandHandler(IAgentFrameworkContext context) : IRequestHandler<DeleteActorByOwnerIdCommand>
12+
public class DeleteActorByOwnerIdCommandHandler(IAgentFrameworkContext context) : IRequestHandler<DeleteActorByOwnerIdCommand>
1313
{
1414
private readonly IAgentFrameworkContext _context = context;
1515

src/Core.Application/Actor/DeleteActorCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class DeleteActorCommand : IRequest
99
public Guid Id { get; set; }
1010
}
1111

12-
public class DeleteAuthorCommandHandler(IAgentFrameworkContext context) : IRequestHandler<DeleteActorCommand>
12+
public class DeleteActorCommandHandler(IAgentFrameworkContext context) : IRequestHandler<DeleteActorCommand>
1313
{
1414
private readonly IAgentFrameworkContext _context = context;
1515

0 commit comments

Comments
 (0)