# C4 Level 2 – Container Architecture Diagram
---

This diagram describes the major containers within the SmartCrops Edge System and Cloud System, including backends, databases, MQTT broker, UI applications, and synchronization services.

```
+----------------------------------------------------------------------------------------------------+
|                                      SmartCrops – Container View                                   |
+----------------------------------------------------------------------------------------------------+

                                ┌────────────────────────────────────────────┐
                                │                  Users                     │
                                │  Administrator / Technician / Viewer       │
                                └────────────────────────────────────────────┘
                                                   |
                                                   |  (HTTPS / LAN or Internet)
                                                   v

+---------------------------------------------+                 +------------------------------------------+
|            Edge System (On-Prem)            |                 |          Cloud System (GCP VPS)          |
|---------------------------------------------|                 |------------------------------------------|
|                                             |                 |                                          |
|  ┌──────────────────────────────┐           |                 |    ┌──────────────────────────────┐      |
|  │   Local UI (Next.js)         │<---------------------------------│   Cloud UI (Next.js)         │      |
|  └──────────────────────────────┘   (HTTPS) |                 |    └──────────────────────────────┘      |
|                |                            |                 |                |                         |
|                | (WebSocket/HTTP)           |                 |                | (HTTPS)                 |
|                v                            |                 |                v                         |
|  ┌──────────────────────────────┐           |                 |     ┌──────────────────────────────┐     |
|  │ Local Backend (Fastify+TS)   │---------------------------------→│ Cloud Backend (Fastify)      │     |
|  │  - Automation Engine         │  (WS Outbound Only)         |     │ + Sync Server (WebSocket)    │     |
|  └──────────────────────────────┘           |                 |     └──────────────────────────────┘     |
|                |                            |                 |                |                         |
|                | (SQL)                      |                 |                | (SQL)                   |
|                v                            |                 |                v                         |
|      ┌──────────────────────────┐           |                 |    ┌──────────────────────────┐          |
|      │ Local Database (Postgres)│           |                 |    │  Cloud Database          │          |
|      │  Time-Series Partitions  │           |                 |    │ (Postgres / SQLite)      │          |
|      └──────────────────────────┘           |                 |    └──────────────────────────┘          |
|                                             |                 |                                          |
|  ┌──────────────────────────────┐           |                 |                                          |
|  │   MQTT Broker (Mosquitto)    │<─────────────────┐          |                                          |
|  └──────────────────────────────┘           │      |          |                                          |
|                                             |      | 		    |                                          |
|  ┌──────────────────────────────┐           |      |          |                                          |
|  │ Sync Client (WebSocket Out)  │-------------------------------------------→ (Sync Server in Cloud)    |
|  └──────────────────────────────┘           |      |          |                                          |
+---------------------------------------------+      |          +------------------------------------------+
													 |
													 v (MQTT Publish/Subscribe)
										┌─────────────────────────────┐
										│       ESP32 MCU Node        │
										│ Sensors + Actuators         │
										│ UART / I2C / 1-Wire / GPIO  │
										└─────────────────────────────┘
								
```
