Role: Lead AI Architect & Founder @ Stratik.co
Focus: AI Unit Economics, System Governance, Production Reliability
Scaling AI products creates three existential business risks:
- Financial Risk - Ungoverned LLM APIs and database auto-scaling can destroy margins.
- Operational Risk - Non-deterministic AI behavior creates support tickets and compliance failures.
- Product Risk — High inference latency (10s+) kills user retention and conversion.
- Business Problem: Uncontrolled DB scaling ($420 → $3,000 spikes) due to AI-driven connection saturation.
- Architectural Solution: Autonomous agent that enforces saturation ceilings via priority-based connection termination (CTE-logic).
- Tech: Python, Asyncpg, GCP Monitoring API.
PostgresGovernor (Autonomous Database Agent) Prevents infrastructure cost spirals by enforcing strict saturation limits.
- Economic Impact: $1,355/mo in peak net cost avoidance (75% reduction vs unmanaged spikes).
- Operational Impact: Reduced P0 database incidents from 8/quarter to 2.
- Business Problem: Non-deterministic nature of LLMs poses a compliance and stability risk in B2B workflows.
- Solution: A strict State Machine architecture enforced via Python decorators.
- Logic: The @require_valid_campaign decorator (see tests/) and lenient parsing with JSON5 enforces rigid state transitions. This ensures that while AI content is probabilistic, the business workflow remains 100% deterministic and auditable.
- Testing: Unit tests (Pytest) verify state integrity and error handling without external dependencies.
- Tech: Python 3.12, FastAPI, SQLAlchemy (Async), State Machine Pattern.
Deterministic State Machine Wraps non-deterministic LLMs in rigid, auditable workflows.
- Economic Impact: Eliminated $1,000+ wasted tokens on invalid request states.
- Operational Impact: Robust audit trail for B2B compliance; 94% reduction in parsing failures.
- Business Problem: High latency of LLM inference degrades user trust and retention.
- Solution: Optimistic UI patterns and robust state management.
Optimistic UI & State Reconciliation Decouples expensive inference latency from perceived user speed.
- Product Impact: Maintained 4.2s perceived latency (vs 12s actual).
- Technical Innovation: State reconciliation pattern for async AI streams.
- Tech: TypeScript, React, Optimistic Updates.
To respect the reviewer's time, this repository shows a ** selection** of the most architecturally important components.
In prod, these systems operate within a broader governance framework I architected, including:
- Cloud Run Controller: Prevents serverless bill shocks via restricted revision jailing.
- API Rate Limiters: Redis-backed circuit breakers to prevent LLM loops.
- Service Controls: Per-user quota management to enforce SaaS margin targets.
These additional components are available for deep-dive discussion.
I built Stratik.co (B2B SaaS) from scratch. As lean company, I had to architect for profitability from day one.
This portfolio demonstrates:
- Economic Engineering: Every line of code is measured by its P&L impact.
- Fail-Safe Design: Systems that default to safety (Fail Closed) rather than burning cash.
- Strategic Curation: Solving the hardest problems (Reliability) first.
| Metric | Result |
|---|---|
| Peak Cost Avoidance | ~$3,300/mo (Combined Database + Compute + API + Engineering Time) |
| Workflow Determinism | 99.9% (Negligible number of invalid-state AI calls) |
| Test Coverage | 94% (Critical path coverage) |
This repo includes a robust test suite to verify the core deterministic AI service (AI Orchestration) and cloud Infrastructure Governance.
1. Install dependencies:
pip install -r requirements.txt2. Run the full test suite:
python3 -m pytestRunning the suite validates both the Infrastructure Governor and the deterministic AI service logic, ensuring end-to-end reliability.
=========================== test session starts ============================
collected 14 items
tests/infrastructure/test_governor.py ......... [ 64%]
tests/backend/test_ai_service.py ..... [100%]
======================== 14 passed in 0.82s ========================
Rafal Modrzewski
Lead AI Architect & Founder @ Stratik.co | Architecture Strategy
LinkedIn