# haouo/ncku-thesis-typst architecture

> Architecture diagram of the GitHub repository haouo/ncku-thesis-typst, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haouo/ncku-thesis-typst
- Repository: https://github.com/haouo/ncku-thesis-typst

## Overview

##### Main Components
- Configuration & Build Files: At the top level, you have configuration files (typst.toml, Makefile, .gitignore, LICENSE) that set up the environment, building, and versioning of the project.
- Core Library & Setup Module: The file "lib.typ" and the critical "setup" function (defined in setup.typ, referenced by main.typ) serve as the heart of the template, initializing parameters (thesis details like degree, advisor info) and returning key functions.
- Layouts & Template Files: The "layouts" directory (containing layout files like extended-abstract-en.typ, mainmatter-or-appendix.typ, whole.typ) and the "template" directory (with its contents, main.typ, images, ref.bib, setup.typ) define the overall structure, style, and organization of the thesis.
- Document Pages: The "pages" directory holds individual typst files (abstract.typ, cover.typ, outline.typ, etc.) that represent discrete sections of the thesis. They rely on the functions and settings provided by the setup module.
- Assets & Fonts: These directories contain supporting resources such as images and fonts used to ensure the thesis has the required visual styling.

##### Relationships and Interactions
- The overarching interaction starts with the configuration files which set environment, compilation, and dependency parameters.
- The core “setup()” function (defined in a dedicated file to avoid cyclic dependencies) initializes the document’s metadata and returns a set of functions. These are later imported and used inside the "main.typ" and "contents" files.
- The "layouts" and "template/contents" directories supply the typesetting structure—the layout decisions and content ordering are maintained here. Each layout file contributes to defining sections like the abstract, main matter, or appendices.
- Individual document pages in the "pages" directory then consume these functions (e.g., make_cover, make-abstract-en) to actually generate the document sections. This establishes a clear data flow from configuration through setup to the final rendered document.
- The "utils" directory provides helper code (e.g. page numbering in page-numb.typ) to manage repeated tasks such as pagination.

##### Architectural Patterns & Design Principles
- Modularity is a significant principle here—the document is broken into distinct components (setup, layouts, pages, and assets), making updates or extensions easier.
- Separation of Concerns is apparent: the project cleanly separates configuration (metadata and build), style/layout (in layouts and template folders), and content (in pages).
- Reusability and Extensibility: The central setup function returns an array of functions that the user calls as needed, ensuring that updates to core formatting or new functionalities can be centrally controlled.

##### Specific Technologies & Frameworks
- Typst as the primary typesetting language is the central technology.
- The project does not rely on a backend or frontend framework but uses Typst’s inherent capabilities in document formatting.
- Integration with bibliographic content is handled via a reference file (template/ref.bib) and the built-in bibliography function in Typst.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Build Files Subgraph
    subgraph "Configuration & Build Files"
        conf1["typst.toml"] 
        conf2["Makefile"]
        conf3[".gitignore"]
        conf4["LICENSE"]
    end

    %% Core Library & Setup Module Subgraph
    subgraph "Core Library & Setup Module"
        core1["lib.typ"]
        core2["template/setup.typ"]
    end

    %% Layouts & Template Files Subgraph
    subgraph "Layouts & Template Files"
        lay1["layouts"]
        lay2["template/main.typ"]
        lay3["template/contents"]
    end

    %% Document Pages Subgraph
    subgraph "Document Pages"
        page1["pages"]
    end

    %% Assets & Fonts Subgraph
    subgraph "Assets & Fonts"
        ast1["assets"]
        ast2["fonts"]
        ast3["template/images"]
    end

    %% Utility Modules Subgraph
    subgraph "Utility Modules"
        util1["utils/page-numb.typ"]
    end

    %% Connections
    conf1 -->|"initialization"| core1
    conf1 -->|"initialization"| core2

    core2 -->|"function_imports"| lay2
    core2 -->|"setup_functions"| page1

    lay2 -->|"template_rendering"| page1

    page1 -->|"uses_images"| ast3
    page1 -->|"uses_fonts"| ast2
    page1 -->|"pagination_helper"| util1

    %% Styling Classes
    class conf1,conf2,conf3,conf4 config
    class core1,core2 core
    class lay1,lay2,lay3 layout
    class page1 pages
    class ast1,ast2,ast3 assets
    class util1 utils

    classDef config fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef core fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef layout fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef pages fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef assets fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef utils fill:#F5B7B1,stroke:#CB4335,stroke-width:2px;

    %% Click Events for Configuration Files
    click conf1 "https://github.com/haouo/ncku-thesis-typst/blob/main/typst.toml"
    click conf2 "https://github.com/haouo/ncku-thesis-typst/tree/main/Makefile"
    click conf3 "https://github.com/haouo/ncku-thesis-typst/blob/main/.gitignore"
    click conf4 "https://github.com/haouo/ncku-thesis-typst/tree/main/LICENSE"

    %% Click Events for Core Modules
    click core1 "https://github.com/haouo/ncku-thesis-typst/blob/main/lib.typ"
    click core2 "https://github.com/haouo/ncku-thesis-typst/blob/main/template/setup.typ"

    %% Click Events for Layouts & Template Files
    click lay1 "https://github.com/haouo/ncku-thesis-typst/tree/main/layouts"
    click lay2 "https://github.com/haouo/ncku-thesis-typst/blob/main/template/main.typ"
    click lay3 "https://github.com/haouo/ncku-thesis-typst/tree/main/template/contents"

    %% Click Event for Document Pages
    click page1 "https://github.com/haouo/ncku-thesis-typst/tree/main/pages"

    %% Click Events for Assets & Fonts
    click ast1 "https://github.com/haouo/ncku-thesis-typst/tree/main/assets"
    click ast2 "https://github.com/haouo/ncku-thesis-typst/tree/main/fonts"
    click ast3 "https://github.com/haouo/ncku-thesis-typst/tree/main/template/images"

    %% Click Event for Utility Modules
    click util1 "https://github.com/haouo/ncku-thesis-typst/blob/main/utils/page-numb.typ"
```
