How finnishtransportagency/suomen-vaylat works
Project type and purpose
• This is a React single-page application (SPA) that integrates with an external Oskari map service.
• It displays Finnish transport infrastructure data via RPC calls, uses a proxy for API calls, and a WebSocket server for file downloads.
File structure
• Top-level folder suomen-vaylat-app contains the React front-end:
• public/ – static assets (HTML, fonts, manifest)
• src/ – app code
– components/ (UI widgets)
– state/ (Redux store & slices)
– utils/ (helpers, RPC & GFI utilities)
– translations/ (i18n JSON files)
– webpack.config.js, environment configs
• linter/ – pre-commit hooks
• No backend code here; external services (published map, proxy, WebSocket server) are configured via environment variables.
README for additional insights
• Environment variables define endpoints:
• REACT_APP_PUBLISHED_MAP_URL → Oskari published map with RPC
• REACT_APP_PROXY_URL → Proxy domain for API calls
• REACT_APP_WEBSOCKET_URL → WebSocket URL for download support
• Shows that the SPA communicates with two main external services plus translations.
Main components and interactions
a. Browser / User
b. React SPA
• State Management (Redux slices)
• Utils (RPC, GFI, logging)
c. External Oskari Map Service (RPC endpoint)
d. Proxy Server (REST API)
e. WebSocket Server (file downloads)
f. CDN / Static Host for production build
g. Translation files (build-time resource)
Relationships:
• Browser ↔ React SPA
• SPA → RPC on Oskari map (via REACT_APP_PUBLISHED_MAP_URL)
• SPA → Proxy (via REACT_APP_PROXY_URL) for backend API calls
• SPA ↔ WebSocket server (via REACT_APP_WEBSOCKET_URL)
• Build pipeline picks up translations and environment variables
Architectural patterns & design principles
• Component-based UI (React + MUI)
• Unidirectional data flow (Redux store with slices)
• Separation of concerns:
• Presentation (components)
• Business logic (utils, hooks)
• State (Redux)
• Configuration via environment variables (12-factor app)
• Build-time translation injection