๐ŸŽ

EU SwagHub Portal

Enterprise Rewards & Inventory Management Platform for Amazon EU Logistics

AWS Amplify Cognito SAML Lambda + API Gateway S3 Data Lake 3 Divisions ยท 200K+ Users

๐Ÿ—๏ธ System Architecture

How the components connect โ€” from browser to storage

๐ŸŒ
Browser
User's device
โ–ผ
โšก
AWS Amplify
Static hosting ยท HTTPS
โ–ผ
๐Ÿ”
Cognito + Federate
SAML ยท PKCE ยท Midway SSO
๐Ÿšช
API Gateway
REST API ยท CORS
โ–ผ
โš™๏ธ
Lambda (AMZL)
Validate ยท Sanitize ยท Write
โš™๏ธ
Lambda (ATS)
Validate ยท Sanitize ยท Write
โš™๏ธ
Lambda (FC)
Validate ยท Sanitize ยท Write
โ–ผ
๐Ÿ“ฆ
S3 Data Bucket
Structured by division ยท site ยท date
๐Ÿ—„๏ธ
DynamoDB
Fast queries ยท RBAC (planned)

๐Ÿ“Š Data Flow

How data moves from site upload to employee dashboard

1

Site Manager Uploads CSV

Swag-Zuteilung files (Attendance, Birthday, Dragonfly) with employee_id and swag_amount columns. CSV only, strict validation.

2

Client-Side Validation

CSV Validator checks exact columns, data types, empty cells, duplicates, and scans for injection attacks before upload.

3

Secure API Upload

JWT token sent with request. Lambda extracts user identity from token, validates site ownership, checks for duplicates via MD5 hash.

4

Server-Side Validation

Lambda loads schema from S3 config, re-validates CSV, sanitizes all values, scans for security threats. Rejects invalid data.

5

Structured S3 Storage

Data saved to: {Division}/data-upload/{type}/{site}/{date}/{user}/{file}.csv with upload manifest containing full audit trail.

6

Employee Dashboard

DynamoDB serves real-time balance, transaction history, and product catalog. Points calculated from earned minus spent. (Planned)

๐Ÿ” Authentication Flow

Midway SSO via Amazon Federate SAML + Cognito PKCE

A

User Opens App

3D landing page appears. Body hidden (opacity: 0) until authenticated. User clicks "Sign In with Midway".

B

Cognito PKCE Flow

App generates code_verifier + code_challenge. Redirects to Cognito Hosted UI with SAML identity provider.

C

Federate + Midway

Cognito redirects to Amazon Federate SAML endpoint. Federate authenticates via Midway (badge or PIN).

D

Token Exchange

SAML assertion returns to Cognito. Cognito exchanges authorization code for JWT tokens (ID + Access + Refresh).

E

Session Established

JWT stored in sessionStorage. User claims extracted (alias, email, department, job level). App becomes visible.

F

Ongoing Security

Token auto-refresh before expiry. 15-minute idle timeout with warning. Logout clears all tokens and redirects to landing.

๐Ÿ“ S3 Data Structure

Organized by division, category, site, and date

eu-swag-hub-inventory-management-datastructure/
โ”œโ”€โ”€ AMZL/ โ† Amazon Logistics
โ”œโ”€โ”€ ATS/ โ† Amazon Transportation
โ””โ”€โ”€ FC/ โ† Fulfillment Centers

Each division contains:
  โ”œโ”€โ”€ _config/ Schema validation files
  โ”œโ”€โ”€ data-upload/ User-uploaded files
  โ”‚   โ”œโ”€โ”€ swag-points/ Zuteilung (Attendance, Birthday, Dragonfly)
  โ”‚   โ”œโ”€โ”€ budget-allocation/ Site budgets
  โ”‚   โ””โ”€โ”€ inventory-order/ Product catalog
  โ”œโ”€โ”€ data-transactions/ App-generated records
  โ”œโ”€โ”€ data-consolidation/ Reports & balances
  โ””โ”€โ”€ data-archive/ Retained old data

๐Ÿ› ๏ธ Technology Stack

Built on AWS serverless โ€” scales automatically

โšก

AWS Amplify

Static hosting, auto-deploy

๐Ÿ”

Amazon Cognito

OAuth2 PKCE, JWT tokens

๐Ÿข

Amazon Federate

SAML SSO, Midway auth

๐Ÿšช

API Gateway

REST API, CORS, routing

โš™๏ธ

AWS Lambda

Python 3.12, serverless

๐Ÿ“ฆ

Amazon S3

Data lake, structured storage

๐Ÿ—„๏ธ

DynamoDB

Fast queries, auto-scale (planned)

๐Ÿ“Š

QuickSight

Analytics dashboards

๐Ÿ›ก๏ธ Security Layers

Defense in depth โ€” every layer validates

๐Ÿ” Authentication

Midway SSO via Federate SAML. PKCE flow prevents token interception. JWT signed by Cognito.

๐Ÿ›ก๏ธ Authorization

JWT claims verified on backend. User identity from token only โ€” never from frontend input.

๐Ÿ“‹ Data Validation

Strict schema: exact columns, data types, ranges. Rejects extra columns, empty cells, duplicates.

๐Ÿงน Sanitization

Trim whitespace, strip HTML/scripts, remove non-printable chars. Max cell length enforced.

๐Ÿšซ Injection Prevention

Blocks formula injection (=, +, -), script tags, JS URIs, eval(), DOM manipulation attempts.

๐ŸŒ Cross-Site Protection

Users can only upload for their own site. Site code validated from JWT location claim and filename.

๐Ÿ“ก Transport Security

HTTPS only. CORS restricted to Amplify domain. 20-second request timeout.

๐Ÿ“ Audit Trail

Every upload creates a manifest with user, timestamp, file hash, row count. Duplicate detection via MD5.