# 20260503175906_FinalNormalizedSubscriptionArchitecture.Designer

- File ID: file:1xzhi6b:20260503175906-finalnormalizedsubscriptionarchit
- Path: NexusReader.Data/Migrations/20260503175906_FinalNormalizedSubscriptionArchitecture.Designer.cs
- Role: database-config
- Layer: data

## Purpose

EF Core migration designer that defines the target EF model for the AppDbContext: configures entities, relationships, indices, Postgres/vector extensions and includes seed data for subscription plans.

## Key Details

Migration snapshot configures Postgres vector extension and embedding columns (vector(768)/vector(1536)), defines identity and domain entities with indices and FKs, and inserts four SubscriptionPlan seed rows (Free, Basic, Pro, Enterprise).

## Symbols

- FinalNormalizedSubscriptionArchitecture: EF Core migration designer that defines the target EF model for the AppDbContext: configures entities, relationships, indices, Postgres/vector extensions and includes seed data for subscription plans.
- BuildTargetModel(): Populates the EF Core ModelBuilder with entity types, columns, keys, indices, relationships, Postgres/vector extensions and seed data for this migration snapshot.
- Microsoft.AspNetCore.Identity.IdentityRole: Identity role mapping configured in the EF model for AspNetRoles table
- NexusReader.Domain.Entities.Ebook: Domain entity configuration for ebooks table
- NexusReader.Domain.Entities.KnowledgeUnit: Vectorized knowledge unit used for semantic search and storage
- NexusReader.Domain.Entities.KnowledgeUnitLink: Represents directional links between knowledge units
- NexusReader.Domain.Entities.NexusUser: Application user mapped to AspNetUsers with subscription and tenant info
- NexusReader.Domain.Entities.SemanticKnowledgeCache: Cached semantic results with embedding vector and prompt/model metadata
- NexusReader.Domain.Entities.SubscriptionPlan: Subscription plan catalog with token limits, price and Stripe product id; seeded by migration
- NexusReader.Domain.Entities.QuizResult: User quiz result entries with score and topic

## Dependencies

- imports NexusReader.Data/Persistence/AppDbContext.cs
- imports NexusReader.Domain/Entities/Ebook.cs
- imports NexusReader.Domain/Entities/KnowledgeUnit.cs
- imports NexusReader.Domain/Entities/KnowledgeUnitLink.cs
- imports NexusReader.Domain/Entities/NexusUser.cs
- imports NexusReader.Domain/Entities/SemanticKnowledgeCache.cs
- imports NexusReader.Domain/Entities/SubscriptionPlan.cs
- imports NexusReader.Domain/Entities/QuizResult.cs

## Calls

- No resolved calls.

## Unresolved References

- interaction-target: NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "vector")
- interaction-target: NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder)

## Coverage

- Symbols: 10
- Executable symbols: 1
- Executable symbols with control flow: 1
- Grounded edges: 18
- Unresolved references: 2
- Control-flow fragments: 1
- Unresolved jumps: 0
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 2

## Control Flow Fragments

- BuildTargetModel: 15 nodes, 14 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### 20260503175906_FinalNormalizedSubscriptionArchitecture.Designer Neighborhood

_Warnings: diagram file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit_neighborhood_view exceeds preferred complexity thresholds (19 nodes, 8 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart LR
    class_zj074q_finalnormalizedsubscriptionarchitecture("FinalNormalizedSubscriptionArchitecture")
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit("20260503175906_FinalNormalizedSubscriptionArchitecture.Designer")
    method_tz9mq3_buildtargetmodel[["BuildTargetModel()"]]
    file_1b03oou_subscriptionplan_cs[/"SubscriptionPlan"/]
    file_1d4ycw2_semanticknowledgecache_cs[/"SemanticKnowledgeCache"/]
    file_1m6x5qy_knowledgeunitlink_cs[/"KnowledgeUnitLink"/]
    file_1pacvtg_appdbcontext_cs[/"AppDbContext"/]
    file_1wyr0y8_quizresult_cs[/"QuizResult"/]
    file_h6a0xu_knowledgeunit_cs[/"KnowledgeUnit"/]
    file_lcvwj6_ebook_cs[/"Ebook"/]
    file_xcxh5w_nexususer_cs[/"NexusUser"/]
    type_13day2p_nexusreader_domain_entities_knowledgeunit[/"NexusReader.Domain.Entities.KnowledgeUnit"/]
    type_14w07kf_nexusreader_domain_entities_subscriptionplan[/"NexusReader.Domain.Entities.SubscriptionPlan"/]
    type_15ow7t1_nexusreader_domain_entities_nexususer[/"NexusReader.Domain.Entities.NexusUser"/]
    type_30kk08_nexusreader_domain_entities_semanticknowledgecac[/"NexusReader.Domain.Entities.SemanticKnowledgeCache"/]
    type_6xl8d4_nexusreader_domain_entities_quizresult[/"NexusReader.Domain.Entities.QuizResult"/]
    type_7ob3p3_nexusreader_domain_entities_ebook[/"NexusReader.Domain.Entities.Ebook"/]
    type_9y8b30_nexusreader_domain_entities_knowledgeunitlink[/"NexusReader.Domain.Entities.KnowledgeUnitLink"/]
    type_hhlqtu_microsoft_aspnetcore_identity_identityrole[/"Microsoft.AspNetCore.Identity.IdentityRole"/]
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|SubscriptionPlan| file_1b03oou_subscriptionplan_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|SemanticKnowledgeCache| file_1d4ycw2_semanticknowledgecache_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|KnowledgeUnitLink| file_1m6x5qy_knowledgeunitlink_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|AppDbContext| file_1pacvtg_appdbcontext_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|QuizResult| file_1wyr0y8_quizresult_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|KnowledgeUnit| file_h6a0xu_knowledgeunit_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|Ebook| file_lcvwj6_ebook_cs
    file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit -->|NexusUser| file_xcxh5w_nexususer_cs
```

### 20260503175906_FinalNormalizedSubscriptionArchitecture.Designer Execution Overview

```mermaid
flowchart TD
    class_zj074q_finalnormalizedsubscriptionarchitecture("FinalNormalizedSubscriptionArchitecture")
    method_tz9mq3_buildtargetmodel[["BuildTargetModel()"]]
    unresolved_unresolved_1meayaz_interaction_target{"Unresolved: NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, \\"vector\\")"}
    unresolved_unresolved_1x958ae_interaction_target{"Unresolved: NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder)"}
    class_zj074q_finalnormalizedsubscriptionarchitecture -->|contains| method_tz9mq3_buildtargetmodel
    class_zj074q_finalnormalizedsubscriptionarchitecture -->|unresolved interaction| unresolved_unresolved_1meayaz_interaction_target
    class_zj074q_finalnormalizedsubscriptionarchitecture -->|unresolved interaction| unresolved_unresolved_1x958ae_interaction_target
```

## Diagram Validation

- Status: warn
- Warning: neighborhood-view: diagram file_1xzhi6b_20260503175906_finalnormalizedsubscriptionarchit_neighborhood_view exceeds preferred complexity thresholds (19 nodes, 8 edges).
