How mikey958/contactless-pay-frontend works
Project type and purpose
• This is a front-end single-page application (SPA) built with React and Vite.
• Its domain is public-transport info: browsing nearby stops, viewing transport details, managing favorites and history, and a map interface.
File structure
• Top-level: configuration files (vite.config.js, ESLint, Prettier, Stylelint), index.html, package.json.
• src/ contains:
• App entry (main.jsx, App.jsx)
• components (UI building blocks, organized by feature)
• layout (page wrappers: full, empty header, footer-only)
• pages (route-based views: Home, Search, Favorite, History, Map, Stop, Transport, etc.)
• contexts (ThemeContext) and hooks (useTheme)
• store (five JS stores for User, Transport, Favorite, History, Map state)
• utils (helpers, route definitions)
• styles (global CSS)
• No backend code; it consumes external transport or map APIs at runtime.
README
• Confirms minimal React+Vite template with HMR, ESLint preset, optional TypeScript.
Main components & interactions
a. Front-end SPA (browser)
• Vite Dev/Build Pipeline
• index.html → main.jsx → AppRouter
• Pages (Home, Search, Map, Favorite, History, Stop, Transport, etc.)
• Components (SearchBar, RouteSelect, TransportItem, Modal*, etc.)
• Layout wrappers (FullLayout, EmptyLayout, OnlyFooterLayout, etc.)
• Context layer (ThemeContext)
• State layer (UserStore, TransportStore, FavoriteStore, HistoryStore, MapStore)
• Utils (API wrappers, consts, route definitions)
b. External Services
• Public Transport API (GET stops, routes, real-time data)
• /Geo-location API (browser navigator.geolocation, map tiles)
c. Build & Deployment
• Vite Dev Server (HMR during development)
• Vite Build → dist/ (static assets) → deployed to a static host/CDN
d. Data & event flow
• User action in UI → Component event handler → calls store action → store uses utils → fetches from External API → updates store state → subscribed Components re-render.
• ThemeContext provides theming props to components.
• Router (AppRouter) determines which page layout and components to mount based on URL.
Architectural patterns & design principles
• Component-based UI with per-feature folders
• Declarative routing via AppRouter
• Centralized client-side state stores (MobX/Zustand-style pattern)
• Separation of concerns: UI <→ State <→ Data layer (utils/api)
• CSS Modules for encapsulated component styling
• Context for cross-cutting theming