<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>API Documentation on PlantCare Enterprise</title>
    <link>https://plantcare.farm/en/api/</link>
    <description>Recent content in API Documentation on PlantCare Enterprise</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://plantcare.farm/en/api/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Security &amp; Authorization</title>
      <link>https://plantcare.farm/en/api/security/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://plantcare.farm/en/api/security/</guid>
      <description>&lt;p&gt;The PlantCare Enterprise API implements a &lt;strong&gt;Zero Trust&lt;/strong&gt; security model. Every request is authenticated at multiple layers to ensure data integrity and privacy.&lt;/p&gt;
&lt;h2 id=&#34;1-client-to-api-authorization-api-keys&#34;&gt;1. Client-to-API Authorization (API Keys)&lt;/h2&gt;
&lt;p&gt;Clients authenticate with a permanent &lt;code&gt;pk_ent_&lt;/code&gt; key provided during onboarding. This key is validated by the &lt;strong&gt;Google Cloud API Gateway&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&#34;mermaid&#34;&gt;
sequenceDiagram
participant Client
participant GW as &#34;API Gateway&#34;
participant KV as &#34;Secret Manager&#34;
participant API as &#34;Backend Service&#34;
Client-&gt;&gt;GW: &#34;Request with Bearer pk_ent_...&#34;
GW-&gt;&gt;KV: &#34;Validate Key &amp; Permissions&#34;
alt &#34;Valid Key&#34;
    GW-&gt;&gt;API: &#34;Proxy Request + Identity Headers&#34;
else &#34;Invalid Key&#34;
    GW--&gt;&gt;Client: &#34;401 Unauthorized&#34;
end
&lt;/div&gt;
&lt;hr&gt;
&lt;h2 id=&#34;2-storage-security-malware-scanning&#34;&gt;2. Storage Security (Malware Scanning)&lt;/h2&gt;
&lt;p&gt;Every image uploaded to the Enterprise API is automatically scanned for viruses and malware before it is processed. This is handled by an asynchronous &lt;strong&gt;Cloud Storage Trigger&lt;/strong&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>The PlantCare Enterprise API implements a <strong>Zero Trust</strong> security model. Every request is authenticated at multiple layers to ensure data integrity and privacy.</p>
<h2 id="1-client-to-api-authorization-api-keys">1. Client-to-API Authorization (API Keys)</h2>
<p>Clients authenticate with a permanent <code>pk_ent_</code> key provided during onboarding. This key is validated by the <strong>Google Cloud API Gateway</strong>.</p>
<div class="mermaid">
sequenceDiagram
participant Client
participant GW as "API Gateway"
participant KV as "Secret Manager"
participant API as "Backend Service"
Client->>GW: "Request with Bearer pk_ent_..."
GW->>KV: "Validate Key & Permissions"
alt "Valid Key"
    GW->>API: "Proxy Request + Identity Headers"
else "Invalid Key"
    GW-->>Client: "401 Unauthorized"
end
</div>
<hr>
<h2 id="2-storage-security-malware-scanning">2. Storage Security (Malware Scanning)</h2>
<p>Every image uploaded to the Enterprise API is automatically scanned for viruses and malware before it is processed. This is handled by an asynchronous <strong>Cloud Storage Trigger</strong>.</p>
<div class="mermaid">
sequenceDiagram
participant GCS as "Cloud Storage"
participant Func as "Scan Function"
participant Scan as "Malware Scanner"
GCS->>Func: "Event: Object Finalized"
Func->>Scan: "OIDC Authorized Scan Request"
Scan->>Scan: "Malware Signature Analysis"
alt "Infected File"
    Scan-->>Func: "Status: infected"
    Func->>GCS: "DELETE Object"
    Func->>Func: "Log Security Incident"
else "Clean File"
    Scan-->>Func: "Status: clean"
end
</div>
<hr>
<h2 id="3-service-to-service-authorization-oidc">3. Service-to-Service Authorization (OIDC)</h2>
<p>When the <strong>Backend Service</strong> needs to call internal services (like the Image Processor), it does not use a shared secret. Instead, it uses <strong>OIDC ID Tokens</strong> fetched from the Google Metadata Server.</p>
<div class="mermaid">
sequenceDiagram
participant API as "Analyze Service"
participant Meta as "GCP Metadata Server"
participant Proc as "Image Processor"
API->>Meta: "Fetch ID Token (Audience: Processor URL)"
Meta-->>API: "Signed JWT ID Token"
API->>Proc: "POST /process (Authorization: Bearer JWT)"
Proc->>Proc: "Validate JWT with Google PubKeys"
alt "Valid Token"
    Proc-->>API: "200 OK (Processed Image)"
else "Invalid Token"
    Proc-->>API: "403 Forbidden"
end
</div>
<hr>
<h2 id="3-network-isolation">3. Network Isolation</h2>
<p>To further harden the system, the <strong>Image Processor</strong> is configured with <code>INGRESS_TRAFFIC_INTERNAL_ONLY</code>. This means it is physically unreachable from the public internet, even with a valid token. Communication is routed through a private <strong>VPC Serverless Connector</strong>.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Architecture &amp; Scalability</title>
      <link>https://plantcare.farm/en/api/architecture/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://plantcare.farm/en/api/architecture/</guid>
      <description>&lt;p&gt;The PlantCare Enterprise API is built on a &lt;strong&gt;Cloud-Native, Stateless&lt;/strong&gt; architecture designed to handle massive IoT workloads with zero downtime.&lt;/p&gt;
