# eric7829/cognitivefunctiontest architecture

> Architecture diagram of the GitHub repository eric7829/cognitivefunctiontest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eric7829/cognitivefunctiontest
- Repository: https://github.com/eric7829/cognitivefunctiontest

## Overview

##### Project Type & Purpose
- This is a purely client-side, static web application: a “Cosmic Mindscape” personality assessment tool.
- Purpose: present a UI in the browser (index.html + app.js + main.css), load question data (questions.json), run a scoring algorithm (score_calculator.js), and display results via static HTML pages (types/*.html, resources/*.html).

##### File Structure Analysis
- Root assets:
- index.html – test entry point
- app.js – UI logic, question flow
- score_calculator.js – core scoring engine
- questions.json – raw question data
- main.css + proximanova_light.otf – styling and font
- Resource pages (resources/): static theory/history acknowledgments.
- Type pages (types/): 16 static HTML pages with accompanying JS & CSS for the cognitive-function carousel.

##### Core Components
A. User’s Web Browser (Client)
B. Static Hosting Layer
- Could be GitHub Pages, Netlify, any CDN or web server serving static files.
C. Static Assets
1. index.html
2. main.css, proximanova_light.otf
3. app.js
4. score_calculator.js
5. questions.json
6. resources/*.html + resources/resources.css + resources/theory.js
7. types/*.html + types/*.js + types/Type.css
D. Data Store (Static JSON)
E. Scoring Engine (Module)
- score_calculator.js logic:
- Raw Function Scoring
- Attitude Preference Integration
- Intra-Pair Suppression
- Global Suppression (sigmoid)
- Temperament & I/E Boosts
- Function-Stack Matching → Final Type
F. Navigation Flow
- After scoring, redirect to the appropriate types/<type>.html page
- Links to resources/*.html for theory/history

##### Relationships & Interactions
1. Browser → (HTTP GET) → Static Hosting → Serves index.html, CSS, JS, JSON
2. index.html + app.js loads questions.json via XHR/Fetch
3. app.js passes raw answers to score_calculator.js
4. score_calculator.js pulls in question weights, runs algorithm, returns a “type code”
5. app.js triggers client-side navigation to types/{code}.html
6. Browser fetches types page and its local CSS/JS to render the results
7. User can click nav items to fetch resources/*.html

##### Architectural Patterns & Design Principles
- Static Single-Page Application (SPA) style for the test flow, but with static post-results pages.
- Separation of concerns:
- UI & state management in app.js
- Pure function-based scoring in score_calculator.js
- Data in JSON
- Presentation in CSS/HTML
- No server-side logic; fully decoupled hosting of assets.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client and Server
    Browser["User's Web Browser"]:::client
    StaticServer["Static Hosting Layer"]:::server

    Browser -->|"GET index.html, CSS, JS"| StaticServer

    %% Static Assets
    StaticServer --> Index["index.html"]:::static
    StaticServer --> CSS["main.css"]:::static
    StaticServer --> Font["proximanova_light.otf"]:::static
    StaticServer --> App["app.js"]:::client
    StaticServer --> Score["score_calculator.js"]:::client
    StaticServer --> Data[(questions.json)]:::data

    %% Execution Flow
    Index -->|"loads UI logic"| App
    App -->|"Fetch questions.json"| Data
    App -->|"Invoke scoring logic"| Score
    App -->|"Navigate to result page"| TypesCluster

    Browser -->|"GET types page and assets"| StaticServer
    Browser -->|"GET resource page"| StaticServer

    %% Static Page Clusters
    subgraph "Resources (Static Pages)"
        direction TB
        ResCluster1["resources/"]:::static
    end

    subgraph "Types (Result Pages)"
        direction TB
        TypesCluster["types/"]:::static
    end

    %% Click Events
    click Index "https://github.com/eric7829/cognitivefunctiontest/blob/main/index.html"
    click CSS "https://github.com/eric7829/cognitivefunctiontest/blob/main/main.css"
    click Font "https://github.com/eric7829/cognitivefunctiontest/blob/main/proximanova_light.otf"
    click App "https://github.com/eric7829/cognitivefunctiontest/blob/main/app.js"
    click Score "https://github.com/eric7829/cognitivefunctiontest/blob/main/score_calculator.js"
    click Data "https://github.com/eric7829/cognitivefunctiontest/blob/main/questions.json"
    click ResCluster1 "https://github.com/eric7829/cognitivefunctiontest/tree/main/resources/"
    click TypesCluster "https://github.com/eric7829/cognitivefunctiontest/tree/main/types/"

    %% Styles
    classDef client fill:#bbdefb,stroke:#2196f3
    classDef static fill:#c8e6c9,stroke:#388e3c
    classDef data fill:#ffe0b2,stroke:#fb8c00
    classDef server fill:#e0e0e0,stroke:#757575
```
