
Build a context-mapping script that documents your system's bounded contexts before AI assists
You'll have a working script that prompts you to identify and document different business domains in your system (e.g., payments vs. notifications), producing a structured context file that you feed t
What you'll make
Context Mapping Script
- map_contexts() — the domain discovery function: what to include
- validate_boundaries() — coupling analysis: what to include
- generate_context_file() — structured output: what to include
- main() — orchestration and prompts: what to include
Paste your working Python script that runs against your actual codebase
The 3 parts
Each part ends with a check you can see.
Find Your Hidden Boundaries
Scan your codebase to identify where business domains are already separated in code but not documented.
Done when
You have a list of 3-5 potential business domains with evidence from your actual code structure (folder names, class groupings, API endpoints).
Measure Domain Coupling
Build a function that analyzes import dependencies and call patterns to validate your proposed domain boundaries.
Done when
You have a validate_boundaries() function that flags high-coupling cases between your proposed domains with specific examples.
Generate Context Documentation
Create the generate_context_file() function that outputs structured domain documentation AI can actually use.
Done when
You have a working script that produces a context.md file with domain descriptions, boundaries, and integration points formatted for AI consumption.
Capstone: you put together your Context Mapping Script.
Where this helps
An elective: a single lesson that sits outside rtwo's job certificates and doesn't count toward one.
About this lesson
What you'll be able to do
- Run a script that systematically documents your codebase's business domains and their boundaries
- Identify where your system has implicit domain boundaries that should be made explicit
- Generate a structured context file that improves how AI understands your codebase's business logic
- Know when to split vs merge bounded contexts based on actual coupling patterns
Who it's for
- Developers working on codebases with multiple business domains (payments, user management, notifications, etc.)
- Anyone who's noticed AI gives generic advice because it doesn't understand their specific business context
- Teams preparing to use AI coding assistants more effectively on domain-heavy code
What it won't cover
- Full Domain-Driven Design implementation
- Refactoring existing code to match discovered boundaries
- Setting up AI coding assistants or prompt engineering fundamentals
- Database schema changes or data migration
Skills you'll practise
- Domain boundary detection from code patterns
- Context documentation that AI can actually use
- Coupling analysis between business domains
- Iterative context refinement based on AI feedback