From 9f5e60ce8fc2a2279c6b56d80c9a442b61ca6980 Mon Sep 17 00:00:00 2001 From: Tim Oyelabi Date: Thu, 30 Jul 2026 09:02:49 +0100 Subject: [PATCH] docs: remove stale scratch artifact files from repo root Closes #1093 Remove four stale scratch/artifact files (ISSUE_134_SUMMARY.md, PR_DESCRIPTION.md, issue.md, pr.md) that were remnants of a past PR and not referenced by CI, scripts, or documentation. Add .gitignore patterns to prevent similar scratch markdown files from being committed in the future. --- .gitignore | 8 +- ISSUE_134_SUMMARY.md | 209 ------------------------------------------- PR_DESCRIPTION.md | 85 ------------------ issue.md | 73 --------------- pr.md | 34 ------- 5 files changed, 7 insertions(+), 402 deletions(-) delete mode 100644 ISSUE_134_SUMMARY.md delete mode 100644 PR_DESCRIPTION.md delete mode 100644 issue.md delete mode 100644 pr.md diff --git a/.gitignore b/.gitignore index 305b3a8c..c92a2f56 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,11 @@ coverage # Soroban test runner — auto-generated, never commit **/test_snapshots/ +.npm-cache/ + +# Scratch / draft markdown files — never commit fix.md -.npm-cache/ \ No newline at end of file +issue*.md +pr*.md +ISSUE_*.md +PR_*.md \ No newline at end of file diff --git a/ISSUE_134_SUMMARY.md b/ISSUE_134_SUMMARY.md deleted file mode 100644 index 9b4a9527..00000000 --- a/ISSUE_134_SUMMARY.md +++ /dev/null @@ -1,209 +0,0 @@ -# Issue #134: Backend SSE Stream Updates - COMPLETE ✅ - - -## API Endpoints - -### Subscribe to Events -```bash -GET /events/subscribe?streams=1&streams=2 -GET /events/subscribe?users=GABC... -GET /events/subscribe?all=true -``` - -### Connection Stats -```bash -GET /events/stats -``` - -## Event Types -- `stream.created` - New stream -- `stream.topped_up` - Funds added -- `stream.withdrawn` - Funds withdrawn -- `stream.cancelled` - Stream cancelled -- `stream.completed` - Stream finished - -## Quick Start - -### 1. Start Backend -```bash -cd backend -npm run dev -``` - -### 2. Test with Curl -```bash -curl -N http://localhost:3001/events/subscribe?all=true -``` - -### 3. Open Test Client -```bash -open backend/test-sse-client.html -``` - -### 4. Trigger Event -```bash -curl -X POST http://localhost:3001/streams \ - -H "Content-Type: application/json" \ - -d '{ - "sender": "GABC...", - "recipient": "GDEF...", - "tokenAddress": "CUSDC...", - "ratePerSecond": "1000000", - "depositedAmount": "86400000000", - "startTime": 1708560000 - }' -``` - -## Client Integration - -### JavaScript -```javascript -const es = new EventSource('http://localhost:3001/events/subscribe?streams=1'); -es.addEventListener('stream.created', (e) => { - console.log('New stream:', JSON.parse(e.data)); -}); -``` - -### React -```typescript -import { useStreamEvents } from '@/hooks/useStreamEvents'; - -function Dashboard() { - const { events, connected } = useStreamEvents({ streamIds: ['1'] }); - // Use events in your component -} -``` - -## Acceptance Criteria ✅ - -- [x] Real-time updates without page reload -- [x] Reconnection strategy documented (exponential backoff, 1s-30s) -- [x] Load implications documented (10K connections = 100MB) -- [x] Security implications documented (auth, rate limiting, DDoS) -- [x] Subscription filtering (stream, user, all) -- [x] Connection statistics endpoint -- [x] Complete documentation with examples - -## Performance - -**Single Instance Capacity:** -- 10,000 connections = ~100MB memory -- 1,000 events/sec = minimal CPU -- Per-connection overhead = ~10KB - -## Production Readiness - -### Implemented ✅ -- Subscription filtering -- Automatic cleanup -- Connection statistics -- Error handling -- OpenAPI documentation -- Test client -- React hook example - -### Next Steps (Production) -- [ ] Add JWT authentication -- [ ] Implement per-IP rate limits -- [ ] Add Redis for horizontal scaling -- [ ] Configure reverse proxy -- [ ] Set up monitoring/alerts - -See `backend/PRODUCTION_CHECKLIST.md` for complete deployment guide. - -## Documentation - -| File | Purpose | -|------|---------| -| `backend/SSE_README.md` | Quick start guide | -| `backend/IMPLEMENTATION_COMPLETE.md` | Detailed implementation | -| `backend/docs/SSE_IMPLEMENTATION.md` | Full technical guide | -| `backend/docs/SSE_ARCHITECTURE.md` | Architecture diagrams | -| `backend/PRODUCTION_CHECKLIST.md` | Deployment checklist | -| `backend/examples/useStreamEvents.tsx` | React hook | -| `backend/services/indexer-integration.example.ts` | Blockchain integration | - -## Testing - -All functionality tested with: -- ✅ Curl commands -- ✅ HTML test client -- ✅ Manual stream creation -- ✅ Connection/disconnection -- ✅ Subscription filtering - -## Next Integration Steps - -1. **Connect to Blockchain Indexer** - ```typescript - import { handleBlockchainEvent } from './services/indexer-integration.example.js'; - - stellar.on('StreamCreated', (event) => { - handleBlockchainEvent({ eventType: 'CREATED', ...event }); - }); - ``` - -2. **Add to Frontend** - - Copy `useStreamEvents.tsx` to `frontend/src/hooks/` - - Use in dashboard components - - Display real-time balance updates - -3. **Deploy to Production** - - Follow `PRODUCTION_CHECKLIST.md` - - Add authentication - - Configure Redis - - Set up monitoring - -## Architecture - -``` -Blockchain → Backend → SSE Service → Multiple Clients - ↓ - Redis Pub/Sub (for scaling) -``` - -## Summary - -✅ **Complete implementation** of real-time event streaming -✅ **Production-ready** with comprehensive documentation -✅ **Tested** with multiple clients and scenarios -✅ **Scalable** architecture with Redis support -✅ **Secure** with documented best practices - -**Ready for integration with blockchain indexer and frontend.** - - -## What Was Built - -A production-ready **Server-Sent Events (SSE)** system for real-time stream updates in FlowFi. - -## Key Decisions - -### SSE vs WebSockets -**Chose SSE** for: -- Unidirectional updates (server → client) -- Simpler implementation & debugging -- Automatic browser reconnection -- Better HTTP/2 compatibility -- Lower overhead for broadcasting - -## Implementation Summary - -### Core Files Created (7) -``` -backend/src/ -├── services/sse.service.ts # SSE connection manager -├── controllers/sse.controller.ts # Subscription endpoint -└── routes/events.routes.ts # /events routes - -backend/ -├── docs/ -│ ├── SSE_IMPLEMENTATION.md # Full guide -│ └── SSE_ARCHITECTURE.md # Architecture diagrams -├── examples/useStreamEvents.tsx # React hook -└── test-sse-client.html # Test client -``` - -### Files Modified (2) -- `src/app.ts` - Added events routes -- `src/controllers/stream.controller.ts` - Added broadcasting diff --git a/PR_DESCRIPTION.md b/PR_DESCRIPTION.md deleted file mode 100644 index a6920e29..00000000 --- a/PR_DESCRIPTION.md +++ /dev/null @@ -1,85 +0,0 @@ -## Description -This PR resolves four CI/CD and infrastructure issues: -1. **Issue #897 [CI] Frontend tests run without coverage and are never uploaded to Codecov**: Added frontend test coverage to CI workflow and configured Codecov to track frontend coverage. -2. **Issue #894 [Infra] No .dockerignore for the backend build context**: Created `.dockerignore` for backend to exclude unnecessary files from Docker build context. -3. **Issue #892 [CI] Workflows have no concurrency control**: Added concurrency control to `ci.yml` and `security.yml` workflows to cancel superseded runs. -4. **Issue #891 [CI] pr-test-gate.yml fully duplicates ci.yml's backend and contracts jobs**: Removed `pr-test-gate.yml` as it duplicates tests already covered by `ci.yml`. - -## Type of Change - - -- [x] 🔧 Infrastructure/CI improvements -- [x] 🐛 Bug fix (non-breaking change which fixes an issue) -- [ ] ✨ New feature (non-breaking change which adds functionality) -- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] 📚 Documentation update -- [ ] ⚡ Performance improvement -- [ ] 🧪 Test addition or update - -## Related Issues - - - -Closes #897 -Closes #894 -Closes #892 -Closes #891 - -## Changes Made -- **Frontend Test Coverage (#897)**: - - Updated `.github/workflows/ci.yml` to run `npm run test:coverage` instead of `npm test` for frontend - - Added frontend coverage upload step to Codecov with `frontend` flag - - Updated `.github/codecov.yml` to include frontend project status with `target: auto` -- **Docker Build Optimization (#894)**: - - Created `backend/.dockerignore` to exclude: `node_modules`, `dist`, `coverage`, `.env*`, `*.log`, `src/generated` - - This reduces Docker build context size and prevents secrets from being sent to build cache -- **Concurrency Control (#892)**: - - Added `concurrency` block to `.github/workflows/ci.yml` with `cancel-in-progress: true` - - Added `concurrency` block to `.github/workflows/security.yml` with `cancel-in-progress: true` - - Both workflows use group: `${{ github.workflow }}-${{ github.ref }}` -- **Remove Duplicate Workflow (#891)**: - - Deleted `.github/workflows/pr-test-gate.yml` as it duplicated backend and contracts tests already in `ci.yml` - - This eliminates duplicate Postgres services and redundant test runs on PRs to main - -## Testing - - -### Test Coverage -- [ ] Unit tests added/updated -- [ ] Integration tests added/updated -- [x] Manual testing performed - -### Test Steps - -1. Verify frontend tests run with coverage in CI by checking workflow logs -2. Verify frontend coverage appears in Codecov dashboard -3. Verify Docker build context size is reduced by checking build logs -4. Verify concurrent workflow runs cancel previous runs by pushing multiple commits to same branch -5. Verify PRs to main no longer launch duplicate Postgres services - -## Breaking Changes - - - -None. Branch protection rules should be updated to point to `ci.yml` jobs instead of `pr-test-gate.yml` if they were previously configured. - -## Screenshots/Demo - - -## Checklist - - -- [x] My code follows the project's style guidelines -- [x] I have performed a self-review of my own code -- [x] I have commented my code, particularly in hard-to-understand areas -- [x] I have made corresponding changes to the documentation -- [x] My changes generate no new warnings -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes -- [x] Any dependent changes have been merged and published -- [x] I have checked for breaking changes and documented them if applicable - -## Additional Notes - -- Branch protection rules may need to be updated to reference `ci.yml` jobs instead of the removed `pr-test-gate.yml` workflow -- Frontend coverage threshold is set to `auto` in Codecov to allow establishing a baseline before setting specific targets diff --git a/issue.md b/issue.md deleted file mode 100644 index bb1ea394..00000000 --- a/issue.md +++ /dev/null @@ -1,73 +0,0 @@ -#867 [Testing] Add unit tests for TopUpModal (precision-filtered input, validation, new-total preview) -Repo Avatar -LabsCrypt/flowfi -Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0 - -Why this matters -frontend/src/components/stream-creation/TopUpModal.tsx has untested behavior: the onChange regex/precision filter that rejects non-numeric and >7-decimal input, validateAmountInput + hasValidPrecision in validate(), the newTotal = currentDeposited + parsedAmount preview, and Enter-to-confirm. No test file references TopUpModal. - -Acceptance criteria - Test that non-numeric and over-precision keystrokes are rejected by the input - Test that Confirm is blocked and an error shows for empty/invalid/over-precision amounts - Test that the new-total preview only appears for a positive amount and equals currentDeposited + amount - Test that onConfirm is called with (streamId, amount) on confirm/Enter -Files to touch -frontend/src/components/stream-creation/TopUpModal.tsx -Out of scope -Soroban top-up transaction wiring - - -#866 [Testing] Add unit tests for ScheduleStep rate calculation and preview rendering -Repo Avatar -LabsCrypt/flowfi -Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0 - -Why this matters -frontend/src/components/stream-creation/ScheduleStep.tsx has untested logic: totalSeconds via SECONDS_PER_UNIT, ratePerSecond = amount/totalSeconds, the formattedRate sec/min/hr buckets, and the ratePerDayPreview currency formatting. components.test.tsx covers RecipientStep/AmountStep/CancelConfirmModal but ScheduleStep has no test. - -Acceptance criteria - Test ratePerSecond/total-seconds for at least seconds, days, and months units - Test that EURC uses a Euro symbol (not $) and XLM uses the token suffix in the rate/day preview - Test that zero/empty amount or duration renders no rate preview - Test the sec vs /min vs /hr formatting threshold branches -Files to touch -frontend/src/components/stream-creation/ScheduleStep.tsx -Out of scope -Full StreamCreationWizard integration test - -#864 [Frontend] StreamDetailsModal & CancelConfirmModal render raw token amounts; remaining uses float subtraction -Repo Avatar -LabsCrypt/flowfi -Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0 - -Why this matters -frontend/src/components/dashboard/StreamDetailsModal.tsx:30,94-95,106,138 renders {stream.withdrawn}/{stream.deposited}/{remaining} with no formatter, and remaining = stream.deposited - stream.withdrawn is plain JS float subtraction (artifacts like 99.99999999). CancelConfirmModal.tsx:39,106-110,118 has the identical raw-render. The stream-detail page uses formatAmount for the same values. - -Acceptance criteria - deposited/withdrawn/remaining are rendered through a shared amount formatter (consistent decimals) - remaining is computed without producing floating-point display artifacts - StreamDetailsModal and CancelConfirmModal match the formatting used on the stream-detail page -Files to touch -frontend/src/components/dashboard/StreamDetailsModal.tsx -frontend/src/components/stream-creation/CancelConfirmModal.tsx -Out of scope -Changing the Stream data model - -#865 [Frontend] Settings Display Preferences (Default Token / Amount Format / Decimal Places) are a no-op - never consumed anywhere -Repo Avatar -LabsCrypt/flowfi -Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0 - -Why this matters -frontend/src/app/settings/page.tsx:244-307 lets users pick Default Token, Amount Format, and Decimal Places and persists them to localStorage, and useSettings exports formatAmountWithPreference/getDecimalPlaces/getAmountFormat/getDisplayCurrency. A repo-wide grep shows these helpers and useSettings have ZERO consumers - every amount uses hardcoded formatters. The settings controls produce no visible effect. - -Acceptance criteria - Amount rendering reads the user's decimalPlaces/amountFormat preference in the main amount displays, or - If the preference feature is not ready, the non-functional controls are removed/marked clearly - Changing Decimal Places visibly changes displayed amounts on at least the dashboard and stream detail views -Files to touch -frontend/src/app/settings/page.tsx -frontend/src/hooks/useSettings.ts -Out of scope -Theme toggle (which does work) -Currency conversion / price feeds \ No newline at end of file diff --git a/pr.md b/pr.md deleted file mode 100644 index 02277619..00000000 --- a/pr.md +++ /dev/null @@ -1,34 +0,0 @@ -# Pull Request: Frontend cleanup — dead code removal, modal a11y, shared API helpers - -## Summary - -This PR addresses four related frontend maintenance issues in a single branch: - -- **#556** — Remove unused `useCancelStream` / `useWithdrawStream` hooks and their dead REST helpers (`cancelStream` / `withdrawStream` in `lib/api/streams.ts`). Active cancel/withdraw flows remain on Soroban (stream detail) and `useIncomingStreams`. -- **#557** — Delete the never-mounted `Banner` component and `banner.config.ts` (no global announcement banner is wired today). -- **#558** — Consolidate duplicated stream-endpoint resolver and stroop conversion helpers into `lib/api/_shared.ts`; `dashboard.ts` and `api/streams.ts` now import from one source. -- **#559** — Add `role="dialog"`, `aria-modal`, `aria-labelledby`, Tab focus trapping, and focus restoration on close for `StreamCreationWizard`, `CancelConfirmModal`, and `TopUpModal` via a shared `useModalDialog` hook (Escape-to-close preserved). - -## Changes by issue - -| Issue | Files | -|-------|-------| -| #556 | Removed `hooks/useCancelStream.ts`, `hooks/useWithdrawStream.ts`; trimmed `lib/api/streams.ts` | -| #557 | Removed `components/ui/Banner.tsx`, `lib/banner.config.ts` | -| #558 | Added `lib/api/_shared.ts`; updated `lib/dashboard.ts`, `lib/api/streams.ts` | -| #559 | Added `hooks/useModalDialog.ts`; updated stream-creation modals | - -## Test plan - -- [ ] `npm run build --workspace=frontend` passes -- [ ] `npm test --workspace=frontend` passes (existing utils tests unchanged) -- [ ] Confirm no imports of removed hooks, Banner, or `cancelStream`/`withdrawStream` REST helpers -- [ ] Open **Create Stream** wizard — Tab cycles within modal only; Escape closes; focus returns to trigger -- [ ] Open **Cancel Stream** confirm modal — same keyboard/a11y behavior; Escape blocked while submitting -- [ ] Open **Top Up** modal — input auto-focused; Tab trapped; Escape closes when idle -- [ ] Dashboard and incoming streams pages still load stream lists correctly (shared endpoint resolver) - -## Notes - -- `shortenAddress` in `dashboard.ts` was left local (dashboard-only); `streams.ts` continues using `shortenPublicKey` from wallet utils. -- Overlap with **#456** (authenticate/remove unused cancel/withdraw REST helpers) is resolved here by deleting the dead REST helpers entirely.