|
| 1 | +# Cloud Visualizer Pro |
| 2 | + |
| 3 | +Cloud Visualizer Pro is an open-source web application for visually designing Azure architecture diagrams, generating grounded Infrastructure-as-Code (IaC) (Bicep and Terraform), and orchestrating deployments. It combines a React/TypeScript frontend with a FastAPI backend and integrates the Microsoft Agent Framework (MAF) and Model Context Protocol (MCP) to ground LLM-driven IaC generation in official documentation. |
| 4 | + |
| 5 | +This repository is MIT licensed and contribution-friendly — contributions via pull requests and issue/task tracking are welcome. |
| 6 | + |
| 7 | +## License |
| 8 | + |
| 9 | +This project is released under the MIT License. See the `LICENSE` file for details. |
| 10 | + |
| 11 | +## Roadmap & Contributions |
| 12 | + |
| 13 | +- Contributions: Please open a pull request against `main`. Small, focused PRs with tests or screenshots are preferred. |
| 14 | +- Tasks / Issues: Use the project's issue tracker for bugs, feature requests, or development tasks. Label and link PRs to issue numbers where applicable. |
| 15 | +- Code of Conduct: Be respectful and follow standard open-source community practices. |
| 16 | + |
| 17 | +## High-level Architecture |
| 18 | + |
| 19 | +- Frontend: React + TypeScript (Vite) — located in `src/` |
| 20 | + - Uses modern UI primitives and a palette of Azure service icons. |
| 21 | + - Key components: diagram canvas, service palette, inspector panel, top bar, deploy modal. |
| 22 | +- Backend: FastAPI (Python) — located in `backend/app/` |
| 23 | + - Provides REST API endpoints for project storage, IaC generation, MCP integration, and deployments. |
| 24 | + - Uses Pydantic Settings for configuration and integrates Azure storage clients optionally. |
| 25 | +- Agent & MCP integration: |
| 26 | + - Microsoft Agent Framework (agent-framework, agent-framework-azure-ai) is used to run LLM-driven agents. |
| 27 | + - The app integrates external MCP servers (Microsoft Learn MCP and HashiCorp Terraform MCP) using a streamable MCP transport to ground model outputs in live documentation and provider schemas. |
| 28 | + |
| 29 | +## Key Features |
| 30 | + |
| 31 | +- Visual diagram editor for Azure architectures. |
| 32 | +- Grounded IaC generation: |
| 33 | + - Bicep generation with optional MCP grounding via Microsoft Learn MCP. |
| 34 | + - Terraform generation with optional HashiCorp Terraform MCP grounding. |
| 35 | +- IaC validation using MCP-backed schema checks. |
| 36 | +- Deploy orchestration pipeline (hooks for Azure SDK clients). |
| 37 | +- Offline/CI-friendly fallbacks: MockAgent/OpenAI fallback paths when MCP/MAF are unavailable. |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +## Quickstart (Development) |
| 42 | + |
| 43 | +Prerequisites |
| 44 | +- Node.js (for frontend / Vite) |
| 45 | +- Python 3.12+ and a virtual environment |
| 46 | +- Optional: Azure credentials if you plan to test deployments |
| 47 | + |
| 48 | +1) Frontend: install and run |
| 49 | + |
| 50 | +```powershell |
| 51 | +cd <repo-root> |
| 52 | +# install dependencies (uses pnpm, npm or yarn depending on your setup) |
| 53 | +pnpm install |
| 54 | +pnpm run dev |
| 55 | +``` |
| 56 | + |
| 57 | +2) Backend: create venv and install Python deps |
| 58 | + |
| 59 | +```powershell |
| 60 | +cd backend |
| 61 | +python -m venv .venv |
| 62 | +.\.venv\Scripts\Activate.ps1 |
| 63 | +python -m pip install --upgrade pip |
| 64 | +python -m pip install -r requirements.txt # if present |
| 65 | +# If you don't have a requirements.txt, install typical deps listed in pyproject or pip freeze |
| 66 | +``` |
| 67 | + |
| 68 | +3) Run backend (development) |
| 69 | + |
| 70 | +```powershell |
| 71 | +# from repo root |
| 72 | +# Ensure backend/.env contains your local overrides |
| 73 | +cd backend |
| 74 | +.\.venv\Scripts\Activate.ps1 |
| 75 | +# Use uvicorn or the provided run tasks |
| 76 | +.\.venv\Scripts\python.exe -m uvicorn main:app --reload --port 8000 |
| 77 | +``` |
| 78 | + |
| 79 | +4) Open the frontend (Vite dev server) and it should proxy to the backend (see CORS settings in `backend/.env`). |
| 80 | + |
| 81 | +## Configuration |
| 82 | + |
| 83 | +Configuration uses a `.env` file at `backend/.env` loaded by Pydantic Settings. |
| 84 | +Important environment keys: |
| 85 | + |
| 86 | +- OPENAI_API_KEY / USE_OPENAI_FALLBACK — enable OpenAI fallback for development |
| 87 | +- AZURE_OPENAI_KEY / AZURE_AI_PROJECT_ENDPOINT — configure Azure AI Project / MAF |
| 88 | +- AZURE_MCP_BICEP_URL — Microsoft Learn MCP base endpoint (recommended: `https://learn.microsoft.com/api/mcp`) |
| 89 | +- TERRAFORM_MCP_URL — HashiCorp Terraform MCP endpoint (if available) |
| 90 | +- AZURE_MCP_BICEP_FORCE / TERRAFORM_MCP_FORCE — set to `true` to force initializing MCP tools (useful in dev/test) |
| 91 | + |
| 92 | +Notes about MCP |
| 93 | +- The MCP endpoints require a streamable HTTP transport (SSE/chunked) and are intended to be used only from compliant MCP clients (for example `MCPStreamableHTTPTool` from `agent-framework`). Manual browser access will often return `405 Method Not Allowed`. |
| 94 | +- Microsoft Learn MCP (`https://learn.microsoft.com/api/mcp`) exposes tools such as `microsoft_docs_search`, `microsoft_code_sample_search` and `microsoft_docs_fetch`. Use these via MCP tools passed to the agent. |
| 95 | +- HashiCorp's MCP endpoint may apply rate-limits or access constraints (you may receive `429 Too Many Requests`). If you need a stable Terraform MCP integration consider contacting HashiCorp or using a local/proxied MCP registry. |
| 96 | + |
| 97 | +## How MCP is used in this project |
| 98 | +- The backend creates a streamable MCP tool singleton (`app.deps.get_mcp_bicep_tool` and `get_mcp_terraform_tool`) which opens a long-lived MCP session to the configured server. |
| 99 | +- The agent passes that tool into `chat_agent.run(prompt, tools=mcp_tool)` so the LLM can invoke tool calls and sample documentation content during generation. |
| 100 | +- The code contains safe fallbacks: if MCP initialization fails, the system logs the reasons and falls back to AI-only generation (or MockAgent for tests). |
| 101 | + |
| 102 | +## Development notes and troubleshooting |
| 103 | + |
| 104 | +- If you see an ImportError related to `prepare_function_call_results`, update/install `agent-framework` and `agent-framework-azure-ai` to compatible versions. The project includes a small compatibility shim to help in mixed-version dev environments. |
| 105 | +- If MCP initialization fails with `Session terminated` or stalls, verify: |
| 106 | + - `AZURE_MCP_BICEP_URL` is the base MCP endpoint (e.g. `https://learn.microsoft.com/api/mcp`) |
| 107 | + - Your network/proxy doesn't block chunked streaming HTTP or SSE |
| 108 | + - HashiCorp MCP may return `429` when rate-limited; try again later or request access |
| 109 | + |
| 110 | +## Testing |
| 111 | + |
| 112 | +- Backend unit/integration tests are located under `backend/` and use pytest/pytest-asyncio. |
| 113 | +- There is a small test harness `backend/test_terraform_mcp.py` that exercises the Terraform generator and demonstrates MockAgent fallback behavior when MCP is unavailable. |
| 114 | + |
| 115 | +## Security & Secrets |
| 116 | + |
| 117 | +- Never commit secrets (API keys, connection strings) to the repository. Put secrets in `backend/.env` (not checked in) or in a secure secret manager. |
| 118 | +- When deploying, use managed identities or secure vaults instead of environment variables for production credentials. |
| 119 | + |
| 120 | +## License & Contribution |
| 121 | + |
| 122 | +- MIT License. You may fork and open PRs. |
| 123 | +- Please follow the contribution notes above and include tests for new features. |
| 124 | + |
| 125 | +## Contact / Maintainers |
| 126 | + |
| 127 | +If you have questions or need help reproducing issues, open an issue describing the problem and include logs from the backend (set `LOG_LEVEL=DEBUG` in `.env` to get detailed MCP handshake logs). |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +Happy building! If you want, I can also add a `CONTRIBUTING.md`, a `CODE_OF_CONDUCT.md`, and a minimal `requirements.txt` extracted from the venv freeze. Let me know which of these you'd like next. |
0 commit comments