CodeSignal CosmoPlot is a browser-based graphing calculator. It runs locally with a small Node server and a Vite-based development setup.
CosmoPlot currently supports the following graphing workflows:
- Live graphing for explicit expressions such as
sin(x)andy = m*x + b - Implicit equations and vertical lines such as
x^2 + y^2 = 9andx = 3 - Inequality shading such as
y > x^2andx <= 3 - Point plotting with
points([[0,0],[1,2]]) - Vector plotting with
vector([3,2],[1,1]) - Parameter assignments such as
a = 2 - Auto-generated sliders for parameters used in graph expressions such as
a*sin(b*x) - Separate sidebar tabs for graph expressions and parameters
- Pan, zoom, reset-view controls, and a built-in help modal
If you cloned the repository with Git, initialize the design-system submodule before starting the app:
git submodule update --initThen install dependencies:
npm installnpm run start:devThen open http://localhost:3000.
Development mode uses Vite for the frontend and the local API server for logs.
The frontend runs on port 3000, the logging API runs on port 3001, and the
app loads its editable config from client/configs/config.json.
npm run build
npm run start:prodThen open http://localhost:3000.
In production mode, the server serves built assets from dist/ and exposes the
config to the browser at /configs/config.json. That production config is read
from:
CONFIG_PATHif you set it- otherwise
./config.jsonat the repo root or extracted release root
If that file does not exist, the client falls back to the bundled default config from client/configs/default-config.js.
CosmoPlot reads a JSON object with this top-level shape:
{
"functions": [],
"graph": {}
}{
"functions": [
{
"id": "f",
"expression": "m*x + b",
"visible": true
}
],
"graph": {
"xMin": -10,
"xMax": 10,
"yMin": -10,
"yMax": 10,
"showGrid": true
}
}Each entry in functions represents one row in the calculator.
Required fields:
id: unique label used by the UI and activity logexpression: the math input to classify and plot
Common optional fields:
visible: hide or show the row on first loadeditable: if set tofalse, the row is not meant to be edited in the UIderivative: tangent-line overlay for explicit functionssecants: secant-line overlays for explicit functions
Example overlay fields:
{
"id": "f",
"expression": "x^2",
"derivative": {
"x0": 1
},
"secants": [
{ "x0": -1, "x1": 1 }
]
}The graph object controls the initial viewport and display options.
Required bounds:
xMinxMaxyMinyMax
Optional fields:
showGrid:trueorfalseannotations: reference lines shown on the graph
Annotation entries use this shape:
{
"x": 2,
"text": "x = 2"
}You may also use y for a horizontal reference line. Each annotation must have at least x or y.
- Explicit graph:
sin(x) - Explicit assignment form:
y = m*x + b - Function definition form:
f(x) = x^2 - Implicit equation:
x^2 + y^2 = 9 - Strict inequality:
y > x^2 - Inclusive inequality:
x <= 3 - Points:
points([[0,0],[1,2]]) - Vector:
vector([3,2],[1,1]) - Parameter assignment:
a = 2 - Parameterized graph with sliders:
a*sin(b*x)
The local server creates a logs/ directory on startup if it does not already exist. Activity logs are written to logs/activity.log as plain text, one event per line. This matters for grading. The current app writes activity messages in these formats:
Initial state: ...Created expression ...Modified expression ...Modified expression ... (parameter: ...)Deleted expression: ...
When a modified expression is invalid, the log appends the error detail:
Modified expression expr_1: x++ -> x+ (invalid: Syntax error)
Typical examples:
Initial state: f: m*x + b
Created expression expr_1
Modified expression expr_1: -> sin(x)
Modified expression expr_1 (parameter: a): 1 -> 2
Deleted expression: sin(x)
Optional debug logging is also available by opening the app with ?debug=true. Those messages go to logs/debug.log, not activity.log.
This repo includes a GitHub Actions workflow at.github/workflows/build-release.yml that runs on every push to main.
The workflow currently does the following:
- Checks out the repository
- Initializes the design-system submodule
- Uses Node
22.13.1 - Runs
npm ci - Runs
npm run build - Reinstalls production dependencies only
- Creates
release.tar.gz - Publishes a GitHub Release tagged
v<run_number>
The generated release.tar.gz contains:
dist/package.jsonserver.js- production
node_modules/
- Download
release.tar.gzfrom the latest GitHub Release. - Extract it in the target directory.
- Provide a
config.jsonfile - Start the app:
npm run start:prod