How nlp-tf/front-end works
Project Type and Purpose
• This is a frontend-only single-page application (SPA) built with React and Vite.
• It implements a “game” workflow via pages (Home, Select, Game, Result) and communicates with an external backend through REST API calls (start, round, submit, summary).
• It is deployed as static assets (HTML/CSS/JS) to Vercel.
Main Components
a. Client / Browser
• Loads index.html and the compiled JS bundle (entry point: src/main.jsx).
• Renders React components (entry: src/App.jsx).
b. React SPA Layers
• Pages: Home.jsx, Select.jsx, Game.jsx, Result.jsx.
• Global state and styles: GlobalStyles.js, theme.js, App.css.
• API layer:
– src/api/instance.js (Axios instance or fetch wrapper, base URL + interceptors)
– start.js, round.js, submit.js, summary.js (endpoint modules)
• Assets: fonts under src/assets/fonts.
c. Build & Tooling
• Vite (vite.config.js) transpiles and bundles JS/JSX, handles HMR in dev.
• ESLint config (eslint.config.js) and Prettier (if used) enforce code quality.
• package.json lists dependencies (React, Axios, styled-components or similar).
d. Deployment
• Vercel (vercel.json) hosts the compiled static site on a global CDN.
• GitHub (or other Git) triggers CI/CD on push (not shown in repo).
e. External Services
• Backend API (not in this repo) handles game logic and data persistence.
• Could include a database, authentication service, etc.
Relationships and Data Flow
• User → Browser loads SPA assets from Vercel CDN
• SPA UI → API layer (instance.js) → External Backend endpoints
• Backend → returns JSON → SPA updates UI state/pages
• Developer → Git push → Vercel build hook → Vite build → Deploy static assets
Architectural Patterns and Design Principles
• Component-based architecture (React functional components and hooks).
• Separation of concerns:
• UI components (pages) vs. styling (GlobalStyles, theme) vs. data fetching (API modules).
• Single source of truth for HTTP configuration (instance.js).
• Unidirectional data flow: user actions → API calls → update state → re-render UI.
Detail Checklist
• Components: Browser, React SPA (Pages, API, Styles, Assets), Vite, ESLint, Vercel, Backend API, Database.
• Data flows: asset delivery, user interactions → API, CI/CD pipeline.
• Architectural patterns: component-based, separation of concerns, unidirectional data flow.