# petdroo/aws-sensor-pipeline architecture

> Architecture diagram of the GitHub repository petdroo/aws-sensor-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/petdroo/aws-sensor-pipeline
- Repository: https://github.com/petdroo/aws-sensor-pipeline

## Overview

This repository implements an AWS sensor-data ingestion pipeline. S3 objects arrive as SQS-notified events, the Lambda handler validates and parses CSV records, flags statistical anomalies, and writes metrics to PostgreSQL; structured logs report processing and anomalies. A separate initializer creates the database schema and grants the ingestion user access. Terraform files indicate deployment, storage, networking, and monitoring components, but their resource wiring was not excerpted, so those relationships are shown only where code supports them or as unverified dashed links.

Main entry points: [`src/handler.py`](https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/handler.py) (CSV processor), [`terraform/workloads/rds.tf`](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/rds.tf) (RDS configuration), [`src/db_init.py`](https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/db_init.py) (Schema initializer), [`terraform/workloads/lambda.tf`](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/lambda.tf) (Lambda deployment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion and analysis"]
  node_handler["CSV processor<br/>[handler.py]"]
  node_metrics[("Sensor metrics<br/>[handler.py]")]
  node_logger["JSON logger<br/>[logger.py]"]
end

subgraph group_database["Database setup"]
  node_initializer["Schema initializer<br/>[db_init.py]"]
end

subgraph group_infra["AWS infrastructure"]
  node_lambda_tf["Lambda deployment<br/>[lambda.tf]"]
  node_s3_tf["S3 configuration<br/>[s3.tf]"]
  node_sqs_tf["SQS configuration<br/>[sqs.tf]"]
  node_rds_tf["RDS configuration<br/>[rds.tf]"]
  node_vpc_tf["VPC configuration<br/>[vpc.tf]"]
  node_monitoring_tf["Monitoring setup<br/>[monitoring.tf]"]
  node_bootstrap["Bootstrap stack<br/>[main.tf]"]
end

node_sqs["SQS events"]
node_s3[("S3 objects")]
node_postgres[("PostgreSQL")]
node_rds_auth["RDS IAM auth"]

node_sqs -.->|"invokes"| node_handler
node_handler -->|"reads objects"| node_s3
node_handler -->|"inserts rows"| node_metrics
node_handler -->|"requests token"| node_rds_auth
node_handler -->|"logs events"| node_logger
node_initializer -->|"creates schema"| node_postgres
node_initializer -->|"logs status"| node_logger
node_handler -->|"connects"| node_postgres
node_s3_tf -.->|"configures"| node_s3
node_sqs_tf -.->|"configures"| node_sqs
node_lambda_tf -.->|"deploys"| node_handler
node_rds_tf -.->|"configures"| node_postgres
node_vpc_tf -.->|"supports networking"| node_rds_tf
node_monitoring_tf -.->|"monitors"| node_lambda_tf
node_bootstrap -.->|"supports provisioning"| node_rds_tf

click node_handler "https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/handler.py"
click node_metrics "https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/handler.py"
click node_logger "https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/logger.py"
click node_initializer "https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/db_init.py"
click node_lambda_tf "https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/lambda.tf"
click node_s3_tf "https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/s3.tf"
click node_sqs_tf "https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/sqs.tf"
click node_rds_tf "https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/rds.tf"
click node_vpc_tf "https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/vpc.tf"
click node_monitoring_tf "https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/monitoring.tf"
click node_bootstrap "https://github.com/petdroo/aws-sensor-pipeline/blob/main/bootstrap/main.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_handler,node_metrics,node_logger toneBlue
class node_initializer,node_s3,node_postgres toneAmber
class node_lambda_tf,node_s3_tf,node_sqs_tf,node_rds_tf,node_vpc_tf,node_monitoring_tf,node_bootstrap toneMint
class node_sqs,node_rds_auth toneIndigo
```

## Components

### Ingestion and analysis

- [CSV processor](https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/handler.py): `src/handler.py`
- [Sensor metrics](https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/handler.py): `src/handler.py`
- [JSON logger](https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/logger.py): `src/logger.py`

### Database setup

- [Schema initializer](https://github.com/petdroo/aws-sensor-pipeline/blob/main/src/db_init.py): `src/db_init.py`

### AWS infrastructure

- [Lambda deployment](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/lambda.tf): `terraform/workloads/lambda.tf`
- [S3 configuration](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/s3.tf): `terraform/workloads/s3.tf`
- [SQS configuration](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/sqs.tf): `terraform/workloads/sqs.tf`
- [RDS configuration](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/rds.tf): `terraform/workloads/rds.tf`
- [VPC configuration](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/vpc.tf): `terraform/workloads/vpc.tf`
- [Monitoring setup](https://github.com/petdroo/aws-sensor-pipeline/blob/main/terraform/workloads/monitoring.tf): `terraform/workloads/monitoring.tf`
- [Bootstrap stack](https://github.com/petdroo/aws-sensor-pipeline/blob/main/bootstrap/main.tf): `bootstrap/main.tf`

### Other components

- **SQS events**
- **S3 objects**
- **PostgreSQL**
- **RDS IAM auth**

## Connections

- SQS events → CSV processor: invokes
- CSV processor → S3 objects: reads objects (evidence: `src/handler.py`)
- CSV processor → Sensor metrics: inserts rows (evidence: `src/handler.py`)
- CSV processor → RDS IAM auth: requests token (evidence: `src/handler.py`)
- CSV processor → JSON logger: logs events (evidence: `src/handler.py`)
- Schema initializer → PostgreSQL: creates schema (evidence: `src/db_init.py`)
- Schema initializer → JSON logger: logs status (evidence: `src/db_init.py`)
- CSV processor → PostgreSQL: connects (evidence: `src/handler.py`)
- S3 configuration → S3 objects: configures
- SQS configuration → SQS events: configures
- Lambda deployment → CSV processor: deploys
- RDS configuration → PostgreSQL: configures
- VPC configuration → RDS configuration: supports networking
- Monitoring setup → Lambda deployment: monitors
- Bootstrap stack → RDS configuration: supports provisioning
