You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the development compose file to run both services with live reload and all required env vars configured:
29
+
30
+
```bash
31
+
docker compose -f docker-compose.dev.yml up --build
32
+
```
33
+
34
+
This will start:
35
+
36
+
- Frontend (dev server): http://localhost:3000
37
+
- Backend API (dev): http://localhost:3005
38
+
- WebSocket (dev): ws://localhost:8080
39
+
26
40
Local development (without Docker)
27
41
28
42
- Frontend:
@@ -47,6 +61,46 @@ Tests
47
61
- Frontend E2E: run Cypress after starting the frontend with `npm run cypress:open` for local `npm run cypress:run` for CI/CD pipelines
48
62
- Backend unit test run in `server/market-trading-service` with `npm run test` (Jest), `npm run test:watch`, `npm run test:coverage` also available if working on test and see the coverage
49
63
64
+
## Assumptions & Trade-offs
65
+
66
+
### Assumptions
67
+
68
+
- Data model: simplified ticker domain (price, change, volume, 24h high/low); no corporate actions, splits, multi-currency, or latency-sensitive guarantees.
69
+
70
+
- Simulation: price history and live ticks are synthetic for UX validation, not financial accuracy.
71
+
72
+
- Environment: single-node backend with in-memory storage is acceptable for this challenge; no cross-process persistence required.
73
+
74
+
- Client: no auth is required to view market data.
75
+
76
+
- Contracts: WebSocket message shapes are minimal and stable: `{"type":"connected","payload":{"clientId"}}` and `{"type":"data","payload":{"ticker"}}`. REST endpoints are reachable for initial bootstrap/fallback.
77
+
78
+
- CI/CD via github actions to run test on PR
79
+
80
+
- Used Code Rabbit to review
81
+
82
+
### Trade-offs
83
+
84
+
- Real-time delivery vs simplicity: WebSocket for live updates plus a one-time REST bootstrap for fast first paint (slight duplication accepted for responsiveness).
85
+
86
+
- Subscription scope: initial subscribe-to-all for clarity; future optimization could subscribe only to visible/selected symbols.
87
+
88
+
- Update cadence: immediate per-tick broadcasts, no batching/debouncing; simple but more frames under heavy load. Batching window (e.g., 50–150 ms) can be added later.
89
+
90
+
- State storage: in-memory repository and subscription registry (per-process); not horizontally scalable without a shared store/pub-sub or sticky sessions.
91
+
92
+
- Consistency vs responsiveness: values rounded for display and updated on each `data` frame; suited for UI, not for reconciliation.
93
+
94
+
- Error handling: if REST fails, fall back to mock data; if WS drops, auto-reconnect and keep last-known data. Prioritizes resilience for demos.
95
+
96
+
- Client architecture: Next.js app with a WebSocket Provider context and React Query; SSR of live data is out of scope to keep the real-time logic client-side and testable.
97
+
98
+
- Testing: REST fallback and provider no-op defaults keep unit tests stable; deep WS integration tests are limited and can be added with a small WS mock.
99
+
100
+
- Selection model: selection tracked by symbol and derived from the latest ticker list to ensure live updates without stale references.
101
+
102
+
- Some of the Bonus features aren't covered due to time constrain.
103
+
50
104
License
51
105
52
106
This project is available under the repository LICENSE file.
0 commit comments