CodeBrain is an autonomous AI quality engineering platform built with Django, LangChain, Pydantic v2, and asynchronous HTTPX execution engines. It orchestrates specialized QA agents across requirement analysis, test case generation, multi-criteria auditing, live API contract testing, and enterprise TMS synchronization.
┌──────────────────────────────────────────────────────────────────────────────┐
│ Presentation & CLI Layer │
│ - Django HTML5 UI (Bootstrap 5, EventSource SSE, /pipeline/ Auto-Pilot) │
│ - React 18 + Vite Interactive Showcase (frontend/ — Vercel-ready) │
│ - Headless CI/CD CLI (python manage.py run_test_suite) │
└──────────────────────────────────────┬───────────────────────────────────────┘
│ HTTP / SSE / CLI
▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ Application & Agent Layer │
│ ┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐ │
│ │ apps/core/ │ │ apps/ai_agents/ │ │ apps/knowledge/ │ │
│ │ - Dashboard & Cases │ │ - ActorCriticEngine │ │ - OpenAPI Parser │ │
│ │ - /pipeline/ Views │ │ - TestCaseGenerator │ │ - Postman Parser │ │
│ │ - Jira / TestRail │ │ - TestCaseReviewer │ │ - HybridRetriever │ │
│ │ - XMind / JUnit XML │ │ - PRDAnalyzer │ │ - Chroma/SQLite DB │ │
│ │ - SSE Stream Views │ │ - IfaceCaseGenerator │ │ - Milvus Facade │ │
│ │ │ │ - APITestRunner │ │ │ │
│ │ │ │ - JavaCodeAnalyzer │ │ │ │
│ └─────────────────────┘ └──────────────────────┘ └─────────────────────┘ │
└──────────────────────────────────────┬───────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ Service & Infrastructure Layer │
│ ┌────────────────────────────────┐ ┌────────────────────────────────────┐ │
│ │ apps/llm/ │ │ apps/utils/ │ │
│ │ - Universal LLMServiceFactory │ │ - ProgressRegistry (Thread-Safe) │ │
│ │ (DeepSeek, Qwen, OpenAI, │ │ - SSELogEmitter (Stream Producer) │ │
│ │ Ollama, Groq, Custom vLLM) │ │ - TaskContext Lifecycle Manager │ │
│ └────────────────────────────────┘ └────────────────────────────────────┘ │
└──────────────────────────────────────┬───────────────────────────────────────┘
│
┌─────────────────┴─────────────────┐
▼ ▼
┌─────────────────────────────────────┐ ┌────────────────────────────────────┐
│ Relational Storage │ │ Vector & Lexical Storage │
│ - SQLite (Default zero-config dev) │ │ - Embedded SQLite/Chroma Store │
│ - MySQL 8.x (Production/UAT) │ │ - PureBM25Index + RRF Fusion │
│ │ │ - Milvus 2.x (Optional Cluster) │
└─────────────────────────────────────┘ └────────────────────────────────────┘
- Django Server-Rendered UI: Templates in
templates/andapps/ai_agents/*/templates/, plus the unified multi-agent Auto-Pilot console inapps/core/templates/pipeline.html. - Interactive Showcase (
frontend/): Standalone Vite + React + TypeScript showcase configured withvercel.jsonfor static/edge hosting. - Headless CLI (
run_test_suite.py): Django management command for executing API test suites in CI/CD pipelines with JUnit XML and JSON summary output.
apps/ai_agents/common/orchestrator.py(ActorCriticReflectionEngine): Runs iterativeGenerator ⇄ Reviewerfeedback loops with monotonic regression safeguards, ensuring refined test suites never degrade below previously achieved quality scores.apps/ai_agents/iface_case_generator/runner.py(APITestRunner): Asynchronoushttpxexecution engine withverify_tls=Trueby default, SSRF/DNS-rebinding guards (_resolve_safe_target+ IP pinning + HTTPSsni_hostname), and JSONPath/regex assertion evaluators.apps/core/exporters/: Pluggable enterprise exporters for Jira Cloud (JiraExporter), TestRail (TestRailExporter), XMind (.xmind) (XMindExporter), and JUnit XML (JUnitExporter).
LLMServiceFactory(apps/llm/base.py): InstantiatesDeepSeekChatModel,QwenChatModel, orChatOpenAIadapters foropenai,ollama,groq, and custom OpenAI-compatible endpoints, enforcing provider-scoped API keys and masked credential logging.
- Relational DB: Defaults to SQLite (
db.sqlite3); switches to MySQL whenUSE_MYSQL=trueorMYSQL_HOSTis set. - Zero-Docker Hybrid RAG: Combines
PersistentSQLiteVectorStore(chroma_store.py) andPureBM25Index(hybrid_retriever.py) via Reciprocal Rank Fusion (RRF), with optional Milvus cluster support (ENABLE_MILVUS = True).
Browser Django Server LLM / Agent Task
│ │ │
├── POST /generate/ ────────────>│ │
│ ├── Generate task_id │
│ ├── Spawn worker thread ────────────>│
│<── JSON {task_id} ─────────────┤ │
│ │ │
├── GET /progress/stream/{id} ──>│ │
│ ├── SSELogEmitter │
│ │ (yields data: {...}\n\n) │
│ │<── emit log / update percentage ───┤
│<── SSE message ────────────────┤ │
│<── SSE [DONE] ─────────────────┤<── task completed ─────────────────┤
- The client initiates a task via HTTP POST and receives a
task_id. - The client opens an
EventSourceconnection to/progress/stream/<task_id>/. - The background worker executes the agent or pipeline, publishing step logs and completion percentages to
ProgressRegistry. SSELogEmitterstreams events to the browser until completion.