# trap-jp/trao-judge-frontend architecture

> Architecture diagram of the GitHub repository trap-jp/trao-judge-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trap-jp/trao-judge-frontend
- Repository: https://github.com/trap-jp/trao-judge-frontend

## Overview

##### 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)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Main["src/main.ts"]:::frontend
        App["src/App.vue"]:::frontend
        Router["Vue Router\n(src/router/index.ts)"]:::frontend
        Store["Pinia Stores\n(src/stores/*.ts)"]:::frontend
        Components["UI Components\n(src/components)"]:::frontend
        Views["Views\n(src/views)"]:::frontend
        Composables["Composables\n(src/composables/useQueryParam.ts)"]:::frontend
        Utils["Utilities\n(src/utils)"]:::frontend
        Assets["Asset Pipeline\n(src/assets)"]:::frontend
        Public["Static Public Files\n(public/)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        GeneratedClient["Generated API Client\n(src/api)"]:::api
        Axios["Axios Calls\n(src/api)"]:::api
        subgraph "Mock API Server (dev)" 
            direction TB
            MockScript["scripts/run-mock-api.sh"]:::backend
            MockData["front-back-api-mock.json\n(src/api/mock/)"]:::backend
        end
        RealAPI["Real Judge API\n(Auth, Problems, Submissions, Settings)"]:::backend
    end

    %% Build Tools
    subgraph "Build & Dev Tooling"
        direction TB
        OpenAPIConfig["openapitools.json"]:::config
        GenScript["scripts/gen-api.sh"]:::config
        Env[".env.development\n(env.d.ts, VITE_API_BASE_URL)"]:::config
        PackageJSON["package.json\n(scripts: dev, build, lint)"]:::pipeline
        ViteConfig["vite.config.ts"]:::pipeline
        ESLint["eslint.config.js"]:::pipeline
        TSConfig["tsconfig*.json"]:::config
    end

    %% CI/CD & Deployment
    subgraph "CI/CD & Deployment"
        direction TB
        CI["GitHub Actions\n(.github/workflows/main.yaml)"]:::pipeline
        Dist["Build Output\n(dist/)"]:::pipeline
        Deploy["Static Hosting / Container"]:::pipeline
    end

    %% Flows
    Main -->|imports| App
    App -->|uses| Router
    App -->|uses| Store
    App -->|renders| Components
    App -->|navigates| Views
    Components -->|use| Composables
    Components -->|use| Utils
    App -->|includes| Assets
    App -->|serves| Public

    App -->|calls API| GeneratedClient
    GeneratedClient -->|HTTP requests via| Axios
    Axios -->|in dev| MockScript
    MockScript --> MockData
    Axios -->|in prod| RealAPI

    OpenAPIConfig -->|configures| GenScript
    GenScript -->|generates| GeneratedClient

    PackageJSON -->|runs| ViteConfig
    ViteConfig -->|serves| Main
    PackageJSON -->|runs| GenScript
    PackageJSON -->|runs| MockScript

    CI -->|runs| PackageJSON
    CI -->|produces| Dist
    CI -->|deploys| Deploy

    %% Click Events
    click Main "https://github.com/trap-jp/trao-judge-frontend/blob/main/src/main.ts"
    click App "https://github.com/trap-jp/trao-judge-frontend/blob/main/src/App.vue"
    click Router "https://github.com/trap-jp/trao-judge-frontend/blob/main/src/router/index.ts"
    click Store "https://github.com/trap-jp/trao-judge-frontend/tree/main/src/stores"
    click Components "https://github.com/trap-jp/trao-judge-frontend/tree/main/src/components"
    click Views "https://github.com/trap-jp/trao-judge-frontend/tree/main/src/views"
    click Composables "https://github.com/trap-jp/trao-judge-frontend/blob/main/src/composables/useQueryParam.ts"
    click Utils "https://github.com/trap-jp/trao-judge-frontend/tree/main/src/utils"
    click Assets "https://github.com/trap-jp/trao-judge-frontend/tree/main/src/assets"
    click Public "https://github.com/trap-jp/trao-judge-frontend/tree/main/public"
    click GeneratedClient "https://github.com/trap-jp/trao-judge-frontend/tree/main/src/api"
    click MockScript "https://github.com/trap-jp/trao-judge-frontend/blob/main/scripts/run-mock-api.sh"
    click MockData "https://github.com/trap-jp/trao-judge-frontend/blob/main/src/api/mock/front-back-api-mock.json"
    click OpenAPIConfig "https://github.com/trap-jp/trao-judge-frontend/blob/main/openapitools.json"
    click GenScript "https://github.com/trap-jp/trao-judge-frontend/blob/main/scripts/gen-api.sh"
    click Env "https://github.com/trap-jp/trao-judge-frontend/blob/main/.env.development"
    click PackageJSON "https://github.com/trap-jp/trao-judge-frontend/blob/main/package.json"
    click ViteConfig "https://github.com/trap-jp/trao-judge-frontend/blob/main/vite.config.ts"
    click ESLint "https://github.com/trap-jp/trao-judge-frontend/blob/main/eslint.config.js"
    click TSConfig "https://github.com/trap-jp/trao-judge-frontend/blob/main/tsconfig.json"
    click CI "https://github.com/trap-jp/trao-judge-frontend/blob/main/.github/workflows/main.yaml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef api fill:#90EE90,stroke:#000,stroke-width:1px
    classDef backend fill:#FFD700,stroke:#000,stroke-width:1px
    classDef pipeline fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px
```
