> For the complete documentation index, see [llms.txt](https://docs.flexbase.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flexbase.in/flexbase-mcp-ai-prompts/implementation-completion-prompts.md).

# Implementation Completion Prompts

> After FlexBase Studio generates skeleton code, use these tasks to **complete API business logic** and **generate UI pages/components** — driven by your extraction JSON and Markdown artifacts.
>
> **Works for all entry points:** Legacy Migration, BRD Extraction, and New Application Design.

## How to Use

Tell your AI agent which feature or module to implement. It will load the implementation completion guide and relevant conventions to produce production-ready code.

**Example prompts you can give your AI agent:**

```
Complete the API business logic for the Schedule module using the extraction JSON
```

```
Generate Blazor CRUD pages for the Person entity from the feature JSON
```

```
Add [Table] and [Column] annotations for legacy database column names
```

```
Implement all validations for CreateBooking from the extraction data
```

```
Complete the Angular service and list component for Orders
```

```
Walk me through implementing the entire Customer module end-to-end
```

```
Complete the implementation — move stored procedure logic to C# handlers
```

```
Complete the implementation — use stored procedures for complex queries
```

```
Generate database scripts for the stored procedures
```

```
Implement the CreateProduct handler using Document Store for CosmosDB
```

```
Add Redis caching to the GetProducts query with cache-aside pattern
```

```
Send a confirmation email after order creation using Email Provider
```

```
Implement AI-powered product classification using Azure OpenAI in the CreateProduct handler
```

```
Add vector search to the SearchArticles query using PgVector for semantic results
```

```
Store uploaded documents in Azure Blob Storage from the CreateDocument handler
```

***

## Task Catalog

### Task 1: Complete Domain Model from Extraction JSON

**Goal:** Fill in generated domain model partial classes with attributes, relationships, and legacy name annotations\
**User provides:** Module name, extraction JSON file path (or entity name)

### Task 1b: Configure Database Indexes

**Goal:** Add index configuration from extraction JSON index definitions\
**User provides:** Extraction JSON with index arrays per domain entity

### Task 2: Complete Domain Factory Methods

**Goal:** Implement Create and Update factory methods using extraction feature details\
**User provides:** Entity name, extraction JSON feature for CREATE/UPDATE

### Task 2b: Complete Handler with Stored Procedure Logic

**Goal:** Implement handler using stored procedure documentation as the specification\
**User provides:** Feature name with SP flag in extraction JSON + SP documentation file

**Options:**

* **Move to Code (DEFAULT):** SP logic translated to C# handler/query code
* **Call Stored Procedures:** Keep SPs in the database and call them from handlers — generates database migration scripts

### Task 3: Complete Handler Business Logic

**Goal:** Implement handler Execute method with orchestration from extraction features\
**User provides:** Feature name (e.g., CreateSchedule), extraction JSON

### Task 4: Complete Query Implementations

**Goal:** Implement query filters, includes, and projections from extraction features\
**User provides:** Module or entity name, extraction JSON with GETPAGEDLIST/GETLIST features

### Task 5: Complete Validation Plugins

**Goal:** Implement pre-bus validation logic from extraction validations\
**User provides:** Feature name, extraction JSON validations section

### Task 6: Complete DTOs and Mappers

**Goal:** Fill in generated DTOs with properties and validation annotations from extraction, then create mapper expressions\
**User provides:** Entity name, extraction JSON domain services

### Task 7: Complete Workflow States

**Goal:** Implement workflow state pattern from extraction workflow/status information\
**User provides:** Entity name, extraction JSON or Markdown with workflow/status information

### Task 8: Complete Event Subscribers

**Goal:** Implement event reactions from extraction events and subscribers\
**User provides:** Feature name, extraction JSON events/subscribers section

### Task 9: Add Legacy Name Retention

**Goal:** Add `[Table]` and `[Column]` annotations for legacy database compatibility\
**User provides:** Entity name or "all entities", extraction JSON with originalName fields

### Task 10: Generate Blazor UI from Extraction — Complete Module

**Goal:** Create the full Blazor FluentUI v4.x UI stack for a module — REST client, DTOs, dialog, list page, navigation — from extraction JSON or API project discovery\
**User provides:** Module name (e.g., "Products"), extraction JSON files or FlexBase API project\
**User says:** "Generate Blazor pages for the Products module"

**What gets generated:**

1. UI DTOs (list + detail with validation annotations)
2. REST client service with CRUD methods
3. DI registration
4. Edit dialog (view/edit/create modes)
5. List page (DataGrid with search, filter, CRUD)
6. Sidebar/navigation entry

### Task 11: Generate Angular UI from Extraction

**Goal:** Create Angular components and services from extraction JSON\
**User provides:** Module or entity name, extraction JSON, target Angular project

### Task 12: Generate React UI from Extraction

**Goal:** Create React components and hooks from extraction JSON\
**User provides:** Module or entity name, extraction JSON, target React project

### Task 13: Complete Entire Module (API + UI)

**Goal:** End-to-end implementation of a module — all domain models, handlers, queries, validations, DTOs, and UI\
**User provides:** Module name, all extraction JSON files, target UI framework

**Implementation order:**

1. Domain models → DTOs & mappers → Queries → Validations → Handlers → Subscribers → UI → Build & verify

***

## DataStore, AI & Email Provider Integration

These prompts add non-relational data store, AI, or email operations into FlexBase handlers, queries, subscribers, and validation plugins. Each provider follows the same pattern: inject the bridge interface, call the provider-specific operations, and let the MCP guide handle the rest.

> **Tip — Operation type for subscribers & validation plugins:** Handlers and queries have an explicit operation type (CREATE, UPDATE, GETPAGEDLIST, etc.). Subscribers and validation plugins **infer the operation from the class/event name** (e.g., `OnOrderCreated...` → Create). If the name is ambiguous, specify the operation explicitly in your prompt: *"...for **Update** operation using Document Store"*.

***

### Document Store (CosmosDB, MongoDB, DynamoDB, RavenDB)

Use when a feature needs to store, retrieve, or query JSON documents in a NoSQL database.

**Handler — Create/Update/Delete a document:**

```
Implement the [FeatureName] handler using Document Store for [Create|Update|Delete] operation on [DocumentType] documents
```

**Query — Retrieve documents:**

```
Implement the [FeatureName] query using Document Store to retrieve [DocumentType] documents with filtering and pagination
```

**Subscriber — React to events with document operations:**

```
Implement the [EventName] subscriber using Document Store to [create|update|delete] [DocumentType] documents after the event
```

**Validation Plugin — Validate against document data:**

```
Implement the [FeatureName] validation plugin to check [business rule] against Document Store before [Create|Update]
```

***

### Vector Store (PgVector, Azure AI Search, OpenSearch, Qdrant, Pinecone)

Use when a feature needs similarity search, semantic search, or embedding storage.

**Handler — Store embeddings:**

```
Implement the [FeatureName] handler using Vector Store to generate and store embeddings for [EntityType] content
```

**Query — Similarity search:**

```
Implement the [FeatureName] query using Vector Store to find similar [items/documents] based on a search query with optional filters
```

**Subscriber — Auto-index on changes:**

```
Implement the [EventName] subscriber using Vector Store to update the vector index when [EntityType] is [created|updated|deleted]
```

***

### Graph Store (Neo4j, Apache AGE, Amazon Neptune)

Use when a feature needs relationship traversal, path finding, or connected data queries.

**Handler — Create graph nodes and relationships:**

```
Implement the [FeatureName] handler using Graph Store to create [NodeType] nodes and [RelationshipType] relationships
```

**Query — Traverse relationships:**

```
Implement the [FeatureName] query using Graph Store to find [connections|paths|recommendations] between [NodeType] entities
```

**Subscriber — Maintain graph on entity changes:**

```
Implement the [EventName] subscriber using Graph Store to update graph nodes/relationships when [EntityType] changes
```

***

### Search Store (Elasticsearch, Azure AI Search, Algolia)

Use when a feature needs full-text search, faceted search, or search indexing.

**Handler — Index content:**

```
Implement the [FeatureName] handler using Search Store to index [EntityType] documents for full-text search
```

**Query — Full-text search:**

```
Implement the [FeatureName] query using Search Store to search [EntityType] with full-text, facets, and filters
```

**Subscriber — Auto-index on changes:**

```
Implement the [EventName] subscriber using Search Store to update the search index when [EntityType] is [created|updated|deleted]
```

***

### File Store (Azure Blob, AWS S3, GCP Storage)

Use when a feature needs to upload, download, or manage files in cloud storage.

**Handler — Upload/manage files:**

```
Implement the [FeatureName] handler using File Store to [upload|download|delete] files in [container/bucket] organized by [path strategy]
```

**Query — List/check files:**

```
Implement the [FeatureName] query using File Store to list files in [container] with prefix filtering
```

**Subscriber — Process files after events:**

```
Implement the [EventName] subscriber using File Store to [archive|copy|generate] files when [EntityType] is [created|approved|completed]
```

***

### Time Series Store (TimescaleDB, InfluxDB, Azure Data Explorer)

Use when a feature needs to store or query time-stamped measurements, metrics, or IoT data.

**Handler — Write data points:**

```
Implement the [FeatureName] handler using Time Series Store to write [metric/measurement] data points with tags and timestamp
```

**Query — Aggregate time series data:**

```
Implement the [FeatureName] query using Time Series Store to aggregate [metric] over [time range] grouped by [interval] with optional tag filters
```

**Subscriber — Record metrics on events:**

```
Implement the [EventName] subscriber using Time Series Store to record a [metric] data point when [EntityType] is [created|updated|state-changed]
```

***

### Cache Store (Redis, Memcached, NCache)

Use when a feature needs caching, session storage, or fast key-value lookups.

**Handler — Cache management:**

```
Implement the [FeatureName] handler using Cache Store to [set|invalidate] cache entries for [EntityType] with [duration] TTL
```

**Query — Cache-aside pattern:**

```
Implement the [FeatureName] query using Cache Store with cache-aside pattern — check cache first, fall back to database, then cache the result
```

**Subscriber — Invalidate cache on changes:**

```
Implement the [EventName] subscriber using Cache Store to invalidate cached [EntityType] entries when the entity is [updated|deleted]
```

***

### AI Provider (Azure OpenAI, OpenAI, Anthropic, Gemini, Ollama)

Use when a feature needs chat completions, content generation, classification, embeddings, or streaming AI responses.

**Handler — AI-powered operations:**

```
Implement the [FeatureName] handler using AI Provider to [generate|classify|summarize|extract] [content type] from [input]
```

**Handler — Structured output (typed response):**

```
Implement the [FeatureName] handler using AI Provider with structured output to return a typed [ResponseType] from the AI response
```

**Handler — Streaming response:**

```
Implement the [FeatureName] handler using AI Provider with streaming to send incremental AI responses for [use case]
```

**Query — AI-assisted search (RAG pattern):**

```
Implement the [FeatureName] query using AI Provider + Vector Store for RAG — embed the question, search for context, then generate an answer
```

**Handler — Generate embeddings:**

```
Implement the [FeatureName] handler using AI Provider to generate embeddings for [content] and store them in Vector Store
```

**Subscriber — AI processing after events:**

```
Implement the [EventName] subscriber using AI Provider to [classify|summarize|tag] [EntityType] content when it is [created|updated]
```

**Validation Plugin — AI-assisted validation:**

```
Implement the [FeatureName] validation plugin using AI Provider to check [content quality|appropriateness|classification] before [Create|Update]
```

***

### Email Provider (SMTP, SendGrid, AWS SES, Azure Communication Services)

Use when a feature needs to send emails — notifications, confirmations, alerts, or bulk communications.

**Handler — Send email directly:**

```
Implement the [FeatureName] handler using Email Provider to send a [notification|confirmation|alert] email to [recipient] after [action]
```

**Handler — Send HTML email with attachments:**

```
Implement the [FeatureName] handler using Email Provider to send an HTML email with [attachments/inline images] for [use case]
```

**Handler — Send templated email:**

```
Implement the [FeatureName] handler using Email Provider to send a templated email using template [templateId] with dynamic data for [use case]
```

**Handler — Bulk email:**

```
Implement the [FeatureName] handler using Email Provider to send bulk emails to [recipient list] for [use case — e.g., newsletter, announcements]
```

**PostBus Plugin — Send email after handler completes:**

```
Implement a PostBus plugin for [FeatureName] using Email Provider to send a [notification|confirmation] email after the handler succeeds
```

**Subscriber — Send email on event:**

```
Implement the [EventName] subscriber using Email Provider to send a [welcome|confirmation|alert] email when [EntityType] is [created|approved|cancelled]
```

**Validation Plugin — Validate email before sending:**

```
Implement the [FeatureName] validation plugin using Email Provider to validate email format and deliverability before [Create|Update]
```

***

### Configuration Notes

All DataStore and Provider integrations follow the same pattern:

* **Registration:** Each provider is registered in `Program.cs` / startup using FlexBase's `AddFlex[ProviderType]()` extension methods
* **Environment-specific:** Use Console/InMemory providers for development, real providers for production
* **Bridge interfaces:** Inject the bridge interface (not the raw provider) in handlers, queries, subscribers, and plugins
* **Multiple instances:** Use keyed registration when you need multiple instances of the same provider type (e.g., two different AI models)

***

## Unit Testing (xUnit, NUnit, MSTest)

FlexBase supports **3 test frameworks** across **4 test projects**. The MCP guides detect which framework to use from the existing `.csproj` or from the user's prompt.

### Feature-Level Tests (All 4 Projects)

```
Write unit tests for the [FeatureName] feature in the [ModuleName] module using [xUnit | NUnit | MSTest]. Identify ALL components (domain model, mappers, handlers, validation plugins, queries, subscribers) and generate tests across all 4 test projects per FlexBase_UnitTest_Implementation_Guide.
```

### Module-Level Tests (All Features)

```
Write unit tests for ALL features in the [ModuleName] module using [xUnit | NUnit | MSTest]. For each feature, identify every component and generate tests across all 4 test projects per FlexBase_UnitTest_Implementation_Guide.
```

### DomainModels.Tests — Model & Mapper Tests

```
Write ALL DomainModels.Tests for [FeatureName] using [xUnit | NUnit | MSTest]: domain model tests (defaults, properties) + Create/Update/Delete mapper tests per FlexBase_UnitTest_Implementation_Guide.
```

### Handlers.Tests — Handler, Subscriber & PostBus Tests

```
Write ALL handler tests for [FeatureName] in Handlers.Tests using [xUnit | NUnit | MSTest]: Create, Update, Delete handlers. Mock IRepoFactory, test happy path, event firing, and error scenarios per FlexBase_UnitTest_Implementation_Guide.
```

### PreBus.Tests — Validation Plugin Tests

```
Write ALL validation plugin tests for [FeatureName] in PreBus.Tests using [xUnit | NUnit | MSTest]: Create and Update validation plugins. Test required fields, format validations, and boundary values per FlexBase_UnitTest_Implementation_Guide.
```

### Queries.Tests — Query Tests with DB Strategy

```
Write ALL query tests for [FeatureName] in Queries.Tests using [xUnit | NUnit | MSTest] with [InMemory EF Core | SQLite | Docker SQL Server | Docker PostgreSQL | Podman]: GetById, GetAll, filtered, paged queries per FlexBase_UnitTest_Implementation_Guide.
```

### Test Data Infrastructure

```
Create a test data builder for [FeatureName] entity with fluent API. Include sensible defaults, With*() methods, Build() and BuildAndSeed(IRepoFactory). Also create DTO builders per FlexBase_UnitTest_TestData_Infrastructure_Guide.
```

### DataStore/Provider Feature Tests

```
Write unit tests for [FeatureName] feature using [Document Store | Cache Store | AI Provider | Email Provider | Vector Store] using [xUnit | NUnit | MSTest]. Mock the provider bridge interface per FlexBase_UnitTest_Implementation_Guide.
```

***

## Related

* **API patterns:** [FlexBase API Patterns](/flexbase-mcp-ai-prompts/flexbase-api-guide-prompts.md)
* **Blazor patterns:** [Blazor FluentUI](/flexbase-mcp-ai-prompts/blazor-fluent-ui-guide-prompts.md)
* **Angular patterns:** [Angular UI](/flexbase-mcp-ai-prompts/angular-ui-guide-prompts.md)
* **React patterns:** [React UI](/flexbase-mcp-ai-prompts/react-js-ui-guide-prompts.md)
