Skip to content
@mgpl-diagnostics

mgpl-diagnostics

MGPL Diagnostics: building the future of diagnostic software, in public

Open, modular software for Maa Gayatri Path Lab, a pathology laboratory in Arang, Raipur, Chhattisgarh.
Covers patients, samples, reports, billing, books and catalog, as small typed packages that each do one job well.

TypeScript GraphQL Fastify MongoDB PostgreSQL Redis Next.js react-pdf


🧱 Backend kits

db-kit  data

Patients, bookings, samples, reports, invoices and payments on MongoDB or PostgreSQL, behind one API. Workflows are ACID on both. Stores the books and the finance records, and includes a Redis cache toolkit.

auth-kit  auth

scrypt passwords and revocable sessions, plus timing-safe, rate-limited login and single-use reset links. Roles and permissions work per branch, for a multi-branch lab.

614 tests, each with parameters, units, methods, reference ranges, sample types and prices. Fuzzy search (~30 µs) understands lab shorthand: lft, kft, sgpt, fbs, vit d.

A4 lab reports and patient invoices as PDF, rendered in pure Node.js, with matching HTML. Letterhead, barcode, QR and GST bills accurate to the paisa.

ledger-kit  books

Our own accounting engine: the 28 standard account groups, ledgers and vouchers, numbered per financial year and always balanced. Invoices and payments post themselves, and lock dates hold. Trial balance, day book, P&L and balance sheet, proven identical on MongoDB and PostgreSQL.

finance-kit  money

GST by place of supply with GSTR-1 and GSTR-3B data, B2B receivables and credit notes, and collection-centre settlements with TDS. Also day-end cash, bank reconciliation, lock dates, year-end close and CSV exports for the CA.

security-kit  security

One package for both sides. Frontends collect a device id, a per-tab id and a coarse fingerprint; the backend binds them to the session and stops a token used from another browser. Also client IP behind proxies, security and CORS headers, and log redaction. Zero dependencies.

mail-kit  mail

Mails written in our own mail design language instead of HTML, compiled to email-safe HTML and plain text in one design. Sent through the worker's queue when it is running, or straight over SMTP when it is not. Zero dependencies.

worker-kit  jobs

Background jobs defined once and run on BullMQ over Redis by a separate worker, in-process when there is no Redis, or on the worker when it is up and standalone when it is not. Same retries, results and error messages everywhere.

…and many more  on the way

Each new kit does one job well and plugs into the same GraphQL API. Watch this organisation for what ships next.

🖥️ Apps and clients

api backend The backend: one GraphQL endpoint on Fastify that combines every kit
client frontend Headless, typed, zero-dependency SDK with a method for every GraphQL operation. Bring your own UI
website site The lab's public website: a living 3D lab, the full test catalogue with prices, home collection and booking
report-studio app Reference Next.js app: report and invoice designer, result entry
lab-panel coming soon Registrations, samples, results, billing and books for every branch
auth client coming soon Sign-in for frontends, with adapters for TanStack Query and others

🧭 How it fits together

flowchart LR
  subgraph Apps
    P[lab panel]
    S[report-studio]
    W[website]
  end
  Apps -->|"GraphQL"| API["api<br/>Fastify · GraphQL Yoga"]
  API --> AUTH[auth-kit]
  API --> DB[db-kit]
  API --> CAT[catalog-kit]
  API --> RND["report-kit · invoice-kit"]
  API --> FIN[finance-kit]
  FIN --> BOOKS[ledger-kit]
  BOOKS --> DB
  FIN --> DB
  DB --> M[(MongoDB)]
  DB --> PG[(PostgreSQL)]
  DB --> R[(Redis)]
  AUTH --> R
  RND --> PDF["A4 PDF / HTML<br/>inside the GraphQL response"]
Loading

One endpoint. Everything goes through POST /graphql, PDFs included (as base64). The only other route is a health check.

⚡ A taste

import { createMgplGraphQLClient, documentBlob, openBlob } from "@mgpl-diagnostics/client";

const mgpl = createMgplGraphQLClient({ url: "https://api.your-lab.in/graphql" });
await mgpl.auth.login({ email: "desk@your-lab.in", password });

const patient = await mgpl.patients.register({ branchId, name: "Kavita Sharma", sex: "female", ageYears: 32 });
const invoice = await mgpl.invoices.issue({
  branchId, patientId: patient.id,
  items: [{ code: "CBC" }],                          // name and MRP from the catalog
  payments: [{ amountPaise: 30000, mode: "upi" }],
});
// → numbered per branch and financial year, Sales + Receipt vouchers posted, books still balance

openBlob(documentBlob(await mgpl.documents.invoice(invoice.id)));  // the A4 PDF, as base64 over GraphQL

✅ How we work

  • Money is exact. Integer paise, double-entry vouchers that must balance, and ACID transactions on MongoDB and PostgreSQL. Tests show two concurrent overpayments can't both succeed.
  • Both databases, one contract. The same test suite runs on real MongoDB and real PostgreSQL.
  • Secure by default. Tokens are stored only as hashes. Data is isolated per organisation, and permissions are checked per branch.
  • HTML and PDF match. One geometry, one row model, the same page breaks; every value is checked inside the PDF.
  • No patient data in any repo. Real signatures load at runtime from the server and are never committed.
  • Docs for people and AI. Every repo has a README, AGENTS.md and llms.txt.
  • Reviewed, always. Nobody pushes to main. Every change is a pull request from a fork, with green CI and a code-owner review. How to contribute →

© MGPL Diagnostics (Maa Gayatri Path Lab), Arang, Raipur. Code is published for reference; all rights reserved.

Popular repositories Loading

  1. website website Public

    Public website of Maa Gayatri Path Lab, Arang, Raipur: Next.js, a 3D living-lab scene, test catalogue and booking.

    JavaScript

  2. report-studio report-studio Public

    Reference Next.js app: report and invoice designer on the headless client, with one backend route.

    HTML

  3. report-kit report-kit Public

    A4 lab reports as PDF in pure Node.js with matching HTML: 31 test templates, letterhead, barcode and QR. Backend library with an HTTP handler and Fastify plugin.

    TypeScript

  4. client client Public

    Headless, zero-dependency TypeScript client for the MGPL Diagnostics API, with GraphQL and session handling. Bring your own UI.

    TypeScript

  5. .github .github Public

    Organisation profile, community health files and repository rules for MGPL Diagnostics.

    JavaScript

  6. invoice-kit invoice-kit Public

    Patient invoices exact to the paisa: GST, discounts, split payments, amount in words. A4 PDF and HTML on the lab letterhead.

    TypeScript

Repositories

Showing 10 of 16 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…