Skip to content

Commit ebac869

Browse files
committed
Add professional architecture diagram (PNG + draw.io)
1 parent d20f65a commit ebac869

File tree

4 files changed

+241
-42
lines changed

4 files changed

+241
-42
lines changed

README.md

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,19 @@ DocAI is a B2B SaaS product that enables businesses to extract structured data f
1616

1717
## Architecture
1818

19-
```
20-
┌─────────────────────────────────────────┐
21-
│ DocAI Platform │
22-
┌──────────────┐ ├─────────────────────────────────────────┤
23-
│ │ HTTPS │ │
24-
│ Customer │───────────────────▶│ ┌─────────────┐ ┌──────────────┐ │
25-
│ App/SDK │ │ │ API Gateway │───▶│ Cognito │ │
26-
│ │◀───────────────────│ │ (REST/WS) │ │ (Auth) │ │
27-
└──────────────┘ JSON Response │ └──────┬──────┘ └──────────────┘ │
28-
│ │ │
29-
│ ▼ │
30-
│ ┌─────────────────────────────────┐ │
31-
│ │ Lambda Functions │ │
32-
│ │ ┌─────────┐ ┌──────────────┐ │ │
33-
│ │ │ Upload │ │ Process │ │ │
34-
│ │ │ Handler │ │ Document │ │ │
35-
│ │ └────┬────┘ └──────┬───────┘ │ │
36-
│ └───────┼──────────────┼──────────┘ │
37-
│ │ │ │
38-
│ ▼ ▼ │
39-
│ ┌────────────┐ ┌─────────────────┐ │
40-
│ │ S3 │ │ Textract │ │
41-
│ │ (Docs) │ │ (AI/OCR) │ │
42-
│ └────────────┘ └─────────────────┘ │
43-
│ │ │ │
44-
│ └──────┬───────┘ │
45-
│ ▼ │
46-
│ ┌──────────────────────────────────┐ │
47-
│ │ DynamoDB │ │
48-
│ │ - Users/Tenants │ │
49-
│ │ - Documents │ │
50-
│ │ - Usage/Billing │ │
51-
│ └──────────────────────────────────┘ │
52-
│ │ │
53-
│ ▼ │
54-
│ ┌──────────────────────────────────┐ │
55-
│ │ Webhooks (EventBridge) │ │
56-
│ │ → Notify customer on completion │ │
57-
│ └──────────────────────────────────┘ │
58-
│ │
59-
└─────────────────────────────────────────┘
60-
```
19+
![DocAI Platform Architecture](docs/architecture.png)
20+
21+
*[Edit in draw.io](docs/architecture.drawio)*
22+
23+
### Data Flow
24+
1. **Customer** sends document via HTTPS to CloudFront CDN
25+
2. **API Gateway** authenticates request via Cognito JWT
26+
3. **Upload Handler** generates presigned URL, stores metadata in DynamoDB
27+
4. **Customer** uploads document directly to S3
28+
5. **S3 Event** triggers Document Processor Lambda
29+
6. **Textract** performs OCR and data extraction
30+
7. **Results** stored in DynamoDB, event sent to EventBridge
31+
8. **Webhook** delivers results to customer's callback URL
6132

6233
## Features
6334

