This document describes every major feature in the Temirqazyq platform, the internal files/endpoints involved, and external libraries/APIs used.
- AI Roadmap Generation
- Guided Roadmap Graph UI
- Lesson Experience
- Learning Materials (Verified Resources)
- Explain Like Child/Student/Specialist
- Quizzes & AI Feedback
- Progress, XP, Streaks, Achievements
- Profile Dashboard & Settings
- Roadmaps Listing & Progress
- Authentication & JWT
- Multi-language Support
- Universal Navigation
- Tech Stack & External Dependencies
Files
frontend/components/navbar.tsx- All page files in
frontend/app/
Behavior
- A shared
Navbarcomponent ensures consistent look and feel across the platform. - Includes quick links to Home, Dashboard, Explain Anything, and Roadmaps.
- Adapts visibility of "Settings" and "Logout" buttons based on the page (primarily shown on Dashboard).
- Integrated
LanguageSelectorfor seamless translation switching. - Responsive design: hides secondary actions on smaller screens to maintain usability.
Files / Modules
backend/app/services/roadmap_generator.pybackend/app/api/v1/routes/roadmap.pybackend/app/schemas/roadmap.py
Behavior
- Accepts
topicand optionalmax_nodes(for testing or compact roadmaps). - Uses Google Gemini via
call_openai()to produce hierarchical JSON with nodes, prerequisites, quizzes, and descriptions. - Recursively fetches learning materials per node.
- Prunes the resulting tree if
max_nodesis supplied.
External Dependencies
- Gemini API via
google-generativeai.
Files
frontend/components/roadmap/roadmap-graph.tsxfrontend/components/roadmap/roadmap-page.tsxfrontend/app/roadmap/[id]/page.tsx
Behavior
- Rendered with
react-force-graph-2d. - Node status colors: green (completed), blue (current), gray (locked).
- Hover tooltips display node titles; click navigates to
/learn/[node-id]. - Graph is laid out top-to-bottom with deterministic positions and locked progression.
- Auto-fit on load and allows pan/zoom (node dragging disabled).
Route Flow
/roadmap/[id]usesRoadmapPage.- Fetches roadmap data + completed node IDs.
- Renders both graph and summary metrics (total nodes, completed, locked).
External Dependencies
react-force-graph-2d
Files
frontend/app/lesson/[id]/page.tsx- (alias)
frontend/app/learn/[id]/page.tsx frontend/components/quiz-card.tsx
Behavior
- Lesson page includes description, materials (videos/articles/docs/suggestions), and a quiz.
- Quiz evaluation uses
/quiz/evaluateand shows AI feedback. - “Complete Lesson” button calls
/progress/complete-lesson/{node_id}to award XP and update streaks.
Files
backend/app/services/material_fetcher.py
Behavior
- AI prompt enforces “real URL only” policy, with trust lists (YouTube channels, doc domains).
- Filters responses and falls back to suggestions if no verified links exist.
- Frontend displays resource cards with icon + type; suggestions appear in a yellow box.
Files
backend/app/services/explanation_generator.pybackend/app/api/v1/routes/explain.pyfrontend/app/explain/page.tsx
Behavior
- Single endpoint
/explain/returningchild_version,student_version,expert_version. - Frontend UI takes a topic input and displays the three cards.
Files
backend/app/api/v1/routes/quiz.pybackend/app/services/level_evaluator.pyfrontend/components/quiz-card.tsx
Behavior
- Questions are generated as part of the roadmap.
- When user submits answers:
evaluate_quizcomputes score, correct answers, and uses Gemini to give supportive feedback.- XP awarded based on percentage thresholds (>=80% double XP, >=60% standard XP).
- Results are rendered inline on the lesson page.
Files
backend/app/api/v1/routes/progress.pybackend/app/models/progress.py,models/lesson.pyfrontend/components/xp-bar.tsxfrontend/store/progress.ts
Behavior
/progress/statsreturns XP, streak, total lessons, achievements, and recent progress events for the dashboard./progress/completed-nodesfeeds the graph to lock/unlock nodes dynamically.- Completing a lesson updates XP, streak,
Progresstable, and XP bar in the dashboard.
Files
frontend/app/dashboard/page.tsxfrontend/components/xp-bar.tsxfrontend/store/progress.ts,frontend/store/user.tsfrontend/lib/api.ts(progress.getStats,progress.getCompletedNodes,roadmap.getAll)
Behavior
- Dashboard is presented as a profile page: avatar with hover highlight, streak/lessons/achievements cards, and an XP bar showing level/total XP.
- Completed lessons section pulls
progress/completed-nodesand cross-references roadmap nodes to list what the learner finished (with XP reward and roadmap name). - Settings modal allows editing email/username/password fields (stored in the local Zustand user store today); logout now shows a confirmation dialog before clearing auth.
- Logout CTA and settings entry are accessible in the top navigation; profile hero includes quick actions and motivational copy.
- Settings save calls
PUT /auth/meso email/username/password persist in the backend/database.
UX Notes
- Avatar is circular with a subtle hover gray tint.
- Logout confirmation is a modal with cancel/confirm buttons; settings modal uses shadcn-style inputs/buttons.
Files
frontend/app/roadmaps/page.tsxfrontend/lib/api.ts(roadmap.getAll,progress.getCompletedNodes)
Behavior
- Shows all user roadmaps in a grid with topic, description, counts, and a green progress bar representing completed lessons percentage.
- Progress computed from completed node IDs returned by
/progress/completed-nodesagainst roadmap node totals. - Provides quick navigation back to dashboard and to each roadmap detail page.
Files
backend/app/api/v1/routes/auth.pybackend/app/core/security.pyfrontend/lib/api.ts(Axios interceptors + cookies)frontend/app/auth/login|register/page.tsx
Behavior
- Register/login endpoints hash passwords (Passlib/bcrypt) and issue JWTs.
- Frontend stores access tokens in cookies (
js-cookie). - Interceptor adds
Authorizationheader and redirects to/auth/loginwhen a 401 occurs. - Debug helper
window.checkAuth()is available in dev to inspect cookie status.
Files
frontend/lib/translations.tsfrontend/store/language.tsfrontend/lib/useTranslation.tsfrontend/components/language-selector.tsx
Behavior
- Support for English, Russian, and Kazakh.
- Persists language choice via Zustand and displays localized labels/buttons.
- Visual Flags: Uses
flag-icons(high-resolution SVGs) to ensure accurate flag representations across all operating systems.
- FastAPI, SQLAlchemy, PostgreSQL, Gemini API (
google-generativeai). - Auth:
python-jose,passlib. - AI abstraction:
call_openaiwrapper for Gemini calls.
- Next.js 14 (App Router), TypeScript, Tailwind, shadcn/ui.
- State: Zustand.
- Force Graph:
react-force-graph-2d. - Cookies:
js-cookie. - Flags:
flag-icons. - Axios for API calls with interceptors.
- Trusted channels: fireship, freeCodeCamp, Web Dev Simplified, Net Ninja, etc.
- Trusted docs: MDN, react.dev, python.org, FastAPI docs, etc.
- If uncertain, result returned as suggestion (no URL) to avoid hallucinated links.
react-force-graph-2d: https://github.com/vasturiano/react-force-graph- FastAPI: https://fastapi.tiangolo.com/
- Next.js: https://nextjs.org/
- shadcn/ui: https://ui.shadcn.com/
- Google Gemini API docs: https://ai.google.dev/gemini-api/docs
- Trusted learning platforms referenced in prompts: freeCodeCamp, MDN, DigitalOcean, RealPython, etc.
This guide serves as a reference for high-level architecture decisions, feature ownership, and the key files involved in each major area of the app. Update this document whenever new features or external dependencies are introduced.