Skip to content

Commit 1be2ef8

Browse files
committed
modified project implementation
1 parent 8a5c1e4 commit 1be2ef8

3 files changed

Lines changed: 23 additions & 60 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ terraform apply → deploy → verify → terraform destroy
133133
| [`docs/IMPLEMENTATION.md`](docs/implementation.md) | Full build log, phase by phase: local dev → Kind/K8s → CI/CD → monitoring → AWS/Terraform |
134134
| [`docs/ARCHITECTURE.md`](docs/architecture.md) | Full topology diagram and Architecture Decision Records (ADRs) — the *why* behind each choice |
135135
| [`docs/TROUBLESHOOTING.md`](docs/troubleshooting.md) | Real incidents hit while building this, in Symptom → Investigation → Root Cause → Fix → Lesson format |
136-
| [`AWS_IMPLEMENTATION_GUIDE.md`](docs/AWS_IMPLEMENTATION_GUIDE.md) | Full click-by-click Phase 2 walkthrough — account setup through teardown |
136+
| [`docs/AWS_IMPLEMENTATION_GUIDE.md`](docs/AWS_IMPLEMENTATION_GUIDE.md) | Full click-by-click Phase 2 walkthrough — account setup through teardown |
137137
| [`app/README.md`](app/README.md) | API endpoints, environment variables, schema, local run instructions |
138138

139139

‎docs/configuration.md‎

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,21 @@ kubectl create secret generic beyondsquare-db \
3838

3939
---
4040

41-
## 2. Docker Compose (`docker-compose.yaml`)
41+
## 2. Docker Compose ## 2. Docker Compose
4242

43-
```yaml
44-
services:
45-
api:
46-
build: ./app
47-
ports: ["3000:3000"]
48-
environment:
49-
DATABASE_URL: postgres://postgres:postgres@postgres:5432/beyondsquare
50-
REDIS_URL: redis://redis:6379
51-
depends_on: [postgres, redis]
52-
postgres:
53-
image: postgres:16-alpine
54-
environment:
55-
POSTGRES_PASSWORD: postgres
56-
POSTGRES_DB: beyondsquare
57-
ports: ["5432:5432"]
58-
volumes: ["pgdata:/var/lib/postgresql/data"]
59-
redis:
60-
image: redis:7-alpine
61-
ports: ["6379:6379"]
62-
volumes:
63-
pgdata:
64-
```
43+
The local application stack is defined in [`docker-compose.yaml`](../docker-compose.yaml).
6544

66-
Note: the top-level `version:` key is intentionally omitted — Docker Compose v2 no longer requires it, and including it now produces an `is obsolete` warning.
45+
It provides:
6746

68-
`depends_on` only controls **start order**, not readiness — Postgres can still be mid-initialization when the API container starts.
47+
- BeyondSquare API
48+
- PostgreSQL
49+
- Redis
50+
- persistent PostgreSQL volume
51+
- environment-variable based configuration
6952

53+
`depends_on` controls startup order but does not guarantee dependency readiness. The application therefore implements retry-with-backoff during startup.
54+
55+
See [`IMPLEMENTATION.md`](docs/implementation.md) for the execution flow.
7056
---
7157
## 3. Kubernetes — Kustomize layout
7258

@@ -155,8 +141,6 @@ AWS deployment and remains an independently deployable option.
155141
---
156142
## 5. Terraform variables (`terraform/environments/prod/`)
157143

158-
## 5. AWS / Terraform configuration
159-
160144
Terraform manages the AWS infrastructure required by Mode 2.
161145

162146
| Variable | Example | Purpose |
@@ -168,23 +152,13 @@ Terraform manages the AWS infrastructure required by Mode 2.
168152
| `single_nat_gateway` | `true` | Cost-conscious NAT configuration |
169153
| `domain_name` | optional | Route53/ACM configuration when a domain is available |
170154

171-
Remote state backend (`backend.tf`):
155+
Terraform uses an S3 backend for remote state.
172156

173-
```hcl
174-
terraform {
175-
backend "s3" {
176-
bucket = "beyondsquare-tfstate-<yourname>"
177-
key = "prod/terraform.tfstate"
178-
region = "ap-south-1"
179-
}
180-
}
181-
```
157+
The backend configuration is defined in:
182158

183-
Create the bucket once, before the first `terraform init`:
159+
`terraform/environments/prod/backend.tf`
184160

185-
```bash
186-
aws s3 mb s3://beyondsquare-tfstate-<yourname> --region ap-south-1
187-
```
161+
See [`AWS_IMPLEMENTATION_GUIDE.md`](docs/AWS_IMPLEMENTATION_GUIDE.md) for initial backend creation and configuration.
188162

189163
---
190164

‎docs/implementation.md‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,13 @@ A small REST service (FastAPI/Express-equivalent) exposing:
7979
- `GET /cache-demo` — first call returns `{"source":"generated"}`, subsequent calls within the cache window return `{"source":"cache"}`, proving Redis is actually in the read path.
8080
- `GET /metrics` — Prometheus exposition format, via a client library (`prom-client` or equivalent). No code changes are needed later to start scraping it — this is intentional.
8181

82-
### 1.2 Dockerfile — multi-stage, production style
83-
84-
```dockerfile
85-
FROM node:20-alpine AS builder
86-
WORKDIR /app
87-
COPY package*.json ./
88-
RUN npm ci --only=production
89-
COPY src ./src
90-
91-
FROM node:20-alpine
92-
WORKDIR /app
93-
RUN addgroup -S app && adduser -S app -G app
94-
COPY --from=builder /app /app
95-
USER app
96-
EXPOSE 3000
97-
HEALTHCHECK CMD wget -qO- http://localhost:3000/health || exit 1
98-
CMD ["node", "src/index.js"]
99-
```
82+
### 1.2 Container image
83+
84+
The API is containerized using the Dockerfile in `app/Dockerfile`.
85+
86+
The image uses a multi-stage build and runs the application as a non-root user.
87+
88+
See [`app/Dockerfile`](../app/Dockerfile) for the current implementation.
10089

10190
Multi-stage build → smaller final image (no build toolchain shipped). Non-root `USER app` → a security best practice worth naming explicitly in an interview.
10291

0 commit comments

Comments
 (0)