|
| 1 | +# AI Enhancement Tutorial — Series 6 & 7 |
| 2 | + |
| 3 | +> Update the checklist below as each article is completed. |
| 4 | +
|
| 5 | +## Context |
| 6 | + |
| 7 | +The existing AngularNetTutorial (Series 0–5, 22 articles) covers the full CAT stack (Angular 20 + .NET 10 + Duende IdentityServer) but has zero AI content. Developers need practical, working examples of how to add AI to a real production-style app — not toy demos. |
| 8 | + |
| 9 | +**Decisions:** |
| 10 | +* **AI Provider:** Ollama (free, local, no API key required) via Microsoft.Extensions.AI abstraction |
| 11 | +* **Series 6** — AI App Features (AI capabilities for end users of the TalentManagement app) |
| 12 | +* **Series 7** — Developer Productivity AI (AI tools for building faster) |
| 13 | + |
| 14 | +**Why Ollama + Microsoft.Extensions.AI:** |
| 15 | +* Zero cost, no sign-up — tutorial readers can follow without a credit card |
| 16 | +* Microsoft.Extensions.AI is provider-agnostic: swap Ollama → Azure OpenAI → Anthropic by changing 1 line in DI registration |
| 17 | +* Aligned with .NET 10 ecosystem (official Microsoft abstraction) |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Coexistence Strategy: Feature Flags + Graceful Degradation |
| 22 | + |
| 23 | +The original tutorial (Series 0–5) and AI tutorial (Series 6–7) share **one codebase**. AI features default to **off** so developers without Ollama are unaffected. |
| 24 | + |
| 25 | +**`Microsoft.FeatureManagement` is already installed — no new dependencies needed.** |
| 26 | + |
| 27 | +**Backend (.NET) — appsettings.json default (AI off):** |
| 28 | +```json |
| 29 | +"FeatureManagement": { |
| 30 | + "AiEnabled": false |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +**Frontend (Angular) — environment.ts default (AI hidden):** |
| 35 | +```typescript |
| 36 | +export const environment = { |
| 37 | + aiEnabled: false, |
| 38 | + ... |
| 39 | +}; |
| 40 | +``` |
| 41 | + |
| 42 | +**Two audiences, one repo:** |
| 43 | +* **Original tutorial readers (no Ollama)** — `aiEnabled: false` everywhere, zero broken UI or failed API calls |
| 44 | +* **AI enhancement readers (have Ollama)** — follow Series 6 article 6.1: set `"AiEnabled": true`, AI features activate |
| 45 | + |
| 46 | +All Series 6 code merges into `develop` via feature branches. `AiEnabled` defaults to `false` so `develop` is safe for both audiences — no divergent AI branch needed. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Series 6: AI App Features |
| 51 | + |
| 52 | +**Folder:** `blogs/series-6-ai-app-features/` |
| 53 | +**Theme:** Add AI capabilities that HR managers and employees actually use |
| 54 | + |
| 55 | +* **6.1** — `6.1-dotnet-ai-foundation.md` — Run a Local LLM in Your .NET 10 API with Ollama |
| 56 | + * Code: `IChatClient` DI setup, `POST /api/v1/ai/chat` endpoint, feature flag setup |
| 57 | +* **6.2** — `6.2-dotnet-ai-hr-assistant.md` — Build an HR AI Assistant That Knows Your Data |
| 58 | + * Code: `GetHrInsightQuery` (MediatR), inject DashboardMetrics context into prompt |
| 59 | +* **6.3** — `6.3-angular-ai-chat-widget.md` — Add an AI Chat Widget to Angular with Streaming |
| 60 | + * Code: `AiChatComponent`, SSE streaming with RxJS |
| 61 | +* **6.4** — `6.4-angular-ai-dashboard-insights.md` — AI-Generated Dashboard Insights in Angular Material |
| 62 | + * Code: AI Insights `mat-card` on dashboard, prompt engineering patterns |
| 63 | +* **6.5** — `6.5-dotnet-natural-language-search.md` — Natural Language Employee Search with LLM Query Parsing |
| 64 | + * Code: `NlSearchQuery` handler (.NET) + NL search bar (Angular) |
| 65 | +* **6.6** — `6.6-dotnet-ai-response-caching.md` — Cache Your AI Responses: Save Time and API Costs |
| 66 | + * Code: EasyCaching cache-aside in `OllamaAiService`, `X-AI-Cache` response header |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Series 7: Developer Productivity AI |
| 71 | + |
| 72 | +**Folder:** `blogs/series-7-developer-productivity-ai/` |
| 73 | +**Theme:** AI tools that make the developer faster — applied to this exact codebase |
| 74 | + |
| 75 | +* **7.1** — `7.1-claude-code-workflow.md` — How We Built 22 Articles with Claude Code |
| 76 | + * Content: CLAUDE.md patterns, prompting guide, session workflow tips |
| 77 | +* **7.2** — `7.2-copilot-clean-architecture.md` — GitHub Copilot for .NET Clean Architecture |
| 78 | + * Content: Copilot prompt patterns for CQRS handlers, FluentValidation, Mapster |
| 79 | +* **7.3** — `7.3-ai-generated-playwright-tests.md` — Generate Playwright Tests from User Stories with AI |
| 80 | + * Content: Prompt-to-test workflow, AI-generated `.spec.ts` files, human review checklist |
| 81 | +* **7.4** — `7.4-ai-code-review-github-actions.md` — AI Code Review in GitHub Actions |
| 82 | + * Content + Code: GitHub Action YAML using Anthropic API for PR review |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Gitflow Branch Strategy |
| 87 | + |
| 88 | +**Branch naming:** `feature/[article-number]-[short-slug]` |
| 89 | +**Base branch:** always off `develop`, merge back via PR |
| 90 | + |
| 91 | +### Feature Branch Map |
| 92 | + |
| 93 | +* **6.1** — Parent: `feature/6.1-dotnet-ai-foundation` | ApiResources: `feature/6.1-dotnet-ai-foundation` |
| 94 | +* **6.2** — Parent: `feature/6.2-dotnet-ai-hr-assistant` | ApiResources: `feature/6.2-dotnet-ai-hr-assistant` |
| 95 | +* **6.3** — Parent: `feature/6.3-angular-ai-chat-widget` | Clients: `feature/6.3-angular-ai-chat-widget` |
| 96 | +* **6.4** — Parent: `feature/6.4-angular-ai-dashboard-insights` | Clients: `feature/6.4-angular-ai-dashboard-insights` |
| 97 | +* **6.5** — Parent: `feature/6.5-natural-language-search` | ApiResources + Clients: `feature/6.5-natural-language-search` |
| 98 | +* **6.6** — Parent: `feature/6.6-ai-response-caching` | ApiResources: `feature/6.6-ai-response-caching` |
| 99 | +* **7.1–7.4** — Parent only (blog articles, no submodule code changes) |
| 100 | + |
| 101 | +### Gitflow Steps Per Article (with submodule code) |
| 102 | + |
| 103 | +```bash |
| 104 | +# 1. Submodule feature branch (off develop) |
| 105 | +cd ApiResources/TalentManagement-API # or Clients/... |
| 106 | +git checkout develop && git pull |
| 107 | +git checkout -b feature/[N.N]-[slug] |
| 108 | + |
| 109 | +# 2. Parent repo feature branch (off develop) |
| 110 | +cd ../.. |
| 111 | +git checkout develop && git pull |
| 112 | +git checkout -b feature/[N.N]-[slug] |
| 113 | + |
| 114 | +# 3. Code in submodule → commit → push |
| 115 | +git add . && git commit -m "Add [feature]" |
| 116 | +git push --set-upstream origin feature/[N.N]-[slug] |
| 117 | + |
| 118 | +# 4. Blog article + submodule ref in parent → commit → push |
| 119 | +git add blogs/series-6-ai-app-features/[N.N]-*.md |
| 120 | +git add ApiResources/TalentManagement-API |
| 121 | +git commit -m "Add article [N.N] and [feature] implementation" |
| 122 | +git push --set-upstream origin feature/[N.N]-[slug] |
| 123 | + |
| 124 | +# 5. Open PRs: submodule feature → develop, then parent feature → develop |
| 125 | +``` |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +## Implementation Checklist |
| 130 | + |
| 131 | +### Phase 0: Setup |
| 132 | + |
| 133 | +- [x] Ollama running at `http://localhost:11434` ✅ |
| 134 | +- [x] `blogs/AI-ENHANCEMENT-SERIES-PLAN.md` created ✅ |
| 135 | +- [ ] Create `blogs/series-6-ai-app-features/` folder |
| 136 | +- [ ] Create `blogs/series-7-developer-productivity-ai/` folder |
| 137 | +- [ ] Create `docs/images/ai/` folder for screenshots |
| 138 | +- [ ] Update `blogs/BLOG-SERIES-PLAN.md` with Series 6 & 7 entries |
| 139 | +- [ ] Update `blogs/SERIES-NAVIGATION-TOC.md` to include new series |
| 140 | + |
| 141 | +### Phase 1: Series 6 — Backend Foundation |
| 142 | + |
| 143 | +- [ ] **6.1 — .NET AI Foundation** |
| 144 | + - [ ] `git checkout -b feature/6.1-dotnet-ai-foundation` in ApiResources submodule |
| 145 | + - [ ] `git checkout -b feature/6.1-dotnet-ai-foundation` in parent repo |
| 146 | + - [ ] Write article draft (`6.1-dotnet-ai-foundation.md`) |
| 147 | + - [ ] Add to WebApi.csproj: `Microsoft.Extensions.AI`, `Microsoft.Extensions.AI.Ollama` |
| 148 | + - [ ] Add `"FeatureManagement": { "AiEnabled": false }` to `appsettings.json` |
| 149 | + - [ ] Add `aiEnabled: false` to `environment.ts` |
| 150 | + - [ ] Create `Application/Interfaces/IAiChatService.cs` |
| 151 | + - [ ] Create `Infrastructure.Shared/Services/OllamaAiService.cs` |
| 152 | + - [ ] Create `WebApi/Controllers/v1/AiController.cs` with `[FeatureGate("AiEnabled")]` |
| 153 | + - [ ] Screenshot: Swagger AI endpoint → `docs/images/ai/` |
| 154 | + - [ ] Commit + push submodule feature branch |
| 155 | + - [ ] Commit + push parent feature branch (blog + submodule ref) |
| 156 | + - [ ] Open PR: ApiResources `feature/6.1-dotnet-ai-foundation` → `develop` |
| 157 | + - [ ] Open PR: Parent `feature/6.1-dotnet-ai-foundation` → `develop` |
| 158 | + |
| 159 | +- [ ] **6.2 — HR AI Assistant (data-aware)** |
| 160 | + - [ ] `git checkout -b feature/6.2-dotnet-ai-hr-assistant` in ApiResources submodule |
| 161 | + - [ ] `git checkout -b feature/6.2-dotnet-ai-hr-assistant` in parent repo |
| 162 | + - [ ] Write article draft (`6.2-dotnet-ai-hr-assistant.md`) |
| 163 | + - [ ] Create `Application/Features/AI/Queries/GetHrInsightQuery.cs` (MediatR) |
| 164 | + - [ ] Inject DashboardMetrics context into prompt |
| 165 | + - [ ] Screenshot: AI answer about employee data → `docs/images/ai/` |
| 166 | + - [ ] Commit + push submodule feature branch |
| 167 | + - [ ] Commit + push parent feature branch |
| 168 | + - [ ] Open PR: ApiResources `feature/6.2-dotnet-ai-hr-assistant` → `develop` |
| 169 | + - [ ] Open PR: Parent `feature/6.2-dotnet-ai-hr-assistant` → `develop` |
| 170 | + |
| 171 | +### Phase 2: Series 6 — Angular Frontend |
| 172 | + |
| 173 | +- [ ] **6.3 — Angular AI Chat Widget** |
| 174 | + - [ ] `git checkout -b feature/6.3-angular-ai-chat-widget` in Clients submodule |
| 175 | + - [ ] `git checkout -b feature/6.3-angular-ai-chat-widget` in parent repo |
| 176 | + - [ ] Write article draft (`6.3-angular-ai-chat-widget.md`) |
| 177 | + - [ ] Create `src/app/services/api/ai.service.ts` |
| 178 | + - [ ] Create `src/app/routes/ai-chat/` (component + template + SCSS) |
| 179 | + - [ ] Implement SSE streaming with `HttpClient` + `EventSource` |
| 180 | + - [ ] Add to sidebar navigation (guarded by `environment.aiEnabled`) |
| 181 | + - [ ] Screenshot: Chat widget in Angular UI → `docs/images/ai/` |
| 182 | + - [ ] Commit + push Clients feature branch |
| 183 | + - [ ] Commit + push parent feature branch |
| 184 | + - [ ] Open PR: Clients `feature/6.3-angular-ai-chat-widget` → `develop` |
| 185 | + - [ ] Open PR: Parent `feature/6.3-angular-ai-chat-widget` → `develop` |
| 186 | + |
| 187 | +- [ ] **6.4 — AI Dashboard Insights** |
| 188 | + - [ ] `git checkout -b feature/6.4-angular-ai-dashboard-insights` in Clients submodule |
| 189 | + - [ ] `git checkout -b feature/6.4-angular-ai-dashboard-insights` in parent repo |
| 190 | + - [ ] Write article draft (`6.4-angular-ai-dashboard-insights.md`) |
| 191 | + - [ ] Modify `dashboard.ts` — add AI insights call after metrics load |
| 192 | + - [ ] Add "AI Insights" `mat-card` to `dashboard.html` (guarded by `aiEnabled`) |
| 193 | + - [ ] Screenshot: Dashboard with AI insights card → `docs/images/ai/` |
| 194 | + - [ ] Commit + push Clients feature branch |
| 195 | + - [ ] Commit + push parent feature branch |
| 196 | + - [ ] Open PR: Clients `feature/6.4-angular-ai-dashboard-insights` → `develop` |
| 197 | + - [ ] Open PR: Parent `feature/6.4-angular-ai-dashboard-insights` → `develop` |
| 198 | + |
| 199 | +### Phase 3: Series 6 — Advanced |
| 200 | + |
| 201 | +- [ ] **6.5 — Natural Language Search** |
| 202 | + - [ ] `git checkout -b feature/6.5-natural-language-search` in ApiResources + Clients + parent |
| 203 | + - [ ] Write article draft (`6.5-dotnet-natural-language-search.md`) |
| 204 | + - [ ] .NET: Create `NlSearchQuery` MediatR handler (LLM → structured filter) |
| 205 | + - [ ] Angular: Add NL search bar above employee table |
| 206 | + - [ ] Screenshot: NL query → filtered employee list → `docs/images/ai/` |
| 207 | + - [ ] Commit + push all feature branches |
| 208 | + - [ ] Open PRs: ApiResources + Clients + Parent → `develop` |
| 209 | + |
| 210 | +- [ ] **6.6 — AI Response Caching** |
| 211 | + - [ ] `git checkout -b feature/6.6-ai-response-caching` in ApiResources submodule + parent |
| 212 | + - [ ] Write article draft (`6.6-dotnet-ai-response-caching.md`) |
| 213 | + - [ ] .NET: Add EasyCaching cache-aside to `OllamaAiService` |
| 214 | + - [ ] Add `X-AI-Cache: HIT/MISS` response header |
| 215 | + - [ ] Screenshot: Swagger response headers showing cache → `docs/images/ai/` |
| 216 | + - [ ] Commit + push feature branches |
| 217 | + - [ ] Open PRs: ApiResources + Parent → `develop` |
| 218 | + |
| 219 | +### Phase 4: Series 7 — Developer Productivity (parent repo only) |
| 220 | + |
| 221 | +- [ ] **7.1 — Claude Code Workflow** |
| 222 | + - [ ] `git checkout -b feature/7.1-claude-code-workflow` in parent repo |
| 223 | + - [ ] Write article: CLAUDE.md patterns, prompting, session workflow |
| 224 | + - [ ] Commit + push → Open PR → `develop` |
| 225 | + |
| 226 | +- [ ] **7.2 — Copilot for Clean Architecture** |
| 227 | + - [ ] `git checkout -b feature/7.2-copilot-clean-architecture` in parent repo |
| 228 | + - [ ] Write article: Copilot prompt patterns for CQRS, FluentValidation |
| 229 | + - [ ] Commit + push → Open PR → `develop` |
| 230 | + |
| 231 | +- [ ] **7.3 — AI-Generated Playwright Tests** |
| 232 | + - [ ] `git checkout -b feature/7.3-ai-generated-playwright-tests` in parent repo |
| 233 | + - [ ] Write article: prompt-to-test workflow, human review checklist |
| 234 | + - [ ] Commit + push → Open PR → `develop` |
| 235 | + |
| 236 | +- [ ] **7.4 — AI Code Review in GitHub Actions** |
| 237 | + - [ ] `git checkout -b feature/7.4-ai-code-review-ci` in parent repo |
| 238 | + - [ ] Write article + GitHub Action YAML using Anthropic API |
| 239 | + - [ ] Commit + push → Open PR → `develop` |
| 240 | + |
| 241 | +--- |
| 242 | + |
| 243 | +## Writing Order |
| 244 | + |
| 245 | +1. 6.1 — backend AI foundation (everything else depends on this) |
| 246 | +2. 6.2 — HR assistant (builds on 6.1) |
| 247 | +3. 6.3 — Angular chat widget (needs 6.1 endpoint) |
| 248 | +4. 6.4 — dashboard insights (builds on 6.2 + existing dashboard) |
| 249 | +5. 6.5 — NL search (builds on 6.1 + existing employee list) |
| 250 | +6. 6.6 — AI caching (builds on 6.1 + EasyCaching from article 2.5) |
| 251 | +7. 7.1–7.4 — independent, any order |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +## Ollama Setup Reference |
| 256 | + |
| 257 | +```bash |
| 258 | +ollama pull llama3.2 # 2GB, fast for tutorials |
| 259 | +ollama serve # http://localhost:11434 |
| 260 | +``` |
| 261 | + |
| 262 | +> **✅ Confirmed:** Ollama is running at `http://localhost:11434` in the dev environment. |
| 263 | +
|
| 264 | +--- |
| 265 | + |
| 266 | +## Verification (each Series 6 article) |
| 267 | + |
| 268 | +1. Start all 3 services + `ollama serve` |
| 269 | +2. Set `"AiEnabled": true` in `appsettings.json` and `aiEnabled: true` in `environment.ts` |
| 270 | +3. Navigate to the feature in Angular (`http://localhost:4200`) |
| 271 | +4. Confirm AI responds correctly |
| 272 | +5. Verify Swagger endpoint behavior |
| 273 | +6. Reset `AiEnabled` to `false` — confirm original tutorial still works perfectly |
| 274 | +7. Run Playwright tests — ensure no regressions |
0 commit comments