7.8 KiB
7.8 KiB
Epic 1: Backend Foundation, Tooling & "Hello World" API
Goal: To establish the core backend project infrastructure in its dedicated repository, including robust development tooling and initial AWS CDK setup for essential services. By the end of this epic:
- A simple "hello world" API endpoint (AWS API Gateway + Lambda) must be deployed and testable via
curl, returning a dynamic message. - The backend project must have ESLint, Prettier, Jest (unit testing), and esbuild (TypeScript bundling) configured and operational.
- Basic unit tests must exist for the "hello world" Lambda function.
- Code formatting and linting checks should be integrated into a pre-commit hook and/or a basic CI pipeline stub.
User Stories
Story 1.1: Initialize Backend Project using TS-TEMPLATE-STARTER
- User Story Statement: As a Developer, I want to create the
bmad-daily-digest-backendGit repository and initialize it using the existingTS-TEMPLATE-STARTER, ensuring all foundational tooling (TypeScript, Node.js 22, ESLint, Prettier, Jest, esbuild) is correctly configured and operational for this specific project, so that I have a high-quality, standardized development environment ready for application logic. - Acceptance Criteria (ACs):
- A new, private Git repository named
bmad-daily-digest-backendmust be created on GitHub. - The contents of the
TS-TEMPLATE-STARTERproject must be copied/cloned into this new repository. package.jsonmust be updated (project name, version, description).- Project dependencies must be installable.
- TypeScript setup (
tsconfig.json) must be verified for Node.js 22, esbuild compatibility; project must compile. - ESLint and Prettier configurations must be operational; lint/format scripts must execute successfully.
- Jest configuration must be operational; test scripts must execute successfully with any starter example tests.
- Irrelevant generic demo code from starter should be removed.
index.ts/index.test.tscan remain as placeholders. - A standard
.gitignoreand an updated projectREADME.mdmust be present.
- A new, private Git repository named
Story 1.2: Pre-commit Hook Implementation
- User Story Statement: As a Developer, I want pre-commit hooks automatically enforced in the
bmad-daily-digest-backendrepository, so that code quality standards (like linting and formatting) are checked and applied to staged files before any code is committed, thereby maintaining codebase consistency and reducing trivial errors. - Acceptance Criteria (ACs):
- A pre-commit hook tool (e.g., Husky) must be installed and configured.
- A tool for running linters/formatters on staged files (e.g.,
lint-staged) must be installed and configured. - Pre-commit hook must trigger
lint-stagedon staged.tsfiles. lint-stagedmust be configured to run ESLint (--fix) and Prettier (--write).- Attempting to commit files with auto-fixable issues must result in fixes applied and successful commit.
- Attempting to commit files with non-auto-fixable linting errors must abort the commit with error messages.
- Committing clean files must proceed without issues.
Story 1.3: "Hello World" Lambda Function Implementation & Unit Tests
- User Story Statement: As a Developer, I need a simple "Hello World" AWS Lambda function implemented in TypeScript within the
bmad-daily-digest-backendproject. This function, when invoked, should return a dynamic greeting message including the current date and time, and it must be accompanied by comprehensive Jest unit tests, so that our basic serverless compute functionality, testing setup, and TypeScript bundling are validated. - Acceptance Criteria (ACs):
- A
src/features/publicApi/statusHandler.tsfile (or similar according to final backend structure) must contain the Lambda handler. - Handler must be AWS Lambda compatible (event, context, Promise response).
- Successful execution must return JSON:
statusCode: 200, body withmessage: "Hello from BMad Daily Digest Backend, today is [current_date] at [current_time].". - Date and time in message must be dynamic.
- A corresponding Jest unit test file (e.g.,
src/features/publicApi/statusHandler.test.ts) must be created. - Unit tests must verify: 200 status, valid JSON body, expected
messagefield, "Hello from..." prefix, dynamic date/time portion (use mockedDate). - All unit tests must pass.
- esbuild configuration must correctly bundle the handler.
- A
Story 1.4: AWS CDK Setup for "Hello World" API (Lambda & API Gateway)
- User Story Statement: As a Developer, I want to define the necessary AWS infrastructure (Lambda function and API Gateway endpoint) for the "Hello World" service using AWS CDK (Cloud Development Kit) in TypeScript, so that the infrastructure is version-controlled, repeatable, and can be deployed programmatically.
- Acceptance Criteria (ACs):
- AWS CDK (v2) must be a development dependency.
- CDK app structure must be initialized (e.g., in
cdk/). - A new CDK stack (e.g.,
BmadDailyDigestBackendStack) must be defined in TypeScript. - CDK stack must define an AWS Lambda resource for the "Hello World" function (Node.js 22, bundled code reference, handler entry point, basic IAM role for CloudWatch logs, free-tier conscious settings).
- CDK stack must define an AWS API Gateway (HTTP API preferred) with a route (e.g.,
GET /statusorGET /hello) triggering the Lambda, secured with the "Frontend Read API Key". - CDK stack must be synthesizable (
cdk synth) without errors. - CDK code must adhere to project ESLint/Prettier standards.
- Mechanism for passing Lambda environment variables via CDK must be in place.
Story 1.5: "Hello World" API Deployment & Manual Invocation Test
- User Story Statement: As a Developer, I need to deploy the "Hello World" API (defined in AWS CDK) to an AWS environment and successfully invoke its endpoint using a tool like
curl(including the API Key), so that I can verify the end-to-end deployment process and confirm the basic API is operational in the cloud. - Acceptance Criteria (ACs):
- The AWS CDK stack for "Hello World" API must deploy successfully to a designated AWS account/region.
- The API Gateway endpoint URL for the
/status(or/hello) route must be retrievable post-deployment. - A
GETrequest to the deployed endpoint, including the correctx-api-keyheader, must receive a response. - HTTP response status must be 200 OK.
- Response body must be JSON containing the expected dynamic "Hello..." message.
- Basic Lambda invocation logs must be visible in AWS CloudWatch Logs.
Story 1.6: Basic CI/CD Pipeline Stub with Quality Gates
- User Story Statement: As a Developer, I need a basic Continuous Integration (CI) pipeline established for the
bmad-daily-digest-backendrepository, so that code quality checks (linting, formatting, unit tests) and the build process are automated upon code pushes and pull requests, ensuring early feedback and maintaining codebase health. - Acceptance Criteria (ACs):
- A CI workflow file (e.g., GitHub Actions in
.github/workflows/main.yml) must be created. - Pipeline must trigger on pushes to
mainand PRs targetingmain. - Pipeline must include steps for: checkout, Node.js 22 setup, dependency install, ESLint check, Prettier format check, Jest unit tests, esbuild bundle.
- Pipeline must fail if any lint, format, test, or bundle step fails.
- A successful CI run on the
mainbranch must be demonstrated. - CI pipeline for MVP does not need to perform AWS deployment.
- A CI workflow file (e.g., GitHub Actions in