How azure-samples/dapr-store works
Project Type & Purpose
• Dapr Store is a full-stack, microservices-based online store demonstrator built with Go microservices and a Vue.js single-page app, all orchestrated via Dapr.
• It shows key Dapr building blocks: service invocation, state management (Redis), pub/sub messaging, output bindings, and middleware.
File Structure Highlights
• cmd/: Four Go microservices (cart, orders, products, users) plus frontend-host. Each has main.go, routes.go, spec/, impl/, and mock/.
• web/frontend/: Vue.js SPA source, components, services, views, tests.
• api/: HTTP client test scripts, OpenAPI, TypeSpec, JSON schemas.
• components/ & deploy/: Dapr component YAMLs, Helm charts, Kubernetes Bicep templates, Azure Container App configs.
• build/ & scripts/: Dockerfiles, compose files, helper scripts for local/dev setups.
README Insights
• Confirms a monorepo using “Go Standard Project Layout”.
• Services interact via Dapr sidecar HTTP calls—automated mTLS, retries, discovery.
• State store is Redis; pub/sub topic (orders-queue) decouples cart → orders; output bindings for blob storage and SendGrid.
a. Main Components
• Client Layer: Browser running Vue SPA → served by frontend-host service
• API Gateway: NGINX reverse proxy (with Dapr sidecar)
• Microservices (each with its own Dapr sidecar):
• Cart service
• Orders service
• Products service
• Users service
• Dapr Runtime: Sidecar per service exposing /v1.0/ APIs
• State Store: Redis (Dapr state component)
• Pub/Sub Broker: (e.g. Redis PubSub or Azure Service Bus)
• Output Binding Targets: Azure Blob, SendGrid
• CI/CD & Deployment: GitHub Actions, Helm/Kubernetes, Azure Container Apps
b. Relationships & Interactions
• User → (HTTP) → NGINX Gateway → Dapr sidecar → target service via Dapr Service Invocation
• Cart service:
• Reads/writes Cart state → Dapr State API → Redis
• Validates via Dapr Service Invocation → Products service
• Publishes new orders → Dapr Pub/Sub → orders-queue topic
• Orders service:
• Subscribes to orders-queue → Dapr Pub/Sub
• Persists orders → Dapr State API → Redis
• Optionally writes reports → Blob binding
• Sends emails → SendGrid binding
• Users service: state via Dapr State API → Redis
• Products service: internal SQLite DB (no Dapr state), invoked via Dapr Service Invocation
• Frontend-host: serves SPA static files; /config endpoint supplies runtime config
c. Architectural Patterns & Principles
• Microservices per bounded context
• Sidecar pattern (Dapr) to offload service-to-service concerns
• Event-driven communication with pub/sub for loose coupling
• API Gateway for unified ingress, auth enforcement, and routing
• Declarative infra with Helm charts, Bicep, and Dapr component YAML
d. Key Technologies/Frameworks
• Go + go-rest-api starter kit
• Vue.js SPA (Vue Router, Vite, Vitest)
• Dapr building blocks: Service Invocation, State, Pub/Sub, Bindings, Middleware
• Redis (state + pub/sub)
• SQLite (products catalog)
• NGINX as API gateway
• Kubernetes/Helm & Azure Container Apps