# corn323/quiz-app-nuxt architecture

> Architecture diagram of the GitHub repository corn323/quiz-app-nuxt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/corn323/quiz-app-nuxt
- Repository: https://github.com/corn323/quiz-app-nuxt

## Overview

##### Project type and purpose
- This is a full-stack, server-side-rendered (SSR) quiz-generation web application built on Nuxt 3.
- It uses Vue 3 + Vuetify for UI, Prisma + SQLite for persistence, and Nuxt’s Nitro server/API routes for backend logic.
- Key feature: allow users to create, list, search, tag, and export quiz questions (including PDF generation).

##### File structure
- Top-level “app.vue”, “pages/” and “components/” hold the Vue UI (Nuxt’s file-based routing + component hierarchy).
- “plugins/vuetify.ts” bootstraps Vuetify into the Nuxt app.
- “server/api/questionDataHandler.js” defines a Nitro serverless endpoint for CRUD on questions.
- “prisma/schema.prisma” + “prisma/questions.db” define the data model and storage.
- “types/question.ts” defines shared TypeScript interfaces.
- “.nuxt/” holds the generated build artifacts (SSR engine, imports, manifests).
- Config files: nuxt.config.ts, tsconfig.json, server/tsconfig.json.

##### README for additional insights
- Timeline shows initial UI scaffolding, then database integration, then basic functionality.
- Mentions “doc” for PDF generation (see component GeneratePdfButton.vue).
- No complex microservices—single Nitro server with one API route file.

a. Main components
- Client (Browser + Vue/Vuetify SPA)
- Nuxt 3 SSR Server (Nitro)
- Server API Route (questionDataHandler)
- Prisma ORM Layer
- SQLite Database (questions.db)
- PDF/Doc Generation Module
- Static Assets (public/)
- Optional: TypeScript Types (shared between client & server)
b. Relationships & interactions
- Browser → HTTP GET/POST → Nuxt SSR server (initial HTML + hydration)
- Client-side Vue components → Nitro API calls → questionDataHandler → Prisma → SQLite DB
- GeneratePdfButton triggers either a client download or server-side PDF creation via a doc library (e.g., docx or pdfkit).
- Nuxt plugin (Vuetify) injects styling theme at build time.
c. Architectural patterns/design principles
- File-based routing (Nuxt pages → routes)
- Component-driven UI decomposition
- Single API handler for question data (monolith pattern, but isolated in server/api)
- ORM abstraction (Prisma) decouples business logic from raw SQL
- SSR for performance & SEO, with client-side hydration for interactivity
d. Key technologies/frameworks
- Nuxt 3 & Nitro (Vue SSR + serverless functions)
- Vue 3 + Vuetify (UX/UI framework)
- Prisma ORM + SQLite (embedded relational DB)
- TypeScript (type safety across layers)
- PDF/doc generation library (for export feature)

