App · TypeScript
Smart Rule-Based Approval Engine
Rules engine that auto-decides leave, expense and discount requests. Go, Gin, PostgreSQL, React.
Why it exists
We built it to learn how a real approval workflow is put together: business rules that admins can change without a deploy, roles enforced on the server, and a scheduled job that has to respect weekends and holidays. Taking it from a working prototype to a public production deploy taught the rest: configuration that refuses to start when it is unsafe, migrations that work on an empty database, demo data that resets itself, and tests that run a real Postgres in CI.
What it does
- 01
Three request types. leave (working days, from and to inclusive; weekends and admin-set holidays are not counted), expense (amount and category) and discount (percentage), each with a balance per employee.
- 02
Rules engine. one rule per request type and grade, stored as JSON conditions such as {"max_days": 3}, {"max_amount": 5000} or {"max_percent": 10}. Inside the limit: AUTO_APPROVED; above it: PENDING for the manager.
- 03
Approvals. managers and admins approve or reject pending requests with a comment; employees can cancel their own pending requests.
- 04
Nightly auto-reject of requests still pending after 7 working days (weekends and admin-set holidays skipped), at midnight India time.
- 05
Roles. employee, manager and admin, enforced on the server from the signed session token. Sign-up only ever creates employees.
- 06
Rule drafting (optional). an admin types a sentence such as "auto-approve expenses under 5000 for grade 2"; a language model proposes one rule, which is checked against the grade limits and shown as a before and after. Nothing is saved until the admin confirms. Off unless GEMINI_API_KEY is set; see docs/rule-drafting.md.
Next
event-order