Skip to content
Alyssom Fernandes
Sections
CV
Back to projects

Praxis

Purchase requests, quotes, and approvals on one board.

praxis-af618.web.appScreens from the public demo, with sample data; interface in Brazilian Portuguese
Praxis: reports with spending for the period, requests, savings, and a monthly spending chart
Praxis on a phone: purchase request board with the stages as tabs
On this page: 01Why it exists

Why it exists

The goal was to organize the group’s purchasing. The more the group grew, the harder it was to track and control each request. To build Praxis, I took ideas from existing purchasing management and tracking tools.

Problem, system, and proof

Problem

Requests, quotes, and approvals that were hard to track.

System

Corporate purchasing in 7 stages: side-by-side quotes, approvals, installments, deadlines, and time per stage, with 6 access roles.

Proof

45 tests

15 unit and 30 Firestore and Storage rules tests, on GitHub Actions. Checked on 9 Nov 2026.

A closer look

  1. One column per stage

    Each column gives the number of requests in it and their total in BRL. Each card shows the company, the amount, and how many days are left until the deadline.

  2. Side-by-side quotes

    Proposals on the same screen, with price, difference from the lowest, delivery time, and terms. The recommended one is flagged.

  3. 6 access roles

    The request shows who needs to act now and the savings against the most expensive proposal. From requester to general administrator, with buyer, approver, manager, and finance in between, each with its own permissions.

  4. Installs as an app

    A PWA: the same flow on a phone, with the stages as tabs and navigation at the bottom.

How it was built

Architecture

Praxis is a plain JavaScript SPA: index.html loads js/app.js as an ES Module, which tracks the login and picks the screen from the ?tela= query. There is no server of its own: data lives in Firestore, files in Storage, and authorization in the security rules, which read the role and companies stored in the token. Cloud Functions keep that token up to date and send the notifications for each status change.

View in code: index.html L126 arquitetura.md L1–20 firestore.rules L271–305 triggers.js L9–43

Data flow
  1. Action on screen
  2. Firestore rules
  3. Request and history
  4. Functions trigger
  5. Bell notification

Technical decisions

  1. Each order step validated in the rules

    I wrote each step of a request as a function in the Firestore rules (assumir, aprovar, pagar…), which checks the source and target status, the role and, with mudouSo, which fields that step may change. The role and companies come from the token, written by the setUserClaims function on every write to /usuarios; that way, the rules decide without reading another document.

    View in code: firestore.rules L182–263 firestore.rules L59–61 triggers.js L9–38 arquitetura.md L27

  2. Transactions to claim and decide

    Claiming, releasing, approving, and rejecting run in runTransaction: the transaction rereads the request and gives up if someone else has already claimed or decided it, so two simultaneous clicks don't turn into two decisions. _historicoJunto writes the history entry in the same transaction or batch, and the rules don't allow editing the history: a request can't change status without a record.

    View in code: pedido-detalhe.js L1406–1520 pedido-detalhe.js L2614–2622 firestore.rules L361–366

  3. No framework and no build step

    The browser loads the ES Modules directly, and the Firebase SDK comes from the CDN pinned at version 13.1.0, preloaded with modulepreload. With no bundler, what is in the repository is what goes to Hosting. On localhost, js/firebase.js connects the app to the emulators automatically, and the whole app runs on the machine without touching real data. In CI, each module goes through node --check.

    View in code: index.html L43–47 firebase.js L1–58 arquitetura.md L25 testes.yml L33–34

Challenge

A public demo with an exposed password

The demo requires a login, and the demo account's password is in js/config.js, which the site serves to any visitor. So the rules recognize that account by its email and give it the demo role, which counts as no other role: it only reads and writes documents with isDemo == true and requests with a demo-… ID. Firestore's automatic IDs have no hyphen, and the isDemo flag can't change after creation: no real request gets into that area.

View in code: firestore.rules L11–36 firestore.rules L265–269 storage.rules L6–16 regras.test.mjs L224–335 README.md L91

Testing

There are 15 unit tests with node --test, on the pure functions in js/utils.js and js/constants.js and the access rule for the demo reset in the Functions, and 30 tests of the Firestore and Storage rules, which run on the emulator and check, for example, that whoever opened a request can't approve it and that status and history are written together. GitHub Actions runs both on every push to main and on pull requests, plus the Cloud Functions lint.

View in code: unidade.test.mjs regras.test.mjs package.json L7–11 testes.yml

Stack and links

Stack

JavaScript (ES modules), Firebase (Firestore, Auth, Storage, Hosting), PWA, Cloud Functions, node:test, GitHub Actions