docs/architecture.drawio

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<mxfile host="app.diagrams.net" modified="2024-01-17T00:00:00.000Z" agent="DocAI" version="22.0.0">
2+
<diagram name="DocAI Architecture" id="docai-arch">
3+
<mxGraphModel dx="1200" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="900" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
8+
<!-- Title -->
9+
<mxCell id="title" value="DocAI Platform - AI-Powered Document Intelligence" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=24;fontStyle=1" vertex="1" parent="1">
10+
<mxGeometry x="400" y="20" width="500" height="40" as="geometry" />
11+
</mxCell>
12+
13+
<!-- Customer -->
14+
<mxCell id="customer" value="Customer&#xa;Application" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
15+
<mxGeometry x="40" y="300" width="80" height="100" as="geometry" />
16+
</mxCell>
17+
18+
<!-- AWS Cloud Container -->
19+
<mxCell id="aws-cloud" value="AWS Cloud" style="swimlane;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;rounded=1;startSize=30;" vertex="1" parent="1">
20+
<mxGeometry x="180" y="80" width="1200" height="700" as="geometry" />
21+
</mxCell>
22+
23+
<!-- Edge Layer -->
24+
<mxCell id="edge-layer" value="Edge Layer" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;rounded=1;" vertex="1" parent="aws-cloud">
25+
<mxGeometry x="20" y="50" width="200" height="280" as="geometry" />
26+
</mxCell>
27+
28+
<mxCell id="cloudfront" value="CloudFront&#xa;CDN" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.cloudfront;fillColor=#F58536;gradientColor=none;" vertex="1" parent="edge-layer">
29+
<mxGeometry x="80" y="40" width="76.5" height="93" as="geometry" />
30+
</mxCell>
31+
32+
<mxCell id="apigateway" value="API Gateway&#xa;REST API" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.api_gateway;fillColor=#D9A741;gradientColor=none;" vertex="1" parent="edge-layer">
33+
<mxGeometry x="80" y="160" width="76.5" height="93" as="geometry" />
34+
</mxCell>
35+
36+
<!-- Security -->
37+
<mxCell id="security" value="Security" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;rounded=1;" vertex="1" parent="aws-cloud">
38+
<mxGeometry x="20" y="350" width="200" height="150" as="geometry" />
39+
</mxCell>
40+
41+
<mxCell id="cognito" value="Cognito&#xa;Auth &amp; JWT" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.cognito;fillColor=#AD688B;gradientColor=none;" vertex="1" parent="security">
42+
<mxGeometry x="80" y="30" width="76.5" height="93" as="geometry" />
43+
</mxCell>
44+
45+
<!-- Compute Layer -->
46+
<mxCell id="compute" value="Compute Layer" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;rounded=1;" vertex="1" parent="aws-cloud">
47+
<mxGeometry x="250" y="50" width="280" height="450" as="geometry" />
48+
</mxCell>
49+
50+
<mxCell id="lambda-upload" value="Upload&#xa;Handler" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.lambda_function;fillColor=#F58534;gradientColor=none;" vertex="1" parent="compute">
51+
<mxGeometry x="100" y="40" width="69" height="72" as="geometry" />
52+
</mxCell>
53+
54+
<mxCell id="lambda-process" value="Document&#xa;Processor" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.lambda_function;fillColor=#F58534;gradientColor=none;" vertex="1" parent="compute">
55+
<mxGeometry x="100" y="160" width="69" height="72" as="geometry" />
56+
</mxCell>
57+
58+
<mxCell id="lambda-get" value="Get Document&#xa;Handler" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.lambda_function;fillColor=#F58534;gradientColor=none;" vertex="1" parent="compute">
59+
<mxGeometry x="100" y="280" width="69" height="72" as="geometry" />
60+
</mxCell>
61+
62+
<mxCell id="lambda-webhook" value="Webhook&#xa;Delivery" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.lambda_function;fillColor=#F58534;gradientColor=none;" vertex="1" parent="compute">
63+
<mxGeometry x="100" y="370" width="69" height="72" as="geometry" />
64+
</mxCell>
65+
66+
<!-- AI/ML -->
67+
<mxCell id="aiml" value="AI/ML" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;rounded=1;" vertex="1" parent="aws-cloud">
68+
<mxGeometry x="560" y="120" width="200" height="150" as="geometry" />
69+
</mxCell>
70+
71+
<mxCell id="textract" value="Textract&#xa;OCR &amp; Extraction" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.textract;fillColor=#01A88D;" vertex="1" parent="aiml">
72+
<mxGeometry x="80" y="30" width="78" height="78" as="geometry" />
73+
</mxCell>
74+
75+
<!-- Data Layer -->
76+
<mxCell id="data" value="Data Layer" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;rounded=1;" vertex="1" parent="aws-cloud">
77+
<mxGeometry x="560" y="290" width="320" height="210" as="geometry" />
78+
</mxCell>
79+
80+
<mxCell id="s3" value="Documents&#xa;Bucket" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.s3;fillColor=#E05243;gradientColor=none;" vertex="1" parent="data">
81+
<mxGeometry x="50" y="50" width="76.5" height="93" as="geometry" />
82+
</mxCell>
83+
84+
<mxCell id="dynamodb-docs" value="Documents&#xa;Table" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.dynamo_db;fillColor=#2E73B8;gradientColor=none;" vertex="1" parent="data">
85+
<mxGeometry x="160" y="30" width="72" height="81" as="geometry" />
86+
</mxCell>
87+
88+
<mxCell id="dynamodb-users" value="Users &amp;&#xa;Usage" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.dynamo_db;fillColor=#2E73B8;gradientColor=none;" vertex="1" parent="data">
89+
<mxGeometry x="160" y="120" width="72" height="81" as="geometry" />
90+
</mxCell>
91+
92+
<!-- Integration -->
93+
<mxCell id="integration" value="Integration" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;rounded=1;" vertex="1" parent="aws-cloud">
94+
<mxGeometry x="560" y="520" width="200" height="150" as="geometry" />
95+
</mxCell>
96+
97+
<mxCell id="eventbridge" value="EventBridge&#xa;Events" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.eventbridge;fillColor=#E7157B;" vertex="1" parent="integration">
98+
<mxGeometry x="80" y="30" width="78" height="78" as="geometry" />
99+
</mxCell>
100+
101+
<!-- Monitoring -->
102+
<mxCell id="monitoring" value="Observability" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;rounded=1;" vertex="1" parent="aws-cloud">
103+
<mxGeometry x="920" y="200" width="200" height="200" as="geometry" />
104+
</mxCell>
105+
106+
<mxCell id="cloudwatch" value="CloudWatch&#xa;Metrics &amp; Logs" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.cloudwatch;fillColor=#759C3E;gradientColor=none;" vertex="1" parent="monitoring">
107+
<mxGeometry x="80" y="50" width="76.5" height="93" as="geometry" />
108+
</mxCell>
109+
110+
<!-- Connections -->
111+
<mxCell id="edge1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;strokeColor=#0066CC;" edge="1" parent="1" source="customer" target="cloudfront">
112+
<mxGeometry relative="1" as="geometry" />
113+
</mxCell>
114+
<mxCell id="edge1-label" value="HTTPS" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="edge1">
115+
<mxGeometry x="-0.2" relative="1" as="geometry">
116+
<mxPoint as="offset" />
117+
</mxGeometry>
118+
</mxCell>
119+
120+
</root>
121+
</mxGraphModel>
122+
</diagram>
123+
</mxfile>

