Skip to content

Commit aa5edde

Browse files
committed
Initial Commit for the Azure Cloud AI Visualizer
0 parents  commit aa5edde

845 files changed

Lines changed: 37262 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-cd.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI/CD - Build and Push
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
env:
13+
FRONTEND_IMAGE: ${{ github.repository }}-frontend
14+
BACKEND_IMAGE: ${{ github.repository }}-backend
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v2
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2
24+
25+
- name: Log in to registry
26+
uses: docker/login-action@v2
27+
with:
28+
registry: ${{ secrets.REGISTRY_HOST }}
29+
username: ${{ secrets.REGISTRY_USERNAME }}
30+
password: ${{ secrets.REGISTRY_PASSWORD }}
31+
32+
- name: Build and push backend image
33+
uses: docker/build-push-action@v4
34+
with:
35+
context: .
36+
file: Dockerfile.backend
37+
push: true
38+
tags: |
39+
${{ secrets.REGISTRY_HOST }}/${{ env.BACKEND_IMAGE }}:latest
40+
41+
- name: Build and push frontend image
42+
uses: docker/build-push-action@v4
43+
with:
44+
context: .
45+
file: Dockerfile.frontend
46+
push: true
47+
tags: |
48+
${{ secrets.REGISTRY_HOST }}/${{ env.FRONTEND_IMAGE }}:latest
49+
50+
- name: Image summary
51+
run: |
52+
echo "Frontend image: ${{ secrets.REGISTRY_HOST }}/${{ env.FRONTEND_IMAGE }}:latest"
53+
echo "Backend image: ${{ secrets.REGISTRY_HOST }}/${{ env.BACKEND_IMAGE }}:latest"

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

CODE_OF_CONDUCT.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
This project adheres to the Contributor Covenant v2.1. By participating, you are expected to uphold this code.
4+
5+
Standards
6+
- Be respectful and considerate in all communications.
7+
- Avoid discriminatory or harassing behavior.
8+
- Encourage a welcoming environment for contributors from all backgrounds.
9+
10+
Reporting
11+
- If you witness or are subject to unacceptable behavior, please open an issue flagged `security` or contact the maintainers privately.
12+
13+
Consequences
14+
- Maintainers may remove content or ban contributors who violate the code of conduct.
15+
16+
For the full text of the Contributor Covenant, see: https://www.contributor-covenant.org/version/2/1/code_of_conduct/

CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Contributing to Cloud Visualizer Pro
2+
3+
Welcome — thank you for considering contributing to Cloud Visualizer Pro. We appreciate every contribution, big or small.
4+
5+
This document explains the preferred workflow, coding standards, and how to run tests locally so your PRs are easy to review and merge.
6+
7+
Getting started
8+
- Fork the repository and create a feature branch from `main` using a descriptive name, e.g. `feat/diagram-node-labels` or `fix/backend-logging`.
9+
- Keep changes small and focused. One change per PR makes review straightforward.
10+
11+
Development workflow
12+
- Create an issue for larger features or any bug you plan to work on and link your PR to the issue.
13+
- Branch naming: `feat/*`, `fix/*`, `chore/*`, `docs/*`, `test/*`.
14+
- Commit messages: use conventional style, e.g. `feat(iac): add bicep parameter generation`.
15+
16+
Local development
17+
- Frontend (Vite):
18+
```powershell
19+
cd <repo-root>
20+
pnpm install
21+
pnpm run dev
22+
```
23+
24+
- Backend (FastAPI):
25+
```powershell
26+
cd backend
27+
python -m venv .venv
28+
.\.venv\Scripts\Activate.ps1
29+
python -m pip install --upgrade pip
30+
python -m pip install -r requirements.txt
31+
.\.venv\Scripts\python.exe -m uvicorn main:app --reload --port 8000
32+
```
33+
34+
Testing
35+
- Add unit tests for new backend logic using pytest and for frontend components using your preferred test runner.
36+
- Run backend tests:
37+
```powershell
38+
cd backend
39+
.\.venv\Scripts\Activate.ps1
40+
pytest -q
41+
```
42+
43+
Code style
44+
- Keep TypeScript/React code consistent with project linters and formatters (Prettier / ESLint if configured).
45+
- Keep Python code formatted with Black / ruff where applicable.
46+
47+
Pull requests
48+
- Open a pull request against `main` and include:
49+
- A short description of the change
50+
- Screenshots if the change affects UI
51+
- Any migration or environment changes required
52+
- Link the PR to an issue when possible and add reviewers.
53+
54+
Security disclosures
55+
- If you discover a security issue, please avoid public disclosure and open a private issue or contact the maintainers directly.
56+
57+
Thanks again for helping improve the project — your contributions make it better!

Dockerfile.backend

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Backend Dockerfile for Azure Architect Backend (FastAPI)
2+
# Uses Python 3.11 slim as base
3+
FROM python:3.11-slim
4+
5+
# Ensure pip is upgraded
6+
RUN python -m pip install --upgrade pip
7+
8+
# Create app directory
9+
WORKDIR /app
10+
11+
# Install system deps required for some packages
12+
RUN apt-get update && apt-get install -y --no-install-recommends \
13+
build-essential \
14+
gcc \
15+
libpq-dev \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# Copy the backend into the image
19+
COPY backend /app
20+
21+
# Install the Python package (will read pyproject.toml and install dependencies)
22+
RUN pip install --no-cache-dir .
23+
24+
# Expose port
25+
EXPOSE 8000
26+
27+
# Entrypoint
28+
ENV PYTHONUNBUFFERED=1
29+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.frontend

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Frontend Dockerfile for Vite React app
2+
# Build stage
3+
FROM node:20-alpine AS build
4+
WORKDIR /app
5+
COPY package.json package-lock.json* pnpm-lock.yaml* bun.lockb* ./
6+
# Install deps (use npm by default)
7+
RUN if [ -f pnpm-lock.yaml ]; then npm i -g pnpm && pnpm install; elif [ -f package-lock.json ]; then npm ci; else npm i; fi
8+
COPY . .
9+
RUN npm run build --if-present
10+
11+
# Production stage: serve with nginx
12+
FROM nginx:stable-alpine
13+
COPY --from=build /app/dist /usr/share/nginx/html
14+
# Optional: copy custom nginx config
15+
EXPOSE 80
16+
CMD ["nginx", "-g", "daemon off;"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 CortexGrid.ch
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Cloud Visualizer Pro
2+
![alt text](image.png)
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+
![alt text](image-1.png)
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

Comments
 (0)