Before starting any work, read and internalize these skill files. Apply their patterns, checklists, and frameworks throughout the review:
/mnt/skills/user/senior-architect/SKILL.md
/mnt/skills/user/senior-data-engineer/SKILL.md
/mnt/skills/user/senior-backend/SKILL.md
/mnt/skills/user/code-reviewer/SKILL.md
/mnt/skills/user/senior-fullstack/SKILL.md
- Treat me as a senior developer. Direct answers, no preamble or basic explanations.
- Show multiple approaches with tradeoffs; lead with the production-ready solution.
- No hedging. No unnecessary caveats.
- Use BMAD methodology for breaking down deliverables into epics → stories.
- Use functional programming style where applicable.
- Prefer dynamic verification over hard-coded values.
- When providing code: break into logical sections with approach comments, then provide comprehensive implementation combining all components.
- When making changes to documents: regenerate the full updated version, not partial diffs.
- Use file-based state management (TASKS.md, PROGRESS.md) for session continuity.
Before executing any work, complete these steps in order:
- Read the entire codebase relevant to this pipeline (extraction, DB, dashboard layers).
- Generate a Phased Execution Plan as a markdown document (
/docs/architecture-review/PLAN.md) outlining:- What you will do in each phase
- What agents will handle which workstreams
- Estimated scope/complexity per phase
- Dependencies between phases
- Risks or assumptions you're making
- Ask me any questions you have before proceeding. This includes:
- Ambiguities about the SharePoint file structure or naming conventions
- Unclear deal stage mappings or folder hierarchy
- Which Excel templates are in active use vs. legacy
- Whether certain integrations (Graph API, Azure Functions, etc.) are already partially set up
- Authentication method currently used for SharePoint access
- Any files or directories you can't locate but expect to exist
- Priorities or constraints I haven't stated
- Wait for my answers before moving to execution.
- Only after I confirm the plan, begin executing phase by phase.
System: B&R Capital Dashboard — real estate underwriting data extraction and analytics platform.
Pipeline: SharePoint Excel files → Python extraction/monitoring service → PostgreSQL → Dash/FastAPI dashboard (with React/TypeScript/Vite frontend in progress).
Stack:
- Python 3.12, conda environment
- PostgreSQL on port 5433 (Windows-side, accessed from WSL2 via dynamic host resolution)
- SQLAlchemy 2.0 async
- FastAPI backend
- Dash frontend (migrating to React/TypeScript/Vite)
- WSL2 Ubuntu development environment
Key Projects/Repos:
dashboard_interface_project— primary dashboardmf_market_ranking— market ranking model (separate but related)
Data Sources: SharePoint-hosted Excel workbooks containing deal underwriting data, property financials, and portfolio metrics. Files are organized by deal stage folders.
Read the following in order, building a complete mental model. At each step, write findings to /docs/architecture-review/discovery/.
- Read CLAUDE.md, README, and any configuration files
- Map the directory structure and module boundaries
- Identify entry points, scripts, and scheduled jobs
- Document:
01-project-structure.md
- Identify the extraction/monitoring service (entry point, scheduling, file detection logic)
- Map how SharePoint files are accessed (API, SDK, direct path, credentials)
- Document file detection: polling vs. event-driven, frequency, filtering
- Document:
02-extraction-layer.md
- Read all migration files, SQLAlchemy models, and raw SQL
- Map every table, relationship, constraint, index
- Identify: orphaned tables, missing indexes, denormalization patterns
- Document:
03-database-schema.md
- Trace how Excel columns map to database columns
- Identify all transformation logic (type casting, normalization, calculated fields)
- Find: hardcoded mappings, magic strings, implicit assumptions
- Document:
04-etl-mapping.md
- Map all Dash callbacks, FastAPI endpoints, and data queries
- Identify: N+1 queries, unoptimized joins, missing pagination
- Document:
05-dashboard-api.md
- Inventory all existing tests (unit, integration, e2e)
- Map error handling: try/except coverage, logging, alerting, failure modes
- Identify: silent failures, bare excepts, unhandled edge cases
- Document:
06-testing-errors.md
Produce a single summary document that includes:
- Architecture diagram (mermaid) of current state
- Data flow diagram (mermaid) from SharePoint → DB → Dashboard
- Critical findings and risk areas
- Document:
07-discovery-summary.md
Use Claude Agent Teams (via claude-flow or tmux-based orchestration) with the following team structure:
team:
coordinator:
role: "Architecture Review Coordinator"
responsibilities:
- Merge outputs from all workstream agents
- Resolve cross-cutting concerns and conflicts
- Maintain TASKS.md and PROGRESS.md at project root
- Produce final unified deliverables
- Ensure consistency across workstream recommendations
context:
- All Phase 1 discovery documents
- This prompt file
- Project CLAUDE.md
agents:
- name: "architect-agent"
role: "Senior Architect — General Improvements (WS1)"
skills:
- /mnt/skills/user/senior-architect/SKILL.md
- /mnt/skills/user/code-reviewer/SKILL.md
focus: "Architecture quality, code health, performance, observability"
output_dir: "/docs/architecture-review/ws1-improvements/"
- name: "data-engineer-agent"
role: "Senior Data Engineer — Extraction Automation & Data Integrity (WS2 + WS4)"
skills:
- /mnt/skills/user/senior-data-engineer/SKILL.md
- /mnt/skills/user/senior-backend/SKILL.md
focus: "Event-driven extraction pipeline, data validation, mapping integrity"
output_dir: "/docs/architecture-review/ws2-extraction-automation/"
output_dir_secondary: "/docs/architecture-review/ws4-data-integrity/"
- name: "backend-agent"
role: "Senior Backend Engineer — Deal Stage Sync (WS3)"
skills:
- /mnt/skills/user/senior-backend/SKILL.md
- /mnt/skills/user/senior-data-engineer/SKILL.md
focus: "SharePoint folder sync, deal stage propagation, state management"
output_dir: "/docs/architecture-review/ws3-deal-stage-sync/"Coordination Protocol:
- Coordinator distributes Phase 1 discovery docs to all agents as shared context.
- Each agent works independently within their workstream scope.
- Agents write findings and recommendations to their designated output directories.
- If an agent identifies a cross-cutting concern (e.g., a schema change that affects multiple workstreams), it logs it to
/docs/architecture-review/cross-cutting-concerns.mdfor the coordinator to resolve. - Coordinator merges all outputs into a unified plan after agents complete.
Review and recommend improvements across the entire pipeline.
- Evaluate separation of concerns between extraction, ETL, API, and presentation layers
- Assess async patterns: connection pooling, session management, task queuing
- Review dependency injection and service boundaries
- Check for circular imports, god modules, tight coupling
- Run code-reviewer skill analysis across the codebase
- Audit: type hints coverage, docstrings, dead code, unused imports
- Check error handling: bare excepts, swallowed errors, missing context in logs
- Evaluate: naming conventions, module organization, DRY violations
- Identify slow queries (missing indexes, full table scans, N+1 patterns)
- Evaluate caching strategy (or lack thereof)
- Check connection pool configuration and resource cleanup
- Review pagination in API and dashboard
- Recommend structured logging (JSON, correlation IDs)
- Design health check endpoints for each service layer
- Propose alerting rules: extraction failures, stale data, schema drift
- Recommend monitoring stack (lightweight — not over-engineered)
ws1-current-state.md— What exists nowws1-gap-analysis.md— What's missing or brokenws1-recommendations.md— Prioritized P0/P1/P2 improvementsws1-implementation-plan.md— BMAD epics → stories
Design and plan an event-driven extraction pipeline that triggers when SharePoint files are created, modified, or deleted.
Compare these approaches with explicit tradeoffs:
| Approach | Mechanism | Pros | Cons |
|---|---|---|---|
| A: Graph API Webhooks | Microsoft Graph subscriptions with change notifications | Real-time, push-based, no polling overhead | Requires public endpoint or relay, subscription renewal, webhook validation |
| B: Graph API Delta Queries | Polling delta endpoint for incremental changes | Simpler auth, no public endpoint needed, works behind NAT | Polling latency, must manage delta tokens, heavier on API quota |
| C: Hybrid | Webhooks for real-time + delta polling as fallback/reconciliation | Best of both, self-healing | More complex, two code paths |
- File change detection → event queue → extraction worker → validation → DB upsert
- Handle: file locking (Excel files open in browser), partial uploads, concurrent edits
- Retry logic with exponential backoff and dead-letter queue
- Idempotent upserts (no duplicate records from re-processing)
- Consider worker implementation: Celery, asyncio task queue, or lightweight event loop
- Evaluate: Azure AD app registration, certificate-based auth, managed identity
- Credential storage: environment variables, Azure Key Vault, or secrets manager
- Token refresh handling
ws2-current-state.md— How extraction works todayws2-gap-analysis.md— What breaks, what's manual, what's fragilews2-architecture-proposal.md— Proposed pipeline with mermaid diagramsws2-recommendations.md— Prioritized P0/P1/P2ws2-implementation-plan.md— BMAD epics → stories
When a deal moves to a different stage folder in SharePoint, detect that change and propagate it to the database (and optionally vice versa).
- Map the current SharePoint folder hierarchy to deal stages in the DB
- Document the expected folder names and their corresponding
deal_stagevalues - Handle: non-standard folder names, nested structures, legacy folders
- Detect file moves between folders (Graph API: driveItem moves change
parentReference) - Detect folder renames (stage name changes)
- Handle bulk operations (multiple files moved simultaneously)
- Handle deletions (deal removed from SharePoint — archive vs. delete in DB?)
Evaluate with explicit tradeoffs:
| Direction | Description | Pros | Cons |
|---|---|---|---|
| SharePoint → DB (unidirectional) | SP is source of truth; DB reflects SP state | Simple, single source of truth, no conflict resolution | Dashboard can't drive stage changes |
| DB → SharePoint (reverse) | Dashboard drives stage changes, reflected back to SP | Power users can manage via dashboard | Requires Graph API write permissions, conflict risk |
| Bidirectional | Either side can initiate changes | Maximum flexibility | Complex conflict resolution, race conditions, audit trail critical |
- Track sync state: last known folder per deal, sync timestamps
- Conflict resolution strategy (last-write-wins, manual review queue, etc.)
- Audit trail: log every stage change with timestamp, source, previous value
ws3-current-state.md— How deal stages are managed todayws3-folder-mapping.md— SharePoint folder → DB stage mapping tablews3-gap-analysis.md— What's missing, what breaksws3-architecture-proposal.md— Proposed sync design with mermaid diagramsws3-recommendations.md— Prioritized P0/P1/P2ws3-implementation-plan.md— BMAD epics → stories
Ensure every field in the source Excel templates is correctly extracted, transformed, and stored in the database — with no silent drops, truncation, or type coercion errors.
- Inventory every column in every active Excel template
- Map each column to its corresponding DB column (or document that it's unmapped)
- Produce a mapping manifest:
Excel Column → Transform → DB Column → Dashboard Field - Flag: columns that exist in Excel but not DB, columns in DB with no Excel source
- Type validation: ensure Excel types (dates, currencies, percentages) map correctly to PG types
- Null handling: identify which fields allow nulls, which have defaults, which silently drop
- Truncation: check varchar lengths vs. actual data lengths
- Precision: verify decimal/float precision for financial calculations
- Encoding: check for Unicode issues, special characters in property names/addresses
- Row-level validation: checksums, field-count assertions, required-field checks
- Batch-level validation: before/after record counts, sum-of-amounts reconciliation
- Schema drift detection: alert when Excel template structure changes
- Propose a validation framework (pydantic models, pandera, great_expectations, or custom)
- Design a reconciliation report: what was extracted vs. what's in the DB
- Dashboard widget or standalone report showing data freshness and completeness
- Alerting: email/Slack notification when records fail validation or counts drift
ws4-current-state.md— Current mapping and validation coveragews4-mapping-manifest.md— Complete Excel → DB → Dashboard field mapws4-gap-analysis.md— Missing fields, broken mappings, silent failuresws4-validation-framework.md— Proposed validation architecturews4-recommendations.md— Prioritized P0/P1/P2ws4-implementation-plan.md— BMAD epics → stories
After all agents complete, the coordinator produces:
-
EXECUTIVE-SUMMARY.md- 1-page overview of findings, risks, and top recommendations
- Current state vs. proposed state (before/after mermaid diagrams)
-
ARCHITECTURE-CURRENT.mermaid- Complete data flow diagram of current system
-
ARCHITECTURE-PROPOSED.mermaid- Complete data flow diagram of proposed system with all improvements
-
UNIFIED-RECOMMENDATIONS.md- All recommendations across workstreams, merged and deduplicated
- Prioritized: P0 (critical/breaking) → P1 (important) → P2 (nice-to-have)
- Dependency map between recommendations
-
IMPLEMENTATION-ROADMAP.md- BMAD-style breakdown: Epics → Stories → Tasks
- Sequenced by dependency and priority
- Estimated effort (T-shirt sizing: S/M/L/XL)
- Suggested sprint allocation (assuming 2-week sprints)
-
TASKS.md(project root)- Flat checklist of all actionable items
- Grouped by workstream and priority
- Checkbox format for tracking execution
- Session-drop safe: any future Claude Code session can pick this up
-
SECURITY-FINDINGS.md(if applicable)- Credentials in code, SQL injection vectors, auth gaps → all flagged as P0
The following MCP servers are connected and available for use during this review:
- Filesystem — Direct access to project files on the local machine
- Linear — Create issues/stories directly from recommendations (ask before creating)
- Slack — Post summaries or alerts (ask before sending)
- Google Drive — Access any related documentation stored in Drive
- Figma — Generate architecture diagrams if mermaid is insufficient
- Supabase — If any DB inspection is needed beyond direct PG access
Use these tools proactively where they add value. If you need to create Linear issues or send Slack messages, ask me first.
- Stack: Python 3.12, PostgreSQL (port 5433), SQLAlchemy 2.0 async, FastAPI, Dash
- Style: Ruff @ 88 chars, functional preferred, SOLID/DRY/KISS/YAGNI
- Session management: TASKS.md + PROGRESS.md for continuity across session drops
- No hardcoded values: Prefer dynamic verification commands and environment-based config
- Auth: Do not store or log credentials. Reference env vars or secrets manager.
- Code output: When recommending code changes, provide complete implementations grouped by logical section with summary comments, not partial snippets.