Hey! Welcome to the xray-sys repository. This is a lightweight observability system designed to track, monitor, and analyze execution pipelines (think LLM chains, data workflows, or complex job sequences).
The goal here is simple: provide a way to trace exactly what happens inside your runs—step by step—capturing inputs, outputs, errors, and even the reasoning behind decisions.
This is a monorepo setup containing the core pieces of the system:
packages/api: The backend service built with Express and PostgreSQL. It handles data ingestion and exposes the API for creating/updating runs and steps. It uses Prisma for ORM.packages/sdk: A TypeScript SDK for instrumenting your applications. You drop this into your code to start recording runs automatically.packages/examples: (Work in progress) Practical examples of how to integrate the SDK.
- Instrumentation: You wrap your code blocks using the SDK.
- Ingestion: The SDK sends telemetry data (runs, steps, candidates) to the API.
- Storage: The API persists structured traces into PostgreSQL, capturing hierarchy (
Run->Step->Child Step) and detailed metrics. - Analysis: (Future) You query the data to understand failure rates, latency bottlenecks, or audit decision paths.
Prerequisites:
- Node.js (v18+ recommended)
- PostgreSQL running locally or accessible via URL.
Clone the repo and install dependencies from the root:
npm installYou need a Postgres database. Create a .env file in packages/api/ with your database URL (or update the existing one):
DATABASE_URL="postgresql://user:password@localhost:5432/xray_db"Then run the migrations to create the schema:
cd packages/api
npm run prisma:migrateTo start the backend in development mode:
# From packages/api
npm run devThe server usually starts on port 3000 (or whatever is defined in your environment).
If you are making changes to the SDK:
cd packages/sdk
npm run buildCheck the packages/examples folder for full code snippets.
Roughly, instrumenting a function looks like this:
import { XrayClient } from "@xray-sys/sdk";
const client = new XrayClient({ baseUrl: "http://localhost:3000" });
async function main() {
const run = await client.startRun({ pipeline: "data-processing-v1" });
try {
// Record a step
await run.step("fetch-data", async (step) => {
// do your work...
step.complete({ output: { items: 5 } });
});
await run.complete({ status: "success" });
} catch (err) {
await run.fail(err);
}
}Just so you know what you're getting into, here is the current status:
- No UI: Currently, this is a headless system. You have to query the database directly or use Prisma Studio (
npm run prisma:studioinpackages/api) to view the data. A dashboard is the next big milestone. - Auth: The API is currently open (no authentication middleware). Don't expose this to the public internet without adding an auth layer.
- SDK Features: The SDK does basic tracing. Advanced features like automatic error capturing for specialized libraries aren't there yet.
- Validation: Input validation is minimal beyond what Zod enforces at the API level.
Feel free to dive in! If you modify the DB schema, remember to run prisma generate and prisma migrate.
Happy coding! 🚀