How pala46/azure-inventory-dashboard works
Purpose and Runtime
Azure Inventory Dashboard is a live, read-only Azure subscription inventory system. A React/Vite browser client calls a FastAPI REST API; the backend authenticates users with Microsoft Entra ID and queries Azure Resource Graph rather than maintaining an inventory database. Development runs Vite on :5173 and uvicorn on :8000; production FastAPI can serve the built frontend.
Paths: backend/app.py, frontend/src/main.jsx, frontend/vite.config.js
Application Composition and Entry Points
backend.app:app is the server entry point: it assembles API routes, error handling, health behavior, and optional static frontend hosting. The React entry mounts the application, while the top-level app owns routing, shared layout, and page selection. Convenience launchers provision and start both runtimes.
Paths: backend/app.py, frontend/src/App.jsx, run.sh
Authentication Boundary
The frontend is gated by auth state and never accesses Azure directly. Auth endpoints expose status, initiate interactive browser login, and clear the in-memory session. Backend authentication encapsulates InteractiveBrowserCredential, persisted OS token caching, MFA-capable browser flow, token-claim user extraction, and thread-pool handling for its synchronous credential calls. Failed Azure authentication is translated to a client-facing 401.
Paths: backend/auth.py, backend/routes/auth.py, frontend/src/context/AuthContext.jsx
Azure Query Layer
Azure access is centralized behind a reusable Resource Graph client and Kusto-query definitions. Request handlers invoke this layer on demand against the configured subscription; there is no database, scheduled scan, or backend inventory persistence. This isolation is the intended insertion boundary for caching, persistence, alternate credentials, or multi-subscription support.
Paths: backend/azure_client.py, backend/resource_graph.py, backend/config.py
API Domain Stages
The API is organized by inventory domain. Dashboard routes compose summary metrics, charts, and curated lists; resource routes implement paginated listing, filtered global search, full resource detail, and relationship discovery. Category routes issue targeted Resource Graph queries for compute, storage, database, network, containers, security, monitoring, resource groups, and tags.
Paths: backend/routes/dashboard.py, backend/routes/resources.py, backend/routes/compute.py
Frontend Data and Presentation Flow
Pages fetch REST data through the shared Axios client and data-fetch hook, rendering reusable tables, charts, loading/error states, and export controls. Auth and refresh contexts coordinate session gating and reload behavior across routes. Detail and search pages consume the generic resource APIs; category pages consume their corresponding domain endpoints.
Paths: frontend/src/api/client.js, frontend/src/hooks/useApi.js, frontend/src/pages/ResourceDetail.jsx
External Services and Deployment Boundaries
Microsoft Entra ID supplies interactive authentication; Azure Resource Graph supplies all inventory data and requires subscription Reader-level query access. The client uses Bootstrap-oriented UI components and Chart.js visualizations. In development, Vite proxies /api to FastAPI; in deployment, a reverse proxy such as nginx/Caddy provides TLS ahead of uvicorn, while FastAPI may host frontend/dist.
Paths: frontend/package.json, frontend/vite.config.js, backend/.env.example
Main entry points: app.py FastAPI application · resource_graph.py Resource Graph query layer · App.jsx App shell & routes · run.sh Development launcher
Components 19
Browser Client
- React entry
frontend/src/main.jsx - App shell & routes · Owns shared layout, page selection, and route-level auth gating.
frontend/src/App.jsx - Auth context · Coordinates frontend authentication state.
frontend/src/context/AuthContext.jsx - API client
frontend/src/api/client.js - Data fetch hook · Provides shared loading, error, and refresh behavior.
frontend/src/hooks/useApi.js - Resource detail page · Consumes generic resource detail and relationship APIs.
frontend/src/pages/ResourceDetail.jsx
FastAPI Backend
- FastAPI application · Assembles routes, health/error behavior, and optional static frontend hosting.
backend/app.py - Auth endpoints · Exposes status, interactive login, and session clearing.
backend/routes/auth.py - Entra auth service · Uses browser credential, OS token cache, MFA flow, and claim extraction.
backend/auth.py - Dashboard endpoints · Composes inventory metrics, charts, and curated lists.
backend/routes/dashboard.py - Resource endpoints · Provides paginated listing, search, detail, and relationships.
backend/routes/resources.py - Category endpoints · Serves targeted compute and other inventory-domain queries.
backend/routes/compute.py - Resource Graph query layer · Centralizes reusable client access and Kusto query definitions.
backend/resource_graph.py - Azure client
backend/azure_client.py
Azure Services
- Microsoft Entra ID · Interactive MFA-capable user authentication.
- Azure Resource Graph · Live subscription inventory source; no inventory database is maintained.
Runtime & Deployment
- Vite development server · Serves the browser client and proxies /api to FastAPI.
frontend/vite.config.js - Development launcher · Starts the frontend and backend development runtimes.
run.sh - TLS reverse proxy · nginx or Caddy can terminate TLS ahead of uvicorn.
Connections 21
- React entry → App shell & routes: mounts
- App shell & routes → Auth context: gates pages with
- App shell & routes → Resource detail page: selects route
- Resource detail page → Data fetch hook: loads via
- Data fetch hook → API client: uses
- API client → FastAPI application: REST /api
- FastAPI application → Auth endpoints: mounts
- FastAPI application → Dashboard endpoints: mounts
- FastAPI application → Resource endpoints: mounts
- FastAPI application → Category endpoints: mounts
- Auth endpoints → Entra auth service: delegates login
- Entra auth service → Microsoft Entra ID: interactive credential
- Dashboard endpoints → Resource Graph query layer: queries
- Resource endpoints → Resource Graph query layer: queries
- Category endpoints → Resource Graph query layer: queries
- Resource Graph query layer → Azure client: uses
- Azure client → Azure Resource Graph: executes Kusto queries
- Development launcher → Vite development server: starts
- Development launcher → FastAPI application: starts uvicorn
- Vite development server → FastAPI application: proxies /api
- TLS reverse proxy → FastAPI application: forwards TLS traffic