askrobots / dbbasic Public

Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.

0 downloads

dbbasic/docs/paradigms/MICROSERVICES_IN_CONFIG.yaml
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add DBBasic crate engine logo and update README 0d628db 1 year, 2 months ago History
MICROSERVICES_IN_CONFIG.yaml · 5.8 KB · 293 lines
1# Microservices Architecture in Config
2# What Rails/Django couldn't do: distributed services
3# Service mesh, API gateways, distributed tracing
4
5name: "Microservices Platform"
6paradigm: "Service-Oriented Architecture"
7why_mvc_failed: "Monoliths don't scale horizontally"
8
9# ==========================================
10# SERVICE DEFINITIONS → CONFIG
11# ==========================================
12services:
13 # Each service is independent
14
15 user-service:
16 language: "auto" # Don't care
17 database: "postgres"
18
19 api:
20 REST:
21 GET /users: "list all users"
22 GET /users/:id: "get user"
23 POST /users: "create user"
24
25 gRPC:
26 GetUser: "returns User"
27 ListUsers: "returns UserList"
28
29 dependencies:
30 - auth-service
31 - notification-service
32
33 scaling:
34 min_replicas: 2
35 max_replicas: 10
36 metric: "cpu > 70%"
37
38 order-service:
39 database: "mongodb"
40
41 api:
42 REST:
43 POST /orders: "create order"
44 GET /orders/:id: "get order"
45
46 events:
47 publishes:
48 - OrderCreated
49 - OrderShipped
50
51 subscribes:
52 - PaymentCompleted
53 - InventoryUpdated
54
55 resilience:
56 timeout: 5s
57 retry: 3
58 circuit_breaker: true
59
60 payment-service:
61 database: "dynamodb"
62
63 api:
64 REST:
65 POST /payments: "process payment"
66
67 external:
68 stripe:
69 api_key: "${STRIPE_KEY}"
70
71 compliance:
72 pci_dss: true
73 audit_log: true
74
75# ==========================================
76# API GATEWAY → CONFIG
77# ==========================================
78gateway:
79 # Kong, Envoy, nginx - whatever
80
81 routes:
82 /api/users:
83 service: "user-service"
84 methods: ["GET", "POST"]
85 auth: "jwt"
86
87 /api/orders:
88 service: "order-service"
89 rate_limit: "100/minute"
90
91 /api/payments:
92 service: "payment-service"
93 auth: "jwt"
94 policies:
95 - pci_compliance
96 - audit_logging
97
98 plugins:
99 - cors
100 - rate_limiting
101 - jwt_auth
102 - request_logging
103
104# ==========================================
105# SERVICE MESH → CONFIG
106# ==========================================
107mesh:
108 # Istio, Linkerd - handle service-to-service
109
110 traffic_management:
111 retry:
112 attempts: 3
113 timeout: 5s
114
115 load_balancing:
116 strategy: "round_robin"
117
118 circuit_breaker:
119 consecutive_errors: 5
120 interval: 30s
121
122 security:
123 mtls: true # Mutual TLS
124 authorization_policy:
125 - from: "user-service"
126 to: "order-service"
127 methods: ["GET", "POST"]
128
129 observability:
130 metrics: "prometheus"
131 tracing: "jaeger"
132 logging: "fluentd"
133
134# ==========================================
135# EVENT BUS → CONFIG
136# ==========================================
137events:
138 # Kafka, RabbitMQ, NATS - whatever
139
140 broker: "auto"
141
142 topics:
143 orders:
144 partitions: 10
145 replication: 3
146 retention: "7 days"
147
148 payments:
149 partitions: 5
150 replication: 3
151
152 streams:
153 order_processing:
154 from: "orders"
155 to: "processed_orders"
156 processor: |
157 validate_order
158 enrich_with_user_data
159 calculate_taxes
160 emit_to_processed
161
162# ==========================================
163# DISTRIBUTED TRANSACTIONS → CONFIG
164# ==========================================
165transactions:
166 # Saga pattern for distributed tx
167
168 create_order:
169 type: "saga"
170
171 steps:
172 - service: "inventory-service"
173 action: "reserve_items"
174 compensate: "release_items"
175
176 - service: "payment-service"
177 action: "charge_card"
178 compensate: "refund_payment"
179
180 - service: "shipping-service"
181 action: "create_shipment"
182 compensate: "cancel_shipment"
183
184# ==========================================
185# SERVICE DISCOVERY → CONFIG
186# ==========================================
187discovery:
188 # Consul, Eureka, etcd
189
190 provider: "auto"
191
192 health_checks:
193 http:
194 path: "/health"
195 interval: 10s
196 timeout: 3s
197
198 tcp:
199 interval: 10s
200
201 load_balancing:
202 strategy: "least_connections"
203 sticky_sessions: false
204
205# ==========================================
206# DISTRIBUTED CACHING → CONFIG
207# ==========================================
208cache:
209 # Redis Cluster, Hazelcast
210
211 distributed: true
212
213 regions:
214 user_cache:
215 ttl: 600
216 max_size: 10000
217 eviction: "LRU"
218
219 session_cache:
220 ttl: 3600
221 replicas: 3
222
223 cache_aside:
224 patterns:
225 - "GET /users/*"
226 - "GET /products/*"
227
228# ==========================================
229# DISTRIBUTED TRACING → CONFIG
230# ==========================================
231tracing:
232 # OpenTelemetry, Jaeger, Zipkin
233
234 provider: "opentelemetry"
235
236 sampling:
237 strategy: "adaptive"
238 rate: 0.1 # 10%
239
240 spans:
241 auto_instrument:
242 - http_requests
243 - database_queries
244 - cache_operations
245
246 baggage:
247 - user_id
248 - request_id
249 - session_id
250
251# ==========================================
252# CONTAINER ORCHESTRATION → CONFIG
253# ==========================================
254deployment:
255 # Kubernetes, Nomad, Docker Swarm
256
257 platform: "kubernetes"
258
259 services:
260 user-service:
261 image: "auto-built"
262 replicas: 3
263 resources:
264 cpu: "500m"
265 memory: "512Mi"
266
267 autoscaling:
268 min: 2
269 max: 10
270 metric: "cpu > 70%"
271
272 health:
273 liveness: "/health"
274 readiness: "/ready"
275
276# ==========================================
277# WHY THIS MATTERS
278# ==========================================
279# Rails/Django assume:
280# - Single database
281# - Monolithic deployment
282# - Synchronous calls
283# - Shared memory/state
284#
285# Microservices assume:
286# - Service per database
287# - Independent deployment
288# - Async communication
289# - Network boundaries
290#
291# DBBasic handles both monoliths AND microservices
292# Same config can generate either architecture
293# ==========================================