docs/architecture.png

236 KB
Loading

docs/generate_diagram.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"""
2+
DocAI Platform Architecture Diagram
3+
Generates a professional AWS architecture diagram using the diagrams library
4+
"""
5+
from diagrams import Diagram, Cluster, Edge
6+
from diagrams.aws.compute import Lambda
7+
from diagrams.aws.database import Dynamodb
8+
from diagrams.aws.storage import S3
9+
from diagrams.aws.network import APIGateway, CloudFront
10+
from diagrams.aws.security import Cognito
11+
from diagrams.aws.ml import Textract
12+
from diagrams.aws.integration import Eventbridge
13+
from diagrams.aws.management import Cloudwatch
14+
from diagrams.aws.general import Users
15+
16+
# Graph attributes for professional look
17+
graph_attr = {
18+
"fontsize": "20",
19+
"bgcolor": "white",
20+
"pad": "0.5",
21+
"splines": "spline",
22+
}
23+
24+
node_attr = {
25+
"fontsize": "12",
26+
}
27+
28+
edge_attr = {
29+
"fontsize": "10",
30+
}
31+
32+
with Diagram(
33+
"DocAI Platform - Document Intelligence SaaS",
34+
filename="/tmp/docai-platform/docs/architecture",
35+
show=False,
36+
direction="LR",
37+
graph_attr=graph_attr,
38+
node_attr=node_attr,
39+
edge_attr=edge_attr,
40+
):
41+
# External users
42+
users = Users("Customers")
43+
44+
with Cluster("AWS Cloud"):
45+
# Edge / Entry
46+
with Cluster("Edge Layer"):
47+
cdn = CloudFront("CloudFront\nCDN")
48+
api = APIGateway("API Gateway\nREST API")
49+
50+
# Auth
51+
with Cluster("Security"):
52+
auth = Cognito("Cognito\nAuth & JWT")
53+
54+
# Compute
55+
with Cluster("Compute Layer"):
56+
upload_fn = Lambda("Upload\nHandler")
57+
process_fn = Lambda("Document\nProcessor")
58+
get_fn = Lambda("Get Document\nHandler")
59+
webhook_fn = Lambda("Webhook\nDelivery")
60+
61+
# AI/ML
62+
with Cluster("AI/ML"):
63+
textract = Textract("Textract\nOCR & Extraction")
64+
65+
# Data
66+
with Cluster("Data Layer"):
67+
docs_bucket = S3("Documents\nBucket")
68+
docs_table = Dynamodb("Documents\nTable")
69+
users_table = Dynamodb("Users &\nUsage")
70+
71+
# Integration
72+
with Cluster("Integration"):
73+
events = Eventbridge("EventBridge\nEvents")
74+
75+
# Monitoring
76+
with Cluster("Observability"):
77+
monitoring = Cloudwatch("CloudWatch\nMetrics & Logs")
78+
79+
# Flow connections
80+
users >> Edge(label="HTTPS") >> cdn >> api
81+
api >> Edge(label="Authorize") >> auth
82+
83+
api >> upload_fn
84+
api >> get_fn
85+
86+
upload_fn >> Edge(label="Generate\nPresigned URL") >> docs_bucket
87+
upload_fn >> docs_table
88+
upload_fn >> users_table
89+
90+
docs_bucket >> Edge(label="S3 Event") >> process_fn
91+
process_fn >> textract
92+
textract >> process_fn
93+
process_fn >> docs_table
94+
process_fn >> events
95+
96+
events >> webhook_fn
97+
98+
get_fn >> docs_table
99+
100+
# Monitoring connections (dashed)
101+
upload_fn >> Edge(style="dashed", color="gray") >> monitoring
102+
process_fn >> Edge(style="dashed", color="gray") >> monitoring
103+
get_fn >> Edge(style="dashed", color="gray") >> monitoring
104+
105+
print("Diagram generated: /tmp/docai-platform/docs/architecture.png")

0 commit comments

Comments
 (0)