How skannan1209/myapp works
This is a 3-component microservices-style system for efficiently transferring and displaying a large JSON dataset (~10MB) end-to-end with explicit focus on:
• Backend-to-backend streaming + connection pooling (Client App → Data Service)
• Frontend timeout/cancellation + large payload parsing/rendering (React)
The architecture is intentionally “linear” and should be drawn as such:
React Frontend (5173) → Client App / Gateway (8080) → Data Service (8081)
User / Browser
• Interacts with React app served by Vite dev server (during dev) or static hosting (future).
Frontend (React/Vite) – Port 5173
• Calls Client App via HTTP
• Shows cancellation/timeout at UI layer (AbortController)
Client App (Spring Boot) – Port 8080
• Exposes endpoint: /fetch-remote-data (from README)
• Uses Apache HttpClient 5 with:
• PoolingHttpClientConnectionManager (200 total / 50 per route)
• Timeout ~5s, read timeout ~30s
• Calls Data Service over HTTP
Data Service (Spring Boot) – Port 8081
• Exposes endpoint: /data
• Generates ~50,000 items
• Uses StreamingResponseBody to stream JSON
• Frontend → Client App: GET /fetch-remote-data (large payload)
• Client App → Data Service: GET /data (streamed; pooled connections)
• Data Service → Client App: streaming response (chunked/stream)
• Timeout/cancellation boundary
• UI timeout: AbortController cancels fetch (15s default per README)
• Backend timeouts: connect/read timeouts to avoid thread starvation
• Performance/memory strategy
• StreamingResponseBody avoids building full JSON in heap
• Connection pooling prevents connection churn under concurrency
Data Service internals (data-service/src/main/java/dataservice)
• DataController
• endpoint /data
• returns StreamingResponseBody
• DataLoader
• creates/generates dataset (50k items)
• BigItemRepository
• source of items (even if in-memory/mock; label it “Repository / Data source abstraction”)
• BigItem (Domain model)
Data flow inside service:
HTTP request → DataController → (Repository/DataLoader) → StreamingResponseBody writes JSON → HTTP response stream
Client App internals (app/src/main/java/myapp)
• ClientController
• endpoint /fetch-remote-data
• ClientConfig
• HttpClient5 bean(s), pooling manager, timeouts
• Apache HttpClient 5
• As a “library component” connected to Data Service
Data flow:
Frontend request → ClientController → Apache HttpClient5 (pooled) → Data Service → response forwarded back
Frontend internals (frontend/src)
• App.jsx UI
• triggers request, displays metrics (time + size)
• timeout simulator
• Network Layer
• fetch() + AbortController wrapper
• (Optional) Renderer
• large list rendering concerns (virtualization not indicated in tree; don’t invent it—just label “Large list rendering”)
Data flow:
User action → fetch wrapper (AbortController) → GET Client App → parse JSON → render list + metrics
• Gateway/Intermediary pattern: app/ behaves like an API gateway / BFF-lite (even if minimal).
• Streaming response: data-service uses streaming to reduce memory pressure.
• Connection pooling: app uses pooled HTTP connections to backend service.
• Timeouts at multiple layers:
• Client (browser) cancellation
• Server-to-server timeouts
• 3 services + browser + ports + main endpoints + payload size
• Break out each Spring Boot service into Controller/Config/Repository/Loader
• Break out frontend into UI + fetch/AbortController
This gives you both “what runs where” and “how it’s implemented,” without overcomplicating a single canvas.
• data-service/.../DataController.java → “DataController (/data, StreamingResponseBody)”
• data-service/.../DataLoader.java → “Mock Data Generator/Loader (50k items)”
• data-service/.../BigItemRepository.java → “Repository (in-memory/mock abstraction)”
• app/.../ClientController.java → “ClientController (/fetch-remote-data)”
• app/.../ClientConfig.java → “HttpClient5 Config (pooling + timeouts)”
• frontend/src/App.jsx → “UI + Metrics + Timeout simulator”