From 62bc0f40e3dbb223a91e422fccd1de512026713e Mon Sep 17 00:00:00 2001 From: Sh4dowking Date: Thu, 12 Nov 2026 18:04:11 +0100 Subject: [PATCH 01/19] chore: install vue-flow dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f26f84a..8354cb5 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@fontsource/roboto": "^5.2.10", "@janishutz/oidc-login-sdk-browser": "^1.5.3", "@mdi/font": "7.4.47", + "@vue-flow/core": "^1.48.2", "pinia": "^3.0.4", "vue": "^3.5.30", "vue-router": "^5.0.3", From 313ff982240f804c22851738aedbe2260858e58c Mon Sep 17 00:00:00 2001 From: Sh4dowking Date: Thu, 12 Nov 2026 18:04:11 +0100 Subject: [PATCH 02/19] feat: add techtree store with sample subtopics --- src/stores/techtree.ts | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/stores/techtree.ts diff --git a/src/stores/techtree.ts b/src/stores/techtree.ts new file mode 100644 index 0000000..1a2542f --- /dev/null +++ b/src/stores/techtree.ts @@ -0,0 +1,77 @@ +import type { + ModelSubtopic +} from '@/ts/types/api'; +import { + defineStore +} from 'pinia'; +import { + ref +} from 'vue'; + +export const useTechTreeStore = defineStore( 'techtree', () => { + const discrete: ModelSubtopic = { + 'id': 2, + 'name': 'Discrete Distributions', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const continuous: ModelSubtopic = { + 'id': 3, + 'name': 'Continuous Variables', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const expectation: ModelSubtopic = { + 'id': 4, + 'name': 'Expectation & Variance', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const joint: ModelSubtopic = { + 'id': 5, + 'name': 'Joint Distributions', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const clt: ModelSubtopic = { + 'id': 6, + 'name': 'Central Limit Theorem', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const subtopics = ref( [ + { + 'id': 1, + 'name': 'Probability Axioms', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ + discrete, + continuous + ] + }, + { + ...discrete, + 'subtopics': [ expectation ] + }, + { + ...continuous, + 'subtopics': [ + expectation, + joint + ] + }, + { + ...expectation, + 'subtopics': [ clt ] + }, + joint, + clt + ] ); + const selectedSubtopicId = ref( null ); + + return { + subtopics, + selectedSubtopicId + }; +} ); \ No newline at end of file From 94fafd0675c9a86c836b6db484c8b9680039b7d8 Mon Sep 17 00:00:00 2001 From: Sh4dowking Date: Thu, 12 Nov 2026 19:36:49 +0100 Subject: [PATCH 03/19] feat: unfold subtopics into graph representation and edges with unit tests --- src/ts/util/__tests__/techtree-layout.test.ts | 134 ++++++++++++++++++ src/ts/util/techtree-layout.ts | 79 +++++++++++ 2 files changed, 213 insertions(+) create mode 100644 src/ts/util/__tests__/techtree-layout.test.ts create mode 100644 src/ts/util/techtree-layout.ts diff --git a/src/ts/util/__tests__/techtree-layout.test.ts b/src/ts/util/__tests__/techtree-layout.test.ts new file mode 100644 index 0000000..c4ccbfc --- /dev/null +++ b/src/ts/util/__tests__/techtree-layout.test.ts @@ -0,0 +1,134 @@ +import type { + ModelSubtopic +} from '../../types/api'; +import assert from 'node:assert/strict'; +import { + buildTechTreeGraph +} from '../techtree-layout'; +import test from 'node:test'; + +test( 'buildTechTreeGraph correctly unfolds subtopics and creates edges', () => { + const child: ModelSubtopic = { + 'id': 2, + 'name': 'Child Topic', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const parent: ModelSubtopic = { + 'id': 1, + 'name': 'Parent Topic', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ child ] + }; + const result = buildTechTreeGraph( [ parent ] ); + + assert.equal( result.edges.length, 1 ); + assert.equal( result.edges[0].source, '1' ); + assert.equal( result.edges[0].target, '2' ); +} ); + +test( 'buildTechTreeGraph handles multi-parent convergence and deduplicates', () => { + const sharedChild: ModelSubtopic = { + 'id': 3, + 'name': 'Shared Child', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const parentA: ModelSubtopic = { + 'id': 1, + 'name': 'Parent A', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ sharedChild ] + }; + const parentB: ModelSubtopic = { + 'id': 2, + 'name': 'Parent B', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ sharedChild ] + }; + const result = buildTechTreeGraph( [ + parentA, + parentB, + sharedChild + ] ); + + assert.equal( result.edges.length, 2 ); + assert.equal( result.edges[0].target, '3' ); + assert.equal( result.edges[1].target, '3' ); +} ); + +test( 'buildTechTreeGraph upgrades stubs when full node arrives later in list', () => { + const grandchild: ModelSubtopic = { + 'id': 3, + 'name': 'Grandchild', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + // Child stub embedded inside parent without its subtopics populated + const childStub: ModelSubtopic = { + 'id': 2, + 'name': 'Child Stub', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const parent: ModelSubtopic = { + 'id': 1, + 'name': 'Parent', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ childStub ] + }; + // Full child arriving later at root level with its grandchild subtopic + const fullChild: ModelSubtopic = { + 'id': 2, + 'name': 'Full Child', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ grandchild ] + }; + const result = buildTechTreeGraph( [ + parent, + fullChild + ] ); + + assert.equal( result.edges.length, 2 ); + assert.deepEqual( + result.edges.map( e => `${ e.source }->${ e.target }` ), + [ + '1->2', + '2->3' + ] + ); +} ); + +test( 'buildTechTreeGraph terminates cleanly if circular dependency exists', () => { + const nodeB: ModelSubtopic = { + 'id': 2, + 'name': 'Node B', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const nodeA: ModelSubtopic = { + 'id': 1, + 'name': 'Node A', + 'icon': '', + 'updatedAt': '2026-11-12T00:00:00Z', + 'subtopics': [ nodeB ] + }; + + nodeB.subtopics = [ nodeA ]; + + const result = buildTechTreeGraph( [ nodeA ] ); + + assert.equal( result.edges.length, 2 ); + assert.deepEqual( + result.edges.map( e => `${ e.source }->${ e.target }` ), + [ + '1->2', + '2->1' + ] + ); +} ); diff --git a/src/ts/util/techtree-layout.ts b/src/ts/util/techtree-layout.ts new file mode 100644 index 0000000..a6d2d04 --- /dev/null +++ b/src/ts/util/techtree-layout.ts @@ -0,0 +1,79 @@ +import type { + Edge, + Node +} from '@vue-flow/core'; +import { + MarkerType +} from '@vue-flow/core'; +import type { + ModelSubtopic +} from '@/ts/types/api'; + +export interface TechTreeGraph { + 'nodes': Node[]; + 'edges': Edge[]; +} + +export const buildTechTreeGraph = ( items: ModelSubtopic[] ): TechTreeGraph => { + const nodes: Node[] = []; + const edges: Edge[] = []; + // Internal Graph Representation + const subtopicMap = new Map(); + const childrenMap = new Map(); + const inDegree = new Map(); + const edgeSet = new Set(); + + const visit = ( item: ModelSubtopic ) => { + const id = item.id; + const subtopics = item.subtopics; + + // Save topic, upgrading if a copy with children arrives + if ( !subtopicMap.has( id ) || ( subtopics != null && subtopics.length > 0 ) ) { + subtopicMap.set( id, item ); + } + + if ( !inDegree.has( id ) ) { + inDegree.set( id, 0 ); + } + + // Process children if this node has any and we haven't expanded it yet + if ( subtopics != null && subtopics.length > 0 && !childrenMap.has( id ) ) { + const childIds: number[] = []; + + childrenMap.set( id, childIds ); + + for ( const child of subtopics ) { + childIds.push( child.id ); + + const edgeId = `e${ id }-${ child.id }`; + + if ( !edgeSet.has( edgeId ) ) { + edgeSet.add( edgeId ); + edges.push( { + 'id': edgeId, + 'source': String( id ), + 'target': String( child.id ), + 'markerEnd': { + 'type': MarkerType.ArrowClosed + } + } ); + inDegree.set( child.id, ( inDegree.get( child.id ) ?? 0 ) + 1 ); + } + + // Recursively visit child in case subtopics are deeply nested + visit( child ); + } + } + }; + + for ( const item of items ) { + visit( item ); + } + + // TODO: Next step is computing row numbers and (x, y) coordinates + + return { + nodes, + edges + }; +}; From 11604c7993b40bb767573d98a34cf6dd04f62cd5 Mon Sep 17 00:00:00 2001 From: Sh4dowking Date: Mon, 16 Nov 2026 20:44:49 +0100 Subject: [PATCH 04/19] chore: update types --- src/ts/types/api.d.ts | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/ts/types/api.d.ts b/src/ts/types/api.d.ts index b4927ed..e8dad26 100644 --- a/src/ts/types/api.d.ts +++ b/src/ts/types/api.d.ts @@ -7,6 +7,11 @@ * --------------------------------------------------------------- */ +export interface ControllerCreatedResponse { + /** @example 0 */ + 'id': number; +} + export interface ControllerUserProfileResponse { /** @example "jane.doe@example.com" */ 'email': string; @@ -97,7 +102,7 @@ export interface ModelCreateAssetRequest { 'mediaType': string; /** * @minLength 3 - * @maxLength 250 + * @maxLength 100 * @example "Analysis Script" */ 'name': string; @@ -162,6 +167,19 @@ export interface ModelCreateSubtopicRequest { * @example "Analysis" */ 'name': string; + /** + * Due to limitation of validator, has to be value + 1 + * @min 0 + * @max 100 + * @default 1 + * @example 1 + */ + 'progress': number; + /** + * Subject this subtopic belongs to + * @example 1 + */ + 'subject': number; } export interface ModelFlashcard { @@ -194,12 +212,19 @@ export interface ModelSubject { export interface ModelSubtopic { 'assets'?: ModelAsset[]; 'chats'?: ModelChat[]; + 'children'?: ModelSubtopic[]; /** @example "fa-gear" */ 'icon': string; 'id': number; /** @example "ordinary differential equations" */ 'name': string; - 'subtopics'?: ModelSubtopic[]; + /** + * value in [0, 100] + * @min 0 + * @max 100 + * @example 0 + */ + 'progress': number; /** @example "2026-12-17T13:47:33Z" */ 'updatedAt': string; } @@ -269,7 +294,7 @@ export interface ModelUpdateFlashcardRequest { export interface ModelUpdateSubjectRequest { /** * The Icon of the subject. Must be an icon that can be rendered in the browser - * @minLength 0 + * @minLength 1 * @maxLength 100 * @example "fa-gear" */ @@ -296,6 +321,18 @@ export interface ModelUpdateSubtopicRequest { * @example "Analysis" */ 'name'?: string; + /** + * @min 0 + * @max 100 + * @default 0 + * @example 0 + */ + 'progress'?: number; + /** + * Subject this subtopic belongs to + * @example 1 + */ + 'subject'?: number; } export interface ModelUpdateUserConfigRequest { From 92bf82b0c0e29689668e19391323d52afaaf0c36 Mon Sep 17 00:00:00 2001 From: Sh4dowking Date: Mon, 16 Nov 2026 20:44:49 +0100 Subject: [PATCH 05/19] feat: calculate node positions in techtree --- src/stores/techtree.ts | 14 ++- src/ts/util/__tests__/techtree-layout.test.ts | 114 ++++++++++++++++-- src/ts/util/techtree-layout.ts | 77 ++++++++++-- 3 files changed, 177 insertions(+), 28 deletions(-) diff --git a/src/stores/techtree.ts b/src/stores/techtree.ts index 1a2542f..6ad6857 100644 --- a/src/stores/techtree.ts +++ b/src/stores/techtree.ts @@ -13,30 +13,35 @@ export const useTechTreeStore = defineStore( 'techtree', () => { 'id': 2, 'name': 'Discrete Distributions', 'icon': '', + 'progress': 100, 'updatedAt': '2026-11-12T00:00:00Z' }; const continuous: ModelSubtopic = { 'id': 3, 'name': 'Continuous Variables', 'icon': '', + 'progress': 60, 'updatedAt': '2026-11-12T00:00:00Z' }; const expectation: ModelSubtopic = { 'id': 4, 'name': 'Expectation & Variance', 'icon': '', + 'progress': 25, 'updatedAt': '2026-11-12T00:00:00Z' }; const joint: ModelSubtopic = { 'id': 5, 'name': 'Joint Distributions', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; const clt: ModelSubtopic = { 'id': 6, 'name': 'Central Limit Theorem', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; const subtopics = ref( [ @@ -44,26 +49,27 @@ export const useTechTreeStore = defineStore( 'techtree', () => { 'id': 1, 'name': 'Probability Axioms', 'icon': '', + 'progress': 100, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ + 'children': [ discrete, continuous ] }, { ...discrete, - 'subtopics': [ expectation ] + 'children': [ expectation ] }, { ...continuous, - 'subtopics': [ + 'children': [ expectation, joint ] }, { ...expectation, - 'subtopics': [ clt ] + 'children': [ clt ] }, joint, clt diff --git a/src/ts/util/__tests__/techtree-layout.test.ts b/src/ts/util/__tests__/techtree-layout.test.ts index c4ccbfc..925c68c 100644 --- a/src/ts/util/__tests__/techtree-layout.test.ts +++ b/src/ts/util/__tests__/techtree-layout.test.ts @@ -7,47 +7,67 @@ import { } from '../techtree-layout'; import test from 'node:test'; -test( 'buildTechTreeGraph correctly unfolds subtopics and creates edges', () => { +test( 'unfolds subtopics and creates edges', () => { const child: ModelSubtopic = { 'id': 2, 'name': 'Child Topic', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; const parent: ModelSubtopic = { 'id': 1, 'name': 'Parent Topic', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ child ] + 'children': [ child ] }; const result = buildTechTreeGraph( [ parent ] ); assert.equal( result.edges.length, 1 ); assert.equal( result.edges[0].source, '1' ); assert.equal( result.edges[0].target, '2' ); + assert.equal( result.nodes.length, 2 ); + assert.deepEqual( + result.nodes.find( n => n.id === '1' )?.position, + { + 'x': 0, + 'y': 0 + } + ); + assert.deepEqual( + result.nodes.find( n => n.id === '2' )?.position, + { + 'x': 0, + 'y': 130 + } + ); } ); -test( 'buildTechTreeGraph handles multi-parent convergence and deduplicates', () => { +test( 'deduplicates shared child with two parents', () => { const sharedChild: ModelSubtopic = { 'id': 3, 'name': 'Shared Child', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; const parentA: ModelSubtopic = { 'id': 1, 'name': 'Parent A', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ sharedChild ] + 'children': [ sharedChild ] }; const parentB: ModelSubtopic = { 'id': 2, 'name': 'Parent B', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ sharedChild ] + 'children': [ sharedChild ] }; const result = buildTechTreeGraph( [ parentA, @@ -58,36 +78,60 @@ test( 'buildTechTreeGraph handles multi-parent convergence and deduplicates', () assert.equal( result.edges.length, 2 ); assert.equal( result.edges[0].target, '3' ); assert.equal( result.edges[1].target, '3' ); + assert.equal( result.nodes.length, 3 ); + assert.deepEqual( + result.nodes.find( n => n.id === '1' )?.position, + { + 'x': -120, + 'y': 0 + } + ); + assert.deepEqual( + result.nodes.find( n => n.id === '2' )?.position, + { + 'x': 120, + 'y': 0 + } + ); + assert.deepEqual( + result.nodes.find( n => n.id === '3' )?.position, + { + 'x': 0, + 'y': 130 + } + ); } ); -test( 'buildTechTreeGraph upgrades stubs when full node arrives later in list', () => { +test( 'keeps children when full subtopic comes after stub', () => { const grandchild: ModelSubtopic = { 'id': 3, 'name': 'Grandchild', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; - // Child stub embedded inside parent without its subtopics populated const childStub: ModelSubtopic = { 'id': 2, 'name': 'Child Stub', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; const parent: ModelSubtopic = { 'id': 1, 'name': 'Parent', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ childStub ] + 'children': [ childStub ] }; - // Full child arriving later at root level with its grandchild subtopic const fullChild: ModelSubtopic = { 'id': 2, 'name': 'Full Child', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ grandchild ] + 'children': [ grandchild ] }; const result = buildTechTreeGraph( [ parent, @@ -102,24 +146,33 @@ test( 'buildTechTreeGraph upgrades stubs when full node arrives later in list', '2->3' ] ); + assert.equal( result.nodes.length, 3 ); + assert.equal( result.nodes.find( n => n.id === '1' )?.position.y, 0 ); + assert.equal( result.nodes.find( n => n.id === '2' )?.position.y, 130 ); + assert.equal( result.nodes.find( n => n.id === '3' )?.position.y, 260 ); + assert.equal( ( result.nodes.find( n => n.id === '2' )?.data as { + 'subtopic': ModelSubtopic + } ).subtopic.name, 'Full Child' ); } ); -test( 'buildTechTreeGraph terminates cleanly if circular dependency exists', () => { +test( 'handles circular dependencies', () => { const nodeB: ModelSubtopic = { 'id': 2, 'name': 'Node B', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z' }; const nodeA: ModelSubtopic = { 'id': 1, 'name': 'Node A', 'icon': '', + 'progress': 0, 'updatedAt': '2026-11-12T00:00:00Z', - 'subtopics': [ nodeB ] + 'children': [ nodeB ] }; - nodeB.subtopics = [ nodeA ]; + nodeB.children = [ nodeA ]; const result = buildTechTreeGraph( [ nodeA ] ); @@ -132,3 +185,38 @@ test( 'buildTechTreeGraph terminates cleanly if circular dependency exists', () ] ); } ); + +test( 'places node below all prerequisites', () => { + const nodeC: ModelSubtopic = { + 'id': 3, + 'name': 'Final Topic', + 'icon': '', + 'progress': 0, + 'updatedAt': '2026-11-12T00:00:00Z' + }; + const nodeB: ModelSubtopic = { + 'id': 2, + 'name': 'Intermediate Topic', + 'icon': '', + 'progress': 0, + 'updatedAt': '2026-11-12T00:00:00Z', + 'children': [ nodeC ] + }; + const nodeA: ModelSubtopic = { + 'id': 1, + 'name': 'Root Topic', + 'icon': '', + 'progress': 0, + 'updatedAt': '2026-11-12T00:00:00Z', + 'children': [ + nodeB, + nodeC + ] + }; + const result = buildTechTreeGraph( [ nodeA ] ); + + assert.equal( result.nodes.length, 3 ); + assert.equal( result.nodes.find( n => n.id === '1' )?.position.y, 0 ); + assert.equal( result.nodes.find( n => n.id === '2' )?.position.y, 130 ); + assert.equal( result.nodes.find( n => n.id === '3' )?.position.y, 260 ); +} ); diff --git a/src/ts/util/techtree-layout.ts b/src/ts/util/techtree-layout.ts index a6d2d04..c052e59 100644 --- a/src/ts/util/techtree-layout.ts +++ b/src/ts/util/techtree-layout.ts @@ -17,7 +17,6 @@ export interface TechTreeGraph { export const buildTechTreeGraph = ( items: ModelSubtopic[] ): TechTreeGraph => { const nodes: Node[] = []; const edges: Edge[] = []; - // Internal Graph Representation const subtopicMap = new Map(); const childrenMap = new Map(); const inDegree = new Map(); @@ -25,10 +24,9 @@ export const buildTechTreeGraph = ( items: ModelSubtopic[] ): TechTreeGraph => { const visit = ( item: ModelSubtopic ) => { const id = item.id; - const subtopics = item.subtopics; + const children = item.children; - // Save topic, upgrading if a copy with children arrives - if ( !subtopicMap.has( id ) || ( subtopics != null && subtopics.length > 0 ) ) { + if ( !subtopicMap.has( id ) || ( children != null && children.length > 0 ) ) { subtopicMap.set( id, item ); } @@ -36,19 +34,17 @@ export const buildTechTreeGraph = ( items: ModelSubtopic[] ): TechTreeGraph => { inDegree.set( id, 0 ); } - // Process children if this node has any and we haven't expanded it yet - if ( subtopics != null && subtopics.length > 0 && !childrenMap.has( id ) ) { + if ( children != null && children.length > 0 && !childrenMap.has( id ) ) { const childIds: number[] = []; childrenMap.set( id, childIds ); - for ( const child of subtopics ) { - childIds.push( child.id ); - + for ( const child of children ) { const edgeId = `e${ id }-${ child.id }`; if ( !edgeSet.has( edgeId ) ) { edgeSet.add( edgeId ); + childIds.push( child.id ); edges.push( { 'id': edgeId, 'source': String( id ), @@ -60,7 +56,6 @@ export const buildTechTreeGraph = ( items: ModelSubtopic[] ): TechTreeGraph => { inDegree.set( child.id, ( inDegree.get( child.id ) ?? 0 ) + 1 ); } - // Recursively visit child in case subtopics are deeply nested visit( child ); } } @@ -70,7 +65,67 @@ export const buildTechTreeGraph = ( items: ModelSubtopic[] ): TechTreeGraph => { visit( item ); } - // TODO: Next step is computing row numbers and (x, y) coordinates + const depth = new Map(); + const queue: number[] = []; + + inDegree.forEach( ( deg, id ) => { + if ( deg === 0 ) { + depth.set( id, 0 ); + queue.push( id ); + } + } ); + + while ( queue.length > 0 ) { + const currentId = queue.shift()!; + const currentDepth = depth.get( currentId ) ?? 0; + + for ( const childId of childrenMap.get( currentId ) ?? [] ) { + const nextDepth = Math.max( depth.get( childId ) ?? 0, currentDepth + 1 ); + + depth.set( childId, nextDepth ); + const remaining = ( inDegree.get( childId ) ?? 1 ) - 1; + + inDegree.set( childId, remaining ); + + if ( remaining === 0 ) { + queue.push( childId ); + } + } + } + + const rows = new Map(); + + for ( const id of subtopicMap.keys() ) { + const d = depth.get( id ) ?? 0; + const row = rows.get( d ) ?? []; + + row.push( id ); + rows.set( d, row ); + } + + const colSpacing = 240; + const rowSpacing = 130; + + rows.forEach( ( rowIds, rowDepth ) => { + const rowWidth = ( rowIds.length - 1 ) * colSpacing; + + rowIds.forEach( ( id, index ) => { + const subtopic = subtopicMap.get( id )!; + const xOffset = ( index * colSpacing ) - ( rowWidth / 2 ); + + nodes.push( { + 'id': String( id ), + 'type': 'tech-node', + 'position': { + 'x': xOffset, + 'y': rowDepth * rowSpacing + }, + 'data': { + 'subtopic': subtopic + } + } ); + } ); + } ); return { nodes, From fff0d73f84b9ec2224d863c6c01225c6a4aca9b2 Mon Sep 17 00:00:00 2001 From: Sh4dowking Date: Mon, 16 Nov 2026 20:44:50 +0100 Subject: [PATCH 06/19] feat: add techtree page --- src/components/SideBar.vue | 7 +++ src/components/techtree/TechTreeNode.vue | 45 +++++++++++++++++++ src/pages/TechTreePage.vue | 56 ++++++++++++++++++++++++ src/router/index.ts | 9 ++++ 4 files changed, 117 insertions(+) create mode 100644 src/components/techtree/TechTreeNode.vue create mode 100644 src/pages/TechTreePage.vue diff --git a/src/components/SideBar.vue b/src/components/SideBar.vue index 2f7b3e7..3f59dd7 100644 --- a/src/components/SideBar.vue +++ b/src/components/SideBar.vue @@ -53,6 +53,13 @@ link href="/subjects" /> +