How trap-jp/trao-judge-frontend works
Project Type and Purpose
• This is a browser-based Single-Page Application (SPA) frontend for the “traP Online Judge.”
• It is built with Vue 3, Vite, Pinia (state management), Vue Router, and Tailwind CSS, and it consumes a RESTful Judge API (mocked in development, real in production).
Main Architectural Components
A. Browser / Client SPA
• Vue 3 application
• Vue Router (src/router)
• Pinia stores (src/stores)
• Components & Views (src/components, src/views)
• Composables & Utilities (src/composables, src/utils)
• Asset pipeline (Tailwind CSS, main.css, base.css)
B. API Layer
• Frontend-generated TypeScript client (via OpenAPI Tools, openapitools.json & scripts/gen-api.sh)
• Axios (or fetch) calls under src/api/…
C. Mock API Server (Development Only)
• scripts/run-mock-api.sh → json-server or custom mock at localhost:4010 using front-back-api-mock.json
D. Real Backend Judge API
• Authentication endpoints (OAuth, login, signup)
• Problem, Submission, User, Settings endpoints
E. Build & Deployment Pipeline
• Local dev tooling (npm scripts: dev, build, lint)
• Vite dev server (npm run dev)
• Build output (dist folder)
• CI (GitHub Actions .github/workflows/main.yaml)
• Deployment target (e.g., static hosting on Netlify/GitHub Pages or container behind Nginx)
Relationships & Data Flows
• Browser SPA ↔ Mock API (dev) OR Browser SPA ↔ Real Judge API (prod)
• Codegen script → generates API client → src/api
• Vite dev server ↔ local file system (hot reload)
• CI/CD pipeline → runs lint/build/test → deploys dist
Architectural Patterns & Design Principles
• Component-Based UI (Vue components + Views)
• MVVM-like pattern via Vue + Composition API
• Centralized state (Pinia stores)
• Router-driven navigation
• API Client generated from OpenAPI spec → type-safe calls
• Mocking strategy for dev (separation of concerns)
Technologies & Frameworks to Label
• Vue 3, Vite, TypeScript, Pinia, Vue Router
• Tailwind CSS, PostCSS
• OpenAPI Generator (scripts/gen-api.sh)
• Mock Server (scripts/run-mock-api.sh)
• ESLint, Prettier
• GitHub Actions (.github/workflows)