How izaro-c/matematika works
Purpose and entry points
Matematika is a Spanish interactive mathematics encyclopedia: MDX articles, semantic navigation, dependency graphs, geometry simulations, study progress, and a separate authoring workflow. The React/Vite browser application starts at src/app/main.tsx, composes global providers in src/app/App.tsx, and dispatches routes through src/app/routes/AppRouter.tsx. Page-level entry points include src/pages/TheoremPage.tsx, src/pages/GraphPage.tsx, and src/pages/DiagramEditorPage.tsx.
Content system and semantic boundaries
The filesystem is the primary content database: typed MDX articles live under src/database/content/, such as src/database/content/theorems/teorema-pitagoras.mdx. src/entities/content/ContentStore.ts loads and validates these documents; schemas, metadata types, search, and generated indexes are concentrated in src/entities/content/schemas.ts, src/entities/content/loaders.ts, and src/entities/content/searchApi.ts. Invalid or unresolved references are intentionally non-fatal at runtime, allowing editorial work in progress while exposing warnings/controlled missing-content states.
Knowledge graph and learning flow
Article metadata and semantic links feed a logical/semantic graph represented by src/entities/graph/graph_structure.json and domain classes in src/entities/graph/Grafo.ts. The graph feature builds and processes graph data, including worker offloading, through src/features/graph/lib/knowledgeGraphBuilder.ts, src/features/graph/graph.worker.ts, and src/features/graph/GraphStore.ts. Graph pages and axiomatic exploration consume this layer; study-plan and completion state are managed separately through src/features/progress/context/StudyPlanContext.ts and src/features/progress/UserProgressStore.ts.
Published content rendering
Pages render MDX with shared interactive blocks and reader-oriented layouts. src/widgets/mdx/MDXBlocks.tsx is the MDX component boundary; src/widgets/content/DemonstrationSection.tsx and src/widgets/content/MarginaliaPanel.tsx provide proof presentation and contextual linked-content viewing. Navigation should use semantic concept links rather than ordinary inter-article routing, enabling contextual previews and graph relationships. Exercises are runtime React components rooted in src/features/exercises/ui/ExerciseContext.tsx and embedded from authored content.
Diagram platform
A shared declarative diagram specification separates authored geometry from rendering. Specification/schema, migrations, and semantics reside in src/shared/diagrams/spec/schema.ts, src/shared/diagrams/spec/schemaV3.ts, and src/shared/diagrams/spec/migrations.ts; the publication runtime is src/shared/diagrams/runtime/DiagramRenderer.tsx, backed by the JSXGraph adapter at src/shared/diagrams/runtime/jsxgraphAdapter.ts. Existing authored React diagram widgets under src/widgets/diagrams/ coexist with this shared spec/runtime. This boundary is critical: published pages and the editor should render the same diagram semantics.
Editor and persistence service
The editor is a substantial feature for lossless MDX and diagram authoring. Document parsing/projection/edit application live in src/features/editor/document/parseEditorDocument.ts, src/features/editor/document/applySourceEdits.ts, and src/features/editor/core/useEditorCore.ts. The diagram workbench owns editable state and source conversion in src/features/editor/diagrams/state/reducer.ts, src/features/editor/diagrams/source/parser.ts, and src/features/editor/diagrams/source/generator.ts. Browser persistence is coordinated by src/features/editor/persistence/saveCoordinator.ts against an editor API client; the Node API server and persistence backend are scripts/editor/editorApiServer.ts and scripts/editor/editorPersistenceBackend.ts. The API has container/Fly deployment artifacts: Dockerfile.editor-api and fly.editor-api.toml.
Formal verification and delivery
Lean 4 formalizes the geometry basis under lean/Matematika.lean and lean/Matematika/Geometry/Hilbert/. Repository scripts generate a Lean-derived graph and validate correspondence between formal proofs and MDX via scripts/core/generate-lean-graph.ts and scripts/core/validate-bridge-phase.ts. The main runtime stack is React 19, TypeScript, Vite/Rollup, Wouter, MDX/KaTeX, Zod, and force-graph/d3; CI and deployment are defined in .github/workflows/ci.yml, .github/workflows/deploy.yml, and .github/workflows/deploy-editor-api.yml.
Main entry points: TheoremPage.tsx Content pages · ContentStore.ts Content store · AppRouter.tsx Route dispatcher · MDXBlocks.tsx MDX component boundary
Components 22
Browser application
- Browser entry
src/app/main.tsx - Global providers
src/app/App.tsx - Route dispatcher
src/app/routes/AppRouter.tsx - Content pages · Theorem pages render published mathematical content.
src/pages/TheoremPage.tsx - Graph pages · Includes semantic graph and editor page entry points.
src/pages/GraphPage.tsx - MDX component boundary · Maps authored MDX to shared interactive reader blocks.
src/widgets/mdx/MDXBlocks.tsx - Exercise runtime
src/features/exercises/ui/ExerciseContext.tsx
Content and knowledge
- Content store · Loads and validates authored documents while tolerating unresolved editorial references.
src/entities/content/ContentStore.ts - MDX content database
- Content schemas and search
src/entities/content/schemas.ts - Semantic graph
src/entities/graph/Grafo.ts - Graph structure
src/entities/graph/graph_structure.json - Knowledge graph feature · Builds graph data and offloads processing to a worker.
src/features/graph/lib/knowledgeGraphBuilder.ts - Study progress
src/features/progress/UserProgressStore.ts
Diagram platform
- Diagram specification · Shared authored geometry semantics and migrations.
src/shared/diagrams/spec/schema.ts - Diagram renderer · Renders declarative diagrams through the JSXGraph adapter.
src/shared/diagrams/runtime/DiagramRenderer.tsx
Authoring and persistence
- Editor document core · Parses, projects, and applies source edits.
src/features/editor/core/useEditorCore.ts - Diagram workbench · Converts between diagram source and editable state.
src/features/editor/diagrams/state/reducer.ts - Save coordinator
src/features/editor/persistence/saveCoordinator.ts - Editor API service · Persists authoring documents through the backend.
scripts/editor/editorApiServer.ts
Formal verification and delivery
- Lean geometry basis
lean/Matematika.lean - Formal-content bridge · Generates a Lean graph and checks proof-to-MDX correspondence.
scripts/core/validate-bridge-phase.ts
Connections 24
- Browser entry → Global providers
- Global providers → Route dispatcher
- Route dispatcher → Content pages: content routes
- Route dispatcher → Graph pages: graph and editor routes
- Content pages → Content store: loads articles
- Content store → MDX content database: reads MDX
- Content store → Content schemas and search: validates metadata
- Content pages → MDX component boundary: renders MDX
- MDX component boundary → Exercise runtime: embeds exercises
- Content store → Semantic graph: semantic links
- Graph structure → Semantic graph: graph structure
- Semantic graph → Knowledge graph feature: processed for views
- Knowledge graph feature → Graph pages: renders exploration
- Content pages → Study progress: records study state
- MDX component boundary → Diagram renderer: renders diagrams
- Diagram renderer → Diagram specification: interprets spec
- Graph pages → Editor document core: editor route
- Editor document core → Diagram workbench: edits diagram blocks
- Diagram workbench → Diagram specification: uses shared semantics
- Editor document core → Save coordinator: saves source edits
- Save coordinator → Editor API service: persistence API
- Lean geometry basis → Formal-content bridge: formal proofs
- Formal-content bridge → MDX content database: validates correspondence
- Formal-content bridge → Graph structure: generates Lean graph