How mati365/librus-api works
Project type and purpose
• This is an open-source Node.js HTTP client library (“librus-api”) that logs in to the Librus/Synergia electronic gradebook, sends requests, parses returned HTML, and exposes domain-specific methods (inbox, homework, absence, calendar, info).
• It is not a full-stack application or service; it’s a reusable SDK published on npm for other Node apps to consume.
File structure
• Top-level:
• package.json / package-lock.json – defines dependencies and entry point
• .gitignore, .prettierrc – standard repo configs
• README.md – usage & description
• lib/
• api.js – main class (Librus) that wires everything
• config.js – base URLs, endpoints, auth parameters
• tools.js – shared HTTP/session management & HTML parsing utilities
• resources/ – one module per domain area: absence.js, calendar.js, homework.js, inbox.js, info.js
Extract architectural hints from README
• Usage shows a single Librus client instance, then calls like client.inbox.sendMessage(...), client.homework.listSubjects(), etc.
• Each resource uses HTTP requests + HTML parsing under the covers.
a. Consumer Application (your code)
b. LibrusApi Client Layer (lib/api.js)
c. Configuration Layer (lib/config.js)
d. HTTP & Session Tools (lib/tools.js)
e. Resource Modules (lib/resources/*.js)
f. External Librus/Synergia Web Server
Relationships and data flow
• The consumer app calls methods on the LibrusApi instance
• api.js references config.js to assemble URLs and headers
• api.js invokes tools.js to manage login/session cookie & send HTTP requests
• The raw HTML response flows back into a specific resource module (e.g., inbox.js)
• The resource module calls tools.js parsers to turn HTML into JSON data
• Parsed data is returned via Promise to the consumer
• All outbound HTTP calls go to the External Librus/Synergia Web Server
Architectural patterns & design principles
• Separation of concerns:
• config.js holds constants
• tools.js holds HTTP/session and parsing logic
• resources/* hold domain-specific workflows and parsers
• api.js composes resources and exposes a unified client interface
• Single-instance client (stateful session via cookies)
• Promise-based asynchronous API