Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .copilotignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AI_RULES.md
README.md
5 changes: 5 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Role: Senior Backend Engineer (Node.js, TypeScript, PostgreSQL, Redis, Prisma)
- Package Manager: Strict pnpm usage only. Never suggest npm or yarn.
- TypeScript: Strict typing. Banned keyword: any. Explicit return types required.
- Formatting: Professional English comments only. Strictly zero emojis across codebase and logs.
- Logging: Pino logger only via src/utils/logger.js. Zero console.log.
14 changes: 7 additions & 7 deletions PROJECT_CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ distributed-ticket-engine-redis/
* **Objective:** Implement a native Redis `ZSET` Sliding Window Log Rate Limiter middleware to drop abusive traffic at the API edge.
* **Target Deliverables:** `src/middlewares/rateLimiter.ts`, `src/scripts/lua/sliding_window.lua`, `src/config/redis.config.ts`.

- [ ] **Phase 2: Database Protection & Stampede Shield** `[STATUS: IN_PROGRESS]`
- [x] **Phase 2: Database Protection & Stampede Shield** `[STATUS: COMPLETED]`
* **Objective:** Build a Distributed Mutex Lock (`SET NX PX`) re-hydration guard to defend PostgreSQL against thundering herd spikes when 1M+ key caches expire.
* **Target Deliverables:** `src/services/stampede.service.ts`, production-tuned `redis.conf` LRU memory policies.
* **Completed Deliverables:** `src/services/stampede.service.ts`, `src/scripts/lua/release_mutex.lua`, `tests/concurrency/stampede.concurrency.test.ts`, production-tuned `redis.conf` eviction policy, and seating-map API wiring.

- [ ] **Phase 3: Atomic Concurrency & Race Condition Elimination** `[STATUS: NOT_STARTED]`
* **Objective:** Eliminate double-booking by executing check-and-hold seat locks inside atomic C-like Redis Lua scripts (`atomic_seat_lock.lua`).
Expand All @@ -143,12 +143,12 @@ distributed-ticket-engine-redis/

## 🎯 Current Active Milestone Focus

**Active Milestone:** **Phase 2 — Database Protection & Cache Stampede Shield**
**Completed Milestone:** **Phase 2 — Database Protection & Cache Stampede Shield**
* **Active Tasks:**
1. Implement a distributed mutex using Redis `SET NX PX`.
2. Build cache-aside seating-map re-hydration around the mutex.
3. Configure cache TTL and production Redis eviction policy.
4. Add stampede protection tests for concurrent cache misses.
1. Implemented a distributed mutex using Redis `SET NX PX`.
2. Implemented cache-aside seating-map re-hydration around the mutex.
3. Configured cache TTL and production Redis eviction policy.
4. Added stampede protection tests for concurrent cache misses.

---

Expand Down
25 changes: 18 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
services:
app:
build: .
container_name: ticket_engine_app
restart: always
ports:
- "5000:5000"
env_file:
- .env
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
REDIS_URL: redis://redis:6379
depends_on:
- postgres
- redis

redis:
image: redis:alpine
container_name: ticket_engine_redis
restart: always
ports:
- "6379:6379"
volumes:
- redis_data:/data

Expand All @@ -13,11 +26,9 @@ services:
container_name: ticket_engine_postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres123
POSTGRES_DB: ticket-engine-redis-db
ports:
- "5432:5432"
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- postgres_data:/var/lib/postgresql/data

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"zod": "^4.5.4"
},
"devDependencies": {
"@jest/globals": "^30.5.1",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.6",
"@types/jest": "^30.0.0",
Expand Down
Loading
Loading