# tianxingleo/acgti architecture

> Architecture diagram of the GitHub repository tianxingleo/acgti, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tianxingleo/acgti
- Repository: https://github.com/tianxingleo/acgti

## Overview

ACGTI is a browser-based MBTI-inspired anime-character quiz. Users answer 39 scenario questions, the client scores four MBTI dimensions and archetype weights, matches a character, then presents and shares the result. Optional services collect anonymous result and self-reported MBTI feedback, provide AI interpretation and aggregate statistics, and support offline calibration. The README documents these capabilities; sampled frontend code confirms quiz orchestration and scoring, while several backend and analysis relationships are documented but their implementation was not sampled.

Main entry points: [`src/composables/useQuiz.ts`](https://github.com/tianxingleo/acgti/blob/main/src/composables/useQuiz.ts) (Quiz state), [`src/pages/ResultPage.vue`](https://github.com/tianxingleo/acgti/blob/main/src/pages/ResultPage.vue) (Result page), [`functions/api/submit.ts`](https://github.com/tianxingleo/acgti/blob/main/functions/api/submit.ts) (Result submission), [`src/utils/statsReporter.ts`](https://github.com/tianxingleo/acgti/blob/main/src/utils/statsReporter.ts) (Anonymous reporting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_quiz["Quiz experience"]
  node_quizui["Question flow<br/>[QuizPage.vue]"]
  node_quizstate["Quiz state<br/>[useQuiz.ts]"]
  node_scoring["Scoring and matching<br/>[quizEngine.ts]"]
  node_quiztypes["Quiz models<br/>[quiz.ts]"]
  node_localstate["Saved progress<br/>[storage.ts]"]
end

subgraph group_results["Results and content"]
  node_resultui["Result page<br/>[ResultPage.vue]"]
  node_archetypeview["Archetype and character catalog<br/>[CharactersPage.vue]"]
  node_statisticsview["Statistics dashboard<br/>[StatsPage.vue]"]
  node_sharing["Share poster<br/>[SharePoster.vue]"]
  node_rarity["Rarity presentation"]
  node_clientreport["Anonymous reporting<br/>[statsReporter.ts]"]
  node_insightcard["AI interpretation card<br/>[AiInsightCard.vue]"]
end

subgraph group_services["API services"]
  node_middleware["Request safeguards<br/>[_middleware.ts]"]
  node_sharedapi["API validation and limits<br/>[_shared.ts]"]
  node_submitapi["Result submission<br/>[submit.ts]"]
  node_feedbackapi["MBTI feedback intake<br/>[feedback.ts]"]
  node_insightapi["AI interpretation API<br/>[insight.ts]"]
  node_statsapi["Statistics endpoints"]
  node_worker["Scheduled maintenance<br/>[index.ts]"]
end

subgraph group_calibration["Feedback calibration"]
  node_calibration["Offline analysis and calibration"]
end

node_visitor(("Quiz taker"))
node_d1[("Cloudflare D1")]
node_ai{{"Workers AI"}}

node_visitor -->|"answers questions"| node_quizui
node_quizui -->|"records answers"| node_quizstate
node_quizstate -->|"calculates result"| node_scoring
node_quizstate -->|"persists progress"| node_localstate
node_scoring -->|"uses models"| node_quiztypes
node_quizstate -->|"provides result"| node_resultui
node_resultui -->|"renders poster"| node_sharing
node_sharing -->|"uses rarity display"| node_rarity
node_resultui -->|"sends feedback and stats"| node_clientreport
node_resultui -->|"shows interpretation"| node_insightcard
node_visitor -->|"browses characters"| node_archetypeview
node_visitor -->|"views statistics"| node_statisticsview
node_clientreport -->|"submits result"| node_submitapi
node_clientreport -->|"submits self-assessment"| node_feedbackapi
node_insightcard -->|"requests interpretation"| node_insightapi
node_insightapi -->|"generates interpretation"| node_ai
node_statisticsview -->|"loads aggregates"| node_statsapi
node_middleware -->|"guards writes"| node_submitapi
node_middleware -->|"guards writes"| node_feedbackapi
node_submitapi -->|"uses shared checks"| node_sharedapi
node_insightapi -->|"uses shared checks"| node_sharedapi
node_statsapi -->|"queries aggregates"| node_d1
node_submitapi -->|"stores submissions"| node_d1
node_feedbackapi -->|"stores feedback"| node_d1
node_worker -->|"refreshes snapshots"| node_d1
node_calibration -->|"analyzes feedback history"| node_d1
node_calibration -.->|"informs weight updates"| node_scoring

click node_quizui "https://github.com/tianxingleo/acgti/blob/main/src/pages/QuizPage.vue"
click node_quizstate "https://github.com/tianxingleo/acgti/blob/main/src/composables/useQuiz.ts"
click node_scoring "https://github.com/tianxingleo/acgti/blob/main/src/utils/quizEngine.ts"
click node_quiztypes "https://github.com/tianxingleo/acgti/blob/main/src/types/quiz.ts"
click node_localstate "https://github.com/tianxingleo/acgti/blob/main/src/utils/storage.ts"
click node_resultui "https://github.com/tianxingleo/acgti/blob/main/src/pages/ResultPage.vue"
click node_archetypeview "https://github.com/tianxingleo/acgti/blob/main/src/pages/CharactersPage.vue"
click node_statisticsview "https://github.com/tianxingleo/acgti/blob/main/src/pages/StatsPage.vue"
click node_sharing "https://github.com/tianxingleo/acgti/blob/main/src/components/SharePoster.vue"
click node_rarity "https://github.com/tianxingleo/acgti/blob/main/src/composables/useCharacterRarity.ts"
click node_clientreport "https://github.com/tianxingleo/acgti/blob/main/src/utils/statsReporter.ts"
click node_insightcard "https://github.com/tianxingleo/acgti/blob/main/src/components/AiInsightCard.vue"
click node_middleware "https://github.com/tianxingleo/acgti/blob/main/functions/_middleware.ts"
click node_sharedapi "https://github.com/tianxingleo/acgti/blob/main/functions/api/_shared.ts"
click node_submitapi "https://github.com/tianxingleo/acgti/blob/main/functions/api/submit.ts"
click node_feedbackapi "https://github.com/tianxingleo/acgti/blob/main/functions/api/feedback.ts"
click node_insightapi "https://github.com/tianxingleo/acgti/blob/main/functions/api/insight.ts"
click node_statsapi "https://github.com/tianxingleo/acgti/tree/main/functions/api/stats"
click node_worker "https://github.com/tianxingleo/acgti/blob/main/cron-worker/src/index.ts"
click node_calibration "https://github.com/tianxingleo/acgti/tree/main/analysis"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_quizui,node_quizstate,node_scoring,node_quiztypes,node_localstate toneBlue
class node_resultui,node_archetypeview,node_statisticsview,node_sharing,node_rarity,node_clientreport,node_insightcard,node_d1 toneAmber
class node_middleware,node_sharedapi,node_submitapi,node_feedbackapi,node_insightapi,node_statsapi,node_worker toneMint
class node_calibration,node_ai toneRose
class node_visitor toneIndigo
```

## Components

### Quiz experience

- [Question flow](https://github.com/tianxingleo/acgti/blob/main/src/pages/QuizPage.vue): `src/pages/QuizPage.vue`
- [Quiz state](https://github.com/tianxingleo/acgti/blob/main/src/composables/useQuiz.ts): `src/composables/useQuiz.ts`
- [Scoring and matching](https://github.com/tianxingleo/acgti/blob/main/src/utils/quizEngine.ts): `src/utils/quizEngine.ts`
- [Quiz models](https://github.com/tianxingleo/acgti/blob/main/src/types/quiz.ts): `src/types/quiz.ts`
- [Saved progress](https://github.com/tianxingleo/acgti/blob/main/src/utils/storage.ts): `src/utils/storage.ts`

### Results and content

- [Result page](https://github.com/tianxingleo/acgti/blob/main/src/pages/ResultPage.vue): `src/pages/ResultPage.vue`
- [Archetype and character catalog](https://github.com/tianxingleo/acgti/blob/main/src/pages/CharactersPage.vue): `src/pages/CharactersPage.vue`
- [Statistics dashboard](https://github.com/tianxingleo/acgti/blob/main/src/pages/StatsPage.vue): `src/pages/StatsPage.vue`
- [Share poster](https://github.com/tianxingleo/acgti/blob/main/src/components/SharePoster.vue): `src/components/SharePoster.vue`
- [Rarity presentation](https://github.com/tianxingleo/acgti/blob/main/src/composables/useCharacterRarity.ts): `src/composables/useCharacterRarity.ts`
- [Anonymous reporting](https://github.com/tianxingleo/acgti/blob/main/src/utils/statsReporter.ts): `src/utils/statsReporter.ts`
- [AI interpretation card](https://github.com/tianxingleo/acgti/blob/main/src/components/AiInsightCard.vue): `src/components/AiInsightCard.vue`

### API services

- [Request safeguards](https://github.com/tianxingleo/acgti/blob/main/functions/_middleware.ts): `functions/_middleware.ts`
- [API validation and limits](https://github.com/tianxingleo/acgti/blob/main/functions/api/_shared.ts): `functions/api/_shared.ts`
- [Result submission](https://github.com/tianxingleo/acgti/blob/main/functions/api/submit.ts): `functions/api/submit.ts`
- [MBTI feedback intake](https://github.com/tianxingleo/acgti/blob/main/functions/api/feedback.ts): `functions/api/feedback.ts`
- [AI interpretation API](https://github.com/tianxingleo/acgti/blob/main/functions/api/insight.ts): `functions/api/insight.ts`
- [Statistics endpoints](https://github.com/tianxingleo/acgti/tree/main/functions/api/stats): `functions/api/stats`
- [Scheduled maintenance](https://github.com/tianxingleo/acgti/blob/main/cron-worker/src/index.ts): `cron-worker/src/index.ts`

### Feedback calibration

- [Offline analysis and calibration](https://github.com/tianxingleo/acgti/tree/main/analysis): `analysis`

### Other components

- **Quiz taker**
- **Cloudflare D1**
- **Workers AI**

## Connections

- Quiz taker → Question flow: answers questions
- Question flow → Quiz state: records answers (evidence: `src/pages/QuizPage.vue`)
- Quiz state → Scoring and matching: calculates result (evidence: `src/composables/useQuiz.ts`)
- Quiz state → Saved progress: persists progress (evidence: `src/composables/useQuiz.ts`)
- Scoring and matching → Quiz models: uses models (evidence: `src/utils/quizEngine.ts`)
- Quiz state → Result page: provides result (evidence: `src/pages/ResultPage.vue`)
- Result page → Share poster: renders poster (evidence: `src/pages/ResultPage.vue`)
- Share poster → Rarity presentation: uses rarity display (evidence: `src/components/SharePoster.vue`)
- Result page → Anonymous reporting: sends feedback and stats (evidence: `src/pages/ResultPage.vue`)
- Result page → AI interpretation card: shows interpretation (evidence: `src/pages/ResultPage.vue`)
- Quiz taker → Archetype and character catalog: browses characters
- Quiz taker → Statistics dashboard: views statistics
- Anonymous reporting → Result submission: submits result
- Anonymous reporting → MBTI feedback intake: submits self-assessment
- AI interpretation card → AI interpretation API: requests interpretation
- AI interpretation API → Workers AI: generates interpretation
- Statistics dashboard → Statistics endpoints: loads aggregates
- Request safeguards → Result submission: guards writes
- Request safeguards → MBTI feedback intake: guards writes
- Result submission → API validation and limits: uses shared checks
- AI interpretation API → API validation and limits: uses shared checks (evidence: `functions/api/insight.ts`)
- Statistics endpoints → Cloudflare D1: queries aggregates
- Result submission → Cloudflare D1: stores submissions
- MBTI feedback intake → Cloudflare D1: stores feedback
- Scheduled maintenance → Cloudflare D1: refreshes snapshots
- Offline analysis and calibration → Cloudflare D1: analyzes feedback history
- Offline analysis and calibration → Scoring and matching: informs weight updates
