How aaronshaf/dynamodb-admin works
Project Type and Purpose
• This is a full-stack CLI/web application written in TypeScript that provides a graphical user interface for managing a local or in-memory DynamoDB instance (DynamoDB Local, dynalite, localstack, etc.).
• The README describes both a global CLI mode and an embeddable library mode; core functionality is to serve HTML/CSS/JS to a browser, handle HTTP requests, and proxy those requests to a DynamoDB endpoint via the AWS SDK v3.
File Structure Analysis
• bin/
• Entry point script (dynamodb-admin.ts) that parses CLI args or environment variables, configures the DynamoDB client, and starts the server.
• lib/
• backend.ts: sets up and configures the Express/Koa-like server (middleware, view engine, static assets).
• routes.ts: defines HTTP routes for listing tables, creating tables, getting items, scanning, purging, etc.
• actions/: each file implements a specific DynamoDB operation (getPage, listAllTables, purgeTable).
• dynamoDbApi.ts: wraps AWS SDK v3 calls in a uniform interface.
• util.ts, utils/asyncMiddleware.ts: helper functions for error-handling, key parsing, etc.
• types.d.ts: shared TypeScript definitions.
• public/: static assets (CSS themes, vendor JS for ACE editor or Bootstrap).
• views/: EJS templates for server-side rendering—table lists, create-table form, item views, error display, partials (layout, breadcrumbs).
• Configuration and build:
• rollup.config.ts and tsconfig.json for bundling and TS compilation.
• nodemon.json, Dockerfile, GitHub Actions workflows for CI/Publishing.
Key Technologies and Patterns
• Node.js + TypeScript
• Express-style server (middleware pattern)
• AWS SDK v3 DynamoDBClient
• Server-side rendering with EJS templates
• CLI args & environment variables for configuration
• Modular “actions” layer encapsulating database operations
• MVC-like separation: views (EJS) ↔ routes (controller) ↔ actions (model)
Main Components and Relationships
a. Client (Browser)
• Consumes HTML/CSS/JS served from the app’s public/ and views/
• Initiates HTTP requests to the server (GET /tables, POST /create, GET /items/:key, etc.)
b. Server (Node.js App)
• Entry Point (bin/dynamodb-admin.ts) → config & instantiate DynamoDBClient → createServer()
• HTTP Server (lib/backend.ts)
– Middleware (async error handling, static assets, request parsing)
– Routes (lib/routes.ts) map endpoints to action handlers
– View Engine (EJS) renders templates in response
c. Action Layer (lib/actions/*.ts)
• Each action calls dynamoDbApi to perform a specific DynamoDB operation
d. Data Layer (lib/dynamoDbApi.ts)
• Wraps AWS SDK v3 DynamoDBClient commands
• Configuration (lib/config.ts) reads endpoint, credentials, region
e. DynamoDB Endpoint
• Local DynamoDB, dynalite, localstack or remote AWS instance
Architectural Patterns / Principles
• Single-process monolith with clear modular decomposition
• MVC (Views + Controllers/Routes + Model/Action layer)
• Dependency Injection: server creation accepts a preconfigured DynamoDBClient
• Separation of concerns: action handlers contain business logic, routes only wire HTTP to actions, views only handle presentation