How ianhenderson/kstool works
Project type and purpose
• This is a full-stack web application (“Kanji Study Tool”) that provides flashcard-style Japanese character study.
• Front end: multiple Angular 1.x variants (plain Angular, Angular/E S6, Angular Material design) built as static assets under /public.
• Back end: Node.js + Express REST API, session middleware, SQLite database.
File structure
• Top level:
– public/…: three separate Angular front-end builds (angular-mat-design, angular, es6).
– server.js & server/: Express server entry point, configuration, routes, controllers, DB access, middleware.
– build.js, deploy.sh, .deployment, iisnode.yml: build & deploy scripts/config for Azure/IIS Node hosting.
– spec/: E2E/protractor & unit tests.
• server/ breakdown:
– config.js: server configuration (ports, DB path, session secrets)
– routes.js: REST endpoints (/login, /words, /session, etc.)
– controller.js: business logic for each endpoint
– db.js: SQLite wrapper, CRUD operations
– middleware.js & checkSession.js: authentication middleware
README for additional insights
• Confirms stack: Angular/UI-Router, Node/Express, SQLite.
• Flashcard workflow: client fetches one character + contextual words, then posts review results.
Main components & interactions
a. Components:
1. Static asset server – serves HTML, JS, CSS for Angular apps.
2. Angular SPA – UI modules (routes, directives, services) that render flashcards, handle login, settings.
3. Express API – HTTP endpoints for authentication, session management, word CRUD, review logic.
4. Middleware – session check, request logging, error handling.
5. SQLite database – persistent storage of users, words, review history.
6. Build/Deploy – scripts to lint, bundle, deploy to hosting (Azure/IIS Node).
7. Test harness – Jasmine (unit), Protractor (E2E).
b. Relationships & data flow:
– Client browser requests index.html → static asset server (Express static middleware).
– Angular app loads, UI-Router directs to views (home, add‐words, login, settings).
– Angular services call Express API endpoints (e.g., GET /api/word, POST /api/review).
– Express routes.js → middleware.checkSession → controller.js invokes db.js → SQLite.
– Controller returns JSON → Angular service processes response → UI updates.
– Build.js bundles source, deploy.sh pushes to hosting.
– Test suite targets both front end (Protractor) and back end (Jasmine).
c. Architectural patterns & principles:
– MVC on the server (routes → controllers → models/db).
– Component-based Angular 1.x (directives + services) with UI-Router for SPAs.
– Clear separation of concerns: static assets vs. API vs. persistence.
– Modular file structure supports swapping front-end themes (mat-design, ES6, plain).
d. Key technologies & libraries:
– Front end: Angular 1.x, UI-Router, Angular Material, custom directives & services.
– Back end: Node.js, Express, express-session, body-parser, sqlite3.
– Build/deploy: Node scripts, .deployment, iisnode.yml, nodemon.
– Testing: Jasmine, Protractor.
Detail without overcomplicating
– Capture every module-level boundary (static vs. dynamic, REST vs. session, build vs. runtime).
– Aim for a single cohesive view that shows all runtime interactions, plus an optional inset for build/test pipeline.