How ubaidrmn/lambdacrm works
Project type and purpose
• This is a full-stack, serverless CRM application (“LambdaCRM”).
• Frontend: React app built with Vite and TailwindCSS.
• Backend: Single AWS Lambda function (TypeScript) behind API Gateway.
• Database: DynamoDB with a single-table design.
• Auth: AWS Cognito.
• Infrastructure as code: AWS CDK.
• Local development: Docker Compose with LocalStack.
File-structure insights
• Top-level directories:
• backend/ – Lambda code (controllers, services, repositories, schemas, types)
• frontend/ – React app (features, shared components, UI primitives, hooks, lib utilities)
• cdk/ – CDK stacks and tests
• docker-compose.local.yml & localstack-deploy.sh – local dev orchestration
• Backend uses an internal router (route.registry.ts) to dispatch API Gateway requests to controllers.
• Clear separation in backend of controllers → services → repositories → database lib.
• Frontend organized by features (auth, contacts, leads, dashboard, settings, static) and shared/UI components.
• CDK sets up Cognito user pool, API Gateway, Lambda, DynamoDB table, and any IAM roles.
Key README architecture notes
• API Gateway → Lambda
• Lambda interacts with DynamoDB (single table)
• Cognito for authentication flows
• Frontend deployed (e.g., S3/CloudFront) and calls same API endpoint
• CDK bootstraps all AWS resources
• LocalStack emulates AWS services locally via Docker Compose
Main components
a. User / Browser (React UI)
b. CDN / Hosting (S3 + CloudFront)
c. API Gateway
d. Lambda Function (single entrypoint)
– Internal layers: controllers, services, repositories, data access
e. DynamoDB Table (single-table design)
f. Cognito User Pool (Auth)
g. AWS CDK (IaC – not a runtime component, but used to provision resources)
h. LocalStack + Docker Compose (for local dev)
Relationships and data flows
• Browser → HTTP(S) → CDN/Hosting → static React bundle
• Browser → REST API calls → API Gateway → Lambda
• Lambda → SDK calls → DynamoDB
• Browser ↔ Cognito (sign-in/up, tokens)
• Lambda uses Cognito JWT for auth/authorization (via auth.ts lib)
• CDK provisions all AWS components
• Local dev environment: Browser / Local Lambda / Local DynamoDB via LocalStack
Architectural patterns & principles
• Serverless microservice (single Lambda) with internal routing
• Single-table design in DynamoDB for all entities (users, leads, projects)
• Layered backend: controllers → services → repositories → database abstraction
• Feature-driven frontend (domain boundaries)
• Infrastructure as code for repeatability & version control