2.9 KiB
2.9 KiB
GPW_NEXT Agent Instructions
Architecture Overview
- Multi-Project Structure: The solution consists of several interconnected projects.
- Smart10 Module:
GPW.CORE.Smart10: The ASP.NET Core Server project. Hosts API Controllers and implements Server-side logic.GPW.CORE.Smart10.Client: The Blazor WebAssembly project. Contains UI components and client-side services that consume APIs.
- Data Layer:
GPW.CORE.Data: Contains EF Core models (DbModels),GPWContext, and theGPWControllerwhich acts as a data access layer.GPW.CORE.Dto: Contains Data Transfer Objects used for communication between Client and Server to avoid direct dependency on EF Core models.
- Services Pattern:
- Client-side: Services implement interfaces (e.g.,
ITimbraturesService) and useHttpClientto call REST endpoints. - Server-side (Prerendering): To support Blazor Web App prerendering, implement the same interfaces in the Server project using a "Server-side" implementation that calls
CoreSmartDataServicedirectly instead of via HTTP.
- Client-side: Services implement interfaces (e.g.,
Development Workflows
Implementing New Features (Smart10 Example)
- DTO: Define the required data structure in
GPW.CORE.Dto. - Server Data Access: Ensure
CoreSmartDataService(inGPW.CORE.Smart10.Data) orGPWController(inGPW.CORE.Data) has the necessary business logic. - API Controller: Add an endpoint in
GPW.CORE.Smart10\Controllersto expose the data via REST. - Client Interface: Add the method signature to the interface in
GPW.CORE.Smart10.Client\Services. - Client Implementation: Implement the service in
GPW.CORE.Smart10.Client\ServicesusingHttpClient. - Server Implementation (Prerendering Support): Create a server-side implementation of the interface in
GPW.CORE.Smart10\Servicesthat callsCoreSmartDataServicedirectly. - Dependency Injection:
- Client: Register the
HttpClient-based service inGPW.CORE.Smart10.Client\Program.cs. - Server: Register the direct-access service in
GPW.CORE.Smart10\Program.cs.
- Client: Register the
Testing & Verification
- UI Testing: Use the
Test...razorpages in the Client project to validate end-to-end flows (Insert, Update, Delete, Search). - Manual Check: For UI changes, verify the interaction between
@bindand event handlers (use@bind:afterfor .NET 7+).
Key Constraints & Gotchas
- NLog: Do not add
NLog.Web.AspNetCoreto the Client project; it is incompatible with the WASM runtime. - UID Logic: Many entities use a calculated
UID(e.g.,IdxDipendente_DataOra_Ora) for RESTful operations (likeDELETE /api/resource/{uid}) instead of passing entire objects. - Prerendering: Always provide a server-side implementation of client-side services to avoid
InvalidOperationExceptionduring the initial page load. - Namespace Integrity: Be careful with namespaces when moving logic between
GPW.CORE.Smart10(Server) andGPW.CORE.Smart10.Client(Client).