<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hamza Imran</title>
    <description>The latest articles on DEV Community by Hamza Imran (@hamza_imran_ebef24c018200).</description>
    <link>https://dev.to/hamza_imran_ebef24c018200</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4005674%2Fc6a5ed8c-6622-4988-ab53-ebfed28e6eac.png</url>
      <title>DEV Community: Hamza Imran</title>
      <link>https://dev.to/hamza_imran_ebef24c018200</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hamza_imran_ebef24c018200"/>
    <language>en</language>
    <item>
      <title>How I Built a Shadow AI Governance Platform on a DynamoDB Single-Table Design</title>
      <dc:creator>Hamza Imran</dc:creator>
      <pubDate>Sat, 27 Jun 2026 18:06:32 +0000</pubDate>
      <link>https://dev.to/hamza_imran_ebef24c018200/how-i-built-a-shadow-ai-governance-platform-on-a-dynamodb-single-table-design-3h7e</link>
      <guid>https://dev.to/hamza_imran_ebef24c018200/how-i-built-a-shadow-ai-governance-platform-on-a-dynamodb-single-table-design-3h7e</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc08eub7e72runx3awrjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc08eub7e72runx3awrjs.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The proliferation of unsanctioned, locally executed Artificial Intelligence (AI) models (Shadow AI) running inside corporate workstations via Ollama, Llama.cpp, or LM Studio has created a massive blind spot for enterprise security teams. &lt;/p&gt;

&lt;p&gt;Because local inference occurs entirely in system memory, network-layer proxies (like CASBs) are completely blind to it. Because the tools are benignly signed binaries, kernel-level EDRs (like CrowdStrike Falcon) don't trigger alerts when they read sensitive source code or spreadsheets offline.&lt;/p&gt;

&lt;p&gt;To solve this, I built &lt;strong&gt;LifecycleZero&lt;/strong&gt;-a B2B SaaS platform that monitors local endpoint AI engines, streams telemetry, and isolates compromised hosts. &lt;/p&gt;

&lt;p&gt;Here is the database and system architecture blueprint showing how to design this platform for performance and scale.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. The Database Blueprint: Single-Table DynamoDB Design
&lt;/h3&gt;

&lt;p&gt;We consolidated all B2B data entities (Tenant Settings, Employees, Hardware Assets, Telemetry Event Streams, and Audit Custody Logs) into a single physical table (&lt;code&gt;LifecycleZero_Assets&lt;/code&gt;).&lt;/p&gt;

&lt;h4&gt;
  
  
  Entity Relationship and Index Mapping
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Entity&lt;/th&gt;
&lt;th&gt;PK (Partition Key)&lt;/th&gt;
&lt;th&gt;SK (Sort Key)&lt;/th&gt;
&lt;th&gt;GSI1PK (Index 1)&lt;/th&gt;
&lt;th&gt;GSI1SK (Index 1)&lt;/th&gt;
&lt;th&gt;GSI2PK (Index 2 - Sparse)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tenant&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TENANT#&amp;lt;TenantId&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;METADATA&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Asset&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TENANT#&amp;lt;TenantId&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ASSET#&amp;lt;AssetId&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;EMP#&amp;lt;EmployeeId&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;STATE#&amp;lt;Status&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TENANT#&amp;lt;TenantId&amp;gt;#ACTION_REQ&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Telemetry&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TENANT#&amp;lt;TenantId&amp;gt;#TELEMETRY#SHARD#&amp;lt;0-9&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TELEMETRY#&amp;lt;AssetId&amp;gt;#&amp;lt;TS&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ASSET#&amp;lt;AssetId&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DATE#&amp;lt;TS&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TENANT#&amp;lt;TenantId&amp;gt;#ALERT#&amp;lt;Risk&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Audit Log&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TENANT#&amp;lt;TenantId&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;AUDIT#&amp;lt;AssetId&amp;gt;#&amp;lt;TS&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Key Database Highlights
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cryptographic Tenant Isolation&lt;/strong&gt;: Enforced by prefixing all partition keys with &lt;code&gt;TENANT#&amp;lt;OrgId&amp;gt;&lt;/code&gt; mapped directly from Clerk B2B authentication sessions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sparse Indexing (GSI2) for Dashboards&lt;/strong&gt;: 99.9% of telemetry events are benign. Indexing every heartbeat would bloat storage and query costs. We built a Sparse GSI (&lt;code&gt;GSI2PK&lt;/code&gt;) that only populates when a security alert is flagged as &lt;code&gt;CRITICAL&lt;/code&gt; or &lt;code&gt;WARNING&lt;/code&gt;. The dashboard queries &lt;code&gt;GSI2&lt;/code&gt; directly, retrieving active incidents in milliseconds via cheap O(1) index scans.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Telemetry Write Sharding&lt;/strong&gt;: A fleet of 10,000+ endpoints streaming heartbeats every 5 seconds to a single partition key will throttle DynamoDB's 1,000 WCU limit. We shard raw telemetry partition keys across 10 physical partitions (&lt;code&gt;PK = TENANT#&amp;lt;TenantId&amp;gt;#TELEMETRY#SHARD#&amp;lt;0-9&amp;gt;&lt;/code&gt;) using a random hash function.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Transaction Integrity &amp;amp; ACID Containment
&lt;/h3&gt;

&lt;p&gt;When a security administrator quarantines a host, consistency is critical. If a host status is updated to &lt;code&gt;ISOLATED&lt;/code&gt; but the audit custody log fails to write, we breach compliance standards.&lt;/p&gt;

&lt;p&gt;We solved this using DynamoDB’s &lt;code&gt;TransactWriteItems&lt;/code&gt; to execute the isolation command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ConditionCheck &amp;amp; Asset Update&lt;/strong&gt;: Verifies that the asset exists in the partition and its current status is active (not already &lt;code&gt;ISOLATED&lt;/code&gt;). Updates &lt;code&gt;Status&lt;/code&gt; to &lt;code&gt;ISOLATED&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutable Audit Log&lt;/strong&gt;: Appends a chronological custody log (&lt;code&gt;SK = AUDIT#&amp;lt;AssetId&amp;gt;#&amp;lt;Timestamp&amp;gt;&lt;/code&gt;) detailing the operator ID, action type, and compliance justification.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If either step fails, the entire transaction rolls back instantly, eliminating inconsistent states.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Decoupling the Ingest Pipeline with SQS
&lt;/h3&gt;

&lt;p&gt;Direct database writes from thousands of concurrent endpoint agents can trigger write capacity lockouts. &lt;/p&gt;

&lt;p&gt;Our Next.js API Gateway ingests telemetry payloads, checks device isolation status, and immediately pushes them to an &lt;strong&gt;AWS SQS queue&lt;/strong&gt; before returning &lt;code&gt;202 Accepted&lt;/code&gt; in sub-50ms. A TypeScript worker daemon pulls events asynchronously using SQS long-polling to run AI-powered risk evaluations.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>database</category>
      <category>nextjs</category>
      <category>security</category>
    </item>
  </channel>
</rss>