&lt;h2 id=&#34;1-edge-security--metering&#34;&gt;1. Edge Security &amp;amp; Metering&lt;/h2&gt;
&lt;p&gt;Every request to our Enterprise endpoints is intercepted by a high-performance &lt;strong&gt;Security Middleware&lt;/strong&gt; that enforces security policies and usage quotas at the edge before any business logic is executed.&lt;/p&gt;
&lt;div class=&#34;mermaid&#34;&gt;
sequenceDiagram
participant Client
participant Edge as &#34;Security Middleware&#34;
participant DB as &#34;Quota/Audit Store&#34;
participant API as &#34;Analyze Service&#34;
Client-&gt;&gt;Edge: &#34;Request (with API Token)&#34;
Edge-&gt;&gt;Edge: &#34;Validate Payload Size (&lt;10MB)&#34;
Edge-&gt;&gt;Edge: &#34;Verify Token Format (API2)&#34;
Edge-&gt;&gt;DB: &#34;Check Quota &amp; Role (RBAC)&#34;
alt &#34;Quota Exceeded&#34;
    Edge--&gt;&gt;Client: &#34;429 Too Many Requests&#34;
else &#34;Authorized&#34;
    Edge-&gt;&gt;DB: &#34;Log Audit Trail&#34;
    Edge-&gt;&gt;API: &#34;Forward Request&#34;
    API--&gt;&gt;Client: &#34;Analysis Result&#34;
end
&lt;/div&gt;
&lt;hr&gt;
&lt;h2 id=&#34;2-reliable-webhook-delivery&#34;&gt;2. Reliable Webhook Delivery&lt;/h2&gt;
&lt;p&gt;Our webhook system is decoupled from the main request lifecycle using &lt;strong&gt;Google Cloud Pub/Sub&lt;/strong&gt;. This ensures that even if your endpoint is temporarily down, we will retry delivery with exponential backoff.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>The PlantCare Enterprise API is built on a <strong>Cloud-Native, Stateless</strong> architecture designed to handle massive IoT workloads with zero downtime.</p>
<h2 id="1-edge-security--metering">1. Edge Security &amp; Metering</h2>
<p>Every request to our Enterprise endpoints is intercepted by a high-performance <strong>Security Middleware</strong> that enforces security policies and usage quotas at the edge before any business logic is executed.</p>
<div class="mermaid">
sequenceDiagram
participant Client
participant Edge as "Security Middleware"
participant DB as "Quota/Audit Store"
participant API as "Analyze Service"
Client->>Edge: "Request (with API Token)"
Edge->>Edge: "Validate Payload Size (<10MB)"
Edge->>Edge: "Verify Token Format (API2)"
Edge->>DB: "Check Quota & Role (RBAC)"
alt "Quota Exceeded"
    Edge-->>Client: "429 Too Many Requests"
else "Authorized"
    Edge->>DB: "Log Audit Trail"
    Edge->>API: "Forward Request"
    API-->>Client: "Analysis Result"
end
</div>
<hr>
<h2 id="2-reliable-webhook-delivery">2. Reliable Webhook Delivery</h2>
<p>Our webhook system is decoupled from the main request lifecycle using <strong>Google Cloud Pub/Sub</strong>. This ensures that even if your endpoint is temporarily down, we will retry delivery with exponential backoff.</p>
<div class="mermaid">
sequenceDiagram
participant API as "Analyze Service"
participant Topic as "Pub/Sub Topic"
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
</div>
<hr>
<h2 id="3-stateless-scalability">3. Stateless Scalability</h2>
<p>The <strong>Analyze Service</strong> is purely stateless. This allows the platform to:</p>
<ul>
<li><strong>Auto-Scale</strong>: Handle sudden traffic spikes by spawning hundreds of instances in seconds.</li>
<li><strong>Self-Heal</strong>: If an instance fails, another one immediately takes its place without losing session state.</li>
<li><strong>Global Reach</strong>: Deploy code to multiple GCP regions simultaneously for low-latency access.</li>
</ul>
<hr>
<h2 id="4-unified-analysis-pipeline">4. Unified Analysis Pipeline</h2>
<p>Our Go-based Enterprise API handles both mobile and third-party programmatic inputs through a single, intelligent endpoint.</p>
<ul>
<li><strong>Native Mobile Support</strong>: Automatically detects <code>storagePath</code> payloads from our mobile apps, utilizing optimized WebP files already present in our secure Cloud Storage buckets.</li>
<li><strong>Programmatic Base64 Support</strong>: Accepts raw image data from enterprise clients, automatically handling secure ingestion, malware scanning, and optimization before AI analysis.</li>
<li><strong>Multilingual Analysis</strong>: Enterprise clients and mobile users can specify a <code>language</code> parameter to receive localized diagnoses and care advice in their preferred language.</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
