Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
F
finwise-miniapp-be
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • ThinhNC
  • finwise-miniapp-be
  • Merge Requests
  • !19

Merged
Opened Aug 06, 2026 by ThinhNC@ThinhNC
  • Report abuse
Report abuse

feat(system): implement system optimization, security hardening, detailed...

Overview

This pull request implements comprehensive system optimizations, security hardening, detailed health monitoring, and containerized deployment configuration to make the FinWise backend ready for production.

Key Changes

1. Architectural & Core Utilities

  • Logger Service: Added a custom level-based LoggerService that outputs structured JSON in production (safely redacting sensitive parameters like password, token, apiKey) and pretty-printed format in development.
  • Cache Service: Built a pluggable caching wrapper using ioredis with an automated memory-safe fallback to prevent memory leaks if Redis is offline.
  • Lock Service: Built a distributed lock mechanism using Redis (SET NX PX) with a local fallback to prevent overlapping background task processing.

2. Throttling & Concurrency Guardrails

  • Rate Limiting: Re-implemented the Express rateLimitMiddleware to support Redis-backed rate limiting with a self-pruning memory-safe Map fallback.
  • Worker Locking: Locked the background tick in NotificationWorker to ensure only one instance executes reminder checks at a time in scale-out container environments.

3. Caching & Performance Optimization

  • System Categories Caching: Cached read-only system categories for 1 hour, bypassing the database for common app-startup list/tree requests.
  • Financial Reports Caching: Cached report aggregates (overview, cash flow, categories spending, budget performance) for 5 minutes per user query.
  • Cache Invalidation Triggers: Configured instant cache invalidation upon any mutations to Transactions, Wallets, Budgets, and Saving Goals.

4. System Health Monitoring

  • Detailed Health Endpoint: Replaced the basic /health check with an active diagnostics controller returning:
    • Server resource utilization (memory rss/heap, process uptime).
    • Database availability & round-trip query latency (ms).
    • Cache adapter state (Redis connection vs. Memory fallback).
  • Swagger API Docs: Updated the /health API schemas to document the detailed JSON response structure.

5. Deployment, CI/CD & Code Quality

  • Dockerfile: Defined a multi-stage production Docker build using a lightweight Node.js Alpine base, executing under a non-root node user.
  • Docker Compose: Configured healthy checks dependency order so that the Node application waits for PostgreSQL and Redis to be fully responsive.
  • CI pipeline: Created a GitHub Actions workflow .github/workflows/ci.yml verifying TypeScript compilation, Prisma schemas, and ESLint.
  • ESLint Configuration: Set up a flat eslint.config.mjs resolving all source-code formatting and type rules.

Verification Results

  • Compilation: pnpm run build compiles successfully.
  • Linting: pnpm run lint executes cleanly with zero errors.
  • Database validation: pnpm exec prisma validate completes successfully.
  • Health Check Probe: Proved database latency and Redis connection status:
    {
      "success": true,
      "status": "ok",
      "timestamp": "2026-08-06T10:18:58.937Z",
      "uptime": 11.58,
      "memory": { "rss": "72.16 MB", "heapTotal": "23.69 MB", "heapUsed": "20.54 MB" },
      "database": { "status": "up", "latencyMs": 3 },
      "cache": { "status": "up", "type": "redis" }
    }

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b feat/system-optimization-security-deployment origin/feat/system-optimization-security-deployment

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/develop
git merge --no-ff feat/system-optimization-security-deployment

Step 4. Push the result of the merge to GitLab

git push origin develop

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 0
  • Commits 1
  • Changes 23
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: ThinhNC/finwise-miniapp-be!19

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.