The PlantCare Enterprise API is built on a Cloud-Native, Stateless architecture designed to handle massive IoT workloads with zero downtime and sub-second scaling.

1. Edge Security & Metering

Every request to our Enterprise endpoints is intercepted by high-performance Security Middleware. This layer enforces security policies, cryptographic token authentication, and usage quotas at the cloud edge before any business logic is executed.

sequenceDiagram participant Client participant Edge as "Security Middleware" participant DB as "Database / Audit Store" participant API as "Analyze Service" Client->>Edge: "Request (Authorization: Bearer pk_ent_...)" Edge->>Edge: "Validate Payload Size (<10MB)" Edge->>DB: "Verify Cryptographic Token (SHA-256 Hash Lookup)" Edge->>Edge: "Enforce RBAC (Client vs Admin Role)" Edge->>DB: "Check Account Quota & State" alt "Quota Exceeded or Access Denied" Edge-->>Client: "429 / 403 Error" else "Authorized" Edge->>DB: "Log Audit Trail" Edge->>API: "Forward Request" API-->>Client: "Analysis Result" end

Cryptographic Verification & RBAC Middleware

To prevent token leakage and credential stuffing, B2B API tokens are never stored in plaintext. The security middleware hashes incoming tokens using SHA-256 and matches them against database audit records. Furthermore, the middleware enforces strict path-based Role-Based Access Control (RBAC):
Client Tokens: Permitted to consume client-facing endpoints (such as /v0/analyze, /v0/analysis/start, /v0/history, /v0/stats). Administrative requests are rejected with 403 Forbidden.
Admin Tokens: Permitted to access administrative endpoints (token generation/revocation, webhook registration, IoT device hierarchy settings, and worker invitations). Standard client requests are rejected with 403 Forbidden.

2. Reliable Webhook Delivery

Our webhook system is decoupled from the main request lifecycle using an event-driven message bus. This ensures that even if your endpoint is temporarily down, we will retry delivery with exponential backoff.

sequenceDiagram participant API as "Analyze Service" participant Topic as "Event Bus" participant Worker as "Webhook Worker" participant Hub as "Client Endpoint" API->>Topic: "Publish: analysis.completed" API-->>API: "HTTP 202 Accepted" Topic->>Worker: "Trigger: New Event" Worker->>Worker: "Sign Payload (HMAC-SHA256)" Worker->>Hub: "POST (with PlantCare-Signature)" alt "Endpoint Down (5xx/4xx)" Hub-->>Worker: "Error" Worker->>Worker: "Retry with Exponential Backoff" else "Success (2xx)" Hub-->>Worker: "200 OK" end

3. Stateless Scalability

The Analyze Service is purely stateless. This allows the platform to auto-scale, self-heal, and deploy globally across multiple regions:

  • Auto-Scale: Spawns hundreds of instances in seconds to handle sudden traffic spikes.
  • Self-Heal: If an instance fails, another one immediately takes its place without losing session state.
  • Global Reach: Deploys code to multiple cloud regions simultaneously for low-latency access.

4. Unified Analysis Pipeline

Our Enterprise API handles both mobile and third-party programmatic inputs through a single, intelligent endpoint.

  • Native Mobile Support: Automatically detects storagePath payloads, utilizing optimized images already present in secure GCS buckets.
  • Programmatic Base64 Support: Accepts raw image data from enterprise clients, handling secure ingestion, scanning, and optimization before AI analysis.
  • Multilingual Analysis: Clients can specify a language parameter to receive localized diagnoses and care advice in preferred language.