##### Detailed capture of essential elements
- File-based routing concept: map “pages/add-question.vue” → “/add-question” route, “pages/questions.vue” → questions listing route.
- Plugin initialization: “plugins/vuetify.ts” injecting Vuetify into the app context.
- Shared TypeScript “types/question.ts” used by both front and back.
- Prisma schema file as the source of truth for the data model.
- .nuxt build artifacts as part of the deployment bundle (optional detail).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Browser["Browser"]:::external

    %% Frontend & SSR Server
    subgraph "Nuxt SSR Server" 
        direction TB
        App["app.vue"]
        subgraph "Pages (Routes)"
            direction TB
            Index["pages/index.vue"]
            AddQ["pages/add-question.vue"]
            QuestionsP["pages/questions.vue"]
        end
        subgraph "Components" 
            direction TB
            QI["QuestionInput.vue"]
            AS["AnswerSelect.vue"]
            OG["OptionsGrid.vue"]
            TI["TagInput.vue"]
            SB["SearchBar.vue"]
            QL["QuestionList.vue"]
            QP["QuestionPopup.vue"]
            GP["GeneratePdfButton.vue"]
        end
        PL["plugins/vuetify.ts"]
        API["server/api/questionDataHandler.js"]
    end

    %% Shared Types
    subgraph "Shared Types"
        Types["types/question.ts"]
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        ORM["prisma/schema.prisma"]
        DB["SQLite DB (questions.db)"]:::database
    end

    %% Utilities
    subgraph "Utilities"
        PDF["PDF Generation Module"]
    end

    %% Connections
    Browser -->|"Page request & hydration"| App
    App -->|"renders pages"| Browser
    App --> Index
    App --> AddQ
    App --> QuestionsP
    App --> QI
    App --> AS
    App --> OG
    App --> TI
    App --> SB
    App --> QL
    App --> QP
    App --> GP

    App --> PL
    PL --> QI
    PL --> AS
    PL --> OG
    PL --> TI
    PL --> SB
    PL --> QL
    PL --> QP
    PL --> GP

    QI --> Types
    AS --> Types
    OG --> Types
    TI --> Types
    SB --> Types
    QL --> Types
    QP --> Types
    GP --> Types
    API --> Types

    Browser -->|"API calls"| API
    QI --> API
    AS --> API
    OG --> API
    TI --> API
    SB --> API
    QL --> API
    QP --> API

    API -->|"queries via Prisma"| ORM
    ORM -->|"reads/writes"| DB

    GP -->|"generate PDF"| PDF
    PDF -->|"download PDF"| Browser

    %% Click Events
    click QI "https://github.com/corn323/quiz-app-nuxt/blob/main/components/QuestionInput.vue"
    click AS "https://github.com/corn323/quiz-app-nuxt/blob/main/components/AnswerSelect.vue"
    click OG "https://github.com/corn323/quiz-app-nuxt/blob/main/components/OptionsGrid.vue"
    click TI "https://github.com/corn323/quiz-app-nuxt/blob/main/components/TagInput.vue"
    click SB "https://github.com/corn323/quiz-app-nuxt/blob/main/components/SearchBar.vue"
    click QL "https://github.com/corn323/quiz-app-nuxt/blob/main/components/QuestionList.vue"
    click QP "https://github.com/corn323/quiz-app-nuxt/blob/main/components/QuestionPopup.vue"
    click GP "https://github.com/corn323/quiz-app-nuxt/blob/main/components/GeneratePdfButton.vue"
    click Index "https://github.com/corn323/quiz-app-nuxt/blob/main/pages/index.vue"
    click AddQ "https://github.com/corn323/quiz-app-nuxt/blob/main/pages/add-question.vue"
    click QuestionsP "https://github.com/corn323/quiz-app-nuxt/blob/main/pages/questions.vue"
    click App "https://github.com/corn323/quiz-app-nuxt/blob/main/app.vue"
    click PL "https://github.com/corn323/quiz-app-nuxt/blob/main/plugins/vuetify.ts"
    click API "https://github.com/corn323/quiz-app-nuxt/blob/main/server/api/questionDataHandler.js"
    click ORM "https://github.com/corn323/quiz-app-nuxt/blob/main/prisma/schema.prisma"
    click DB "https://github.com/corn323/quiz-app-nuxt/blob/main/prisma/questions.db"
    click Types "https://github.com/corn323/quiz-app-nuxt/blob/main/types/question.ts"
    click Public "https://github.com/corn323/quiz-app-nuxt/tree/main/public/"
    click Robots "https://github.com/corn323/quiz-app-nuxt/blob/main/public/robots.txt"
    click NuxtConfig "https://github.com/corn323/quiz-app-nuxt/blob/main/nuxt.config.ts"
    click TSConfig "https://github.com/corn323/quiz-app-nuxt/blob/main/tsconfig.json"
    click ServerTS "https://github.com/corn323/quiz-app-nuxt/blob/main/server/tsconfig.json"
    click NuxtBuild "https://github.com/corn323/quiz-app-nuxt/tree/main/.nuxt/"

    %% Styles
    classDef external fill:#eef,stroke:#666,stroke-width:1px
    classDef server fill:#cfc,stroke:#393,stroke-width:1px
    classDef data fill:#fec,stroke:#993,stroke-width:1px
    classDef util fill:#ffc,stroke:#cc9,stroke-width:1px
    classDef database fill:#fcf,stroke:#939,stroke-width:1px

    class Browser external
    class App,Index,AddQ,QuestionsP,API server
    class QI,AS,OG,TI,SB,QL,QP,GP util
    class PL util
    class ORM data
    class DB database
    class PDF util
    class Types util
```
