taleem-syllabusbuilder
v1.0.0
Published
This object is to provide a nested syllabus for taleem.help
Maintainers
Readme
taleem-syllabusbuilder
A tiny, stable per-tcode syllabus compiler for Taleem.Help–style apps. Author your course tree in code (Chapters → Exercises → Items) and compile to a clean JSON that frontends can render directly.
- Object-only API (no positional args)
- Single export:
SyllabusBuilder(pluszodSyllabusV1for validation) - No Taleem-specific sugar — keep your helpers in your app
- Future-proof:
typeis just a string ("slide","note","deck", …)
Install
npm i taleem-syllabusbuilderRequires Node 18+ (ESM). Package is
"type": "module".
Quick start (60 seconds)
import { SyllabusBuilder, zodSyllabusV1 } from 'taleem-syllabusbuilder';
// 1) One builder per tcode
const sb = new SyllabusBuilder('fbise9mathold', {
description: 'Math Class 9 Old Course',
image: '/bookcovers/math_9thFBSIE.png'
});
// 2) Chapter → Exercise → Items
const ch10 = sb.addChapter({ name: 'Ch-10', filename: 'Ch-10 Congruent Triangles' });
const ex10 = ch10.addExercise({ name: 'Theorems', filename: 'theorems' });
// content types are just strings
ex10.addItem({
name: 'Congruent Triangles',
filename: 'congruent_triangles',
type: 'slide',
thumbnail: '/images/congruent_triangle.webp',
tags: []
});
// 3) Build JSON and (optionally) validate
const syllabus = sb.build();
zodSyllabusV1.parse(syllabus); // throws if invalid
console.log(JSON.stringify(syllabus, null, 2));Why this exists
- Filename = Identity = Anchor. Every leaf is addressed by a
filename. - Runtime simplicity. Frontends load prebuilt JSON; no DB required.
- Decoupled growth. Add new content types without changing the compiler.
API
new SyllabusBuilder(code, { description, image? })
Creates a per-tcode builder.
code(string, required): e.g.,"fbise9mathold".description(string, required).image(string, optional).
builder.addChapter({ name, filename, description?, image? }) → Chapter
Adds a chapter node. Returns a Chapter object.
chapter.addExercise({ name, filename, description?, image? }) → Exercise
Adds an exercise node. Returns an Exercise object.
exercise.addItem({ name, filename, type='slide', thumbnail=null, tags=[], description?, image? })
Adds a leaf “question”/item.
typeis a string. Common values:"slide","note","deck","exam","link".- The library does not restrict
type; enforce rules in your app (Zod, enums, etc).
builder.build() → TcodeJSON
Compiles the tree into JSON for a single tcode.
Output JSON (v1)
{
"tcodeName": "fbise9mathold",
"description": "Math Class 9 Old Course",
"image": "/bookcovers/math_9thFBSIE.png",
"chapters": [
{
"name": "Ch-10",
"filename": "Ch-10 Congruent Triangles",
"description": "...", // optional
"image": "/covers/ch10.png", // optional
"exercises": [
{
"name": "Theorems",
"filename": "theorems",
"description": "...", // optional
"image": "/covers/ex.png",// optional
"questions": [
{
"name": "Congruent Triangles",
"filename": "congruent_triangles",
"type": "slide",
"thumbnail": "/images/congruent_triangle.webp",
"tags": [],
"description": "...", // optional
"image": "/img.png" // optional
}
]
}
]
}
]
}Validation
The package exports a Zod schema you can run in CI or build scripts.
import { zodSyllabusV1 } from 'taleem-syllabusbuilder';
zodSyllabusV1.parse(syllabus); // throws on first errorValidation guarantees:
- Required string fields are present (
tcodeName,description, etc). - Arrays (
chapters,exercises,questions) are well-formed. typeis a non-empty string (you can restrict allowed values in your app).
Typical project layout (suggestion)
/syllabus/ # your authoring files (per tcode)
fbise9mathold.js
syllabus.js # imports each tcode, builds them
/scripts/
genSyllabus.js # writes: data/syllabus/<tcode>.json + subjects.json
/static/data/syllabus/
fbise9mathold.json
subjects.jsonYour syllabusService (frontend) can then fetch:
/data/syllabus/<tcode>.jsonfor a subject/data/syllabus/subjects.jsonfor the index
FAQ
Q: Where are helpers like addNote or addDeck?
Keep them in your app as thin wrappers around addItem({ ... }). The core stays generic.
Q: Can I add new fields later?
Yes. Add optional fields to your app and pass them through addItem. If you need required structure changes, that’s a v2.
Q: Multi-tcode builds?
Run one SyllabusBuilder per tcode, then write each JSON to disk (plus a subjects.json index).
Versioning
v1is frozen alongside your deck schema; additive, optional fields only.- Structural changes (e.g., new hierarchy depth) will ship as v2 with a new schema.
License
ISC © Bilal Tariq
Changelog
- 1.0.0 — Initial release. Object-only API; exports
SyllabusBuilder+zodSyllabusV1.
