beiju-dev/beiju
beiju-dev/beiju has 53 GitHub stars and 4 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-12 18:19 UTC. Last push 2026-09-16.
Comment ces chiffres sont mesurés
A Node.js analytical query builder inspired by Kysely and other popular libraries.
What you can do
- Window Functions: RANK, DENSE_RANK, ROW_NUMBER, LAG, LEAD, NTILE, with full PARTITION BY / ORDER BY / ROWS BETWEEN support
- Aggregations: SUM, AVG, COUNT, MIN, MAX, including nested aggregates (AVG(SUM(col)))
- JOINs: INNER, LEFT, RIGHT, FULL OUTER
- Composable WHERE: comparison operators, BETWEEN, IN, plus or() / and() helpers
Progression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- Historique en cours
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalBeiju
Beiju | Leia em Português 🇧🇷
Beiju-site | (demo) | beiju.dev
An analytical query builder for Node.js, with a Semantic Layer and bilingual API (English / Portuguese).
Beiju compiles fluent TypeScript method chains into safe, parameterized SQL, abstracting OLAP operations (Window Functions, aggregations, JOINs, temporal comparisons) that traditional ORMs like Prisma and TypeORM were never designed to handle.
const result = await vendas
.select([
vendas.vendedor_id,
vendas.total.sum().as('total_vendas'),
rank()
.over(w => w.partitionBy('mes').orderBy(vendas.total.sum(), 'DESC'))
.as('ranking'),
])
.groupBy(vendas.vendedor_id, vendas.mes)
.fetch()
No raw SQL strings. No manual column casting. Full IDE autocomplete and compile-time type checking on every column reference.
Why Beiju?
Node.js has mature ORMs for transactional (OLTP) workloads, but a real gap exists when a backend developer needs to build a sales ranking, a month-over-month comparison, or a moving average directly inside the application. The usual path is dropping into raw SQL strings, losing type safety and readability in the process.
Beiju closes that gap with a Semantic Layer: instead of writing SELECT, WHERE, and GROUP BY against string column names, you reference columns as typed objects (vendas.total, vendas.vendedor_id), introspected automatically from your PostgreSQL schema at runtime.
Installation
npm i beiju
Requires Node.js 20+ and PostgreSQL.
Quick Start
English API
import { AnalyticsContext, rank } from 'beiju'
const ctx = new AnalyticsContext('postgresql://user:pass@localhost:5432/mydb')
const vendas = await ctx.table('vendas')
const result = await vendas
.select([
vendas.vendedor_id,
vendas.mes,
vendas.total.sum().as('total_vendas'),
rank()
.over(w => w.partitionBy('mes').orderBy(vendas.total.sum(), 'DESC'))
.as('ranking'),
])
.where(vendas.mes.eq('2026-01'))
.groupBy(vendas.vendedor_id, vendas.mes)
.fetch()
API em Português
A mesma biblioteca, o mesmo motor, vocabulário localizado:
import { AnalyticsContext, classificar } from 'beiju'
const ctx = new AnalyticsContext('postgresql://user:pass@localhost:5432/mydb')
const vendas = await ctx.table('vendas')
const resultado = await vendas
.selecione([
vendas.vendedor_id,
vendas.mes,
vendas.total.soma().como('total_vendas'),
classificar()
.sobre(w => w.particionePor('mes').ordenePor(vendas.total.soma(), 'DESC'))
.como('classificacao'),
])
.onde(vendas.mes.igual('2026-01'))
.agrupePor(vendas.vendedor_id, vendas.mes)
.buscar()
Both forms produce the exact same SQL. Pick whichever vocabulary fits your team, or mix them freely in the same query.
Features
- Window Functions:
RANK,DENSE_RANK,ROW_NUMBER,LAG,LEAD,NTILE, with fullPARTITION BY/ORDER BY/ROWS BETWEENsupport - Aggregations:
SUM,AVG,COUNT,MIN,MAX, including nested aggregates (AVG(SUM(col))) - JOINs:
INNER,LEFT,RIGHT,FULL OUTER - Composable WHERE: comparison operators,
BETWEEN,IN, plusor()/and()helpers - Automatic schema introspection: no manual table mapping, columns are typed and autocompletable out of the box
@RawSqlescape hatch: drop down to native SQL when needed, sharing the same connection and parameter-binding safety- Portuguese aliases: every method in the Semantic Layer has a Portuguese equivalent
Architecture
Beiju is built in four layers, following Hexagonal Architecture and Domain-Driven Design:
Semantic Layer → AnalyticsContext, Table, TypedColumn
Builders → Fluent DSL (SelectBuilder, WindowBuilder, JoinBuilder)
Core (Compiler) → AST nodes + SqlGenerator
Infrastructure → PgAdapter (PostgreSQL)
The core never imports infrastructure code. Query construction (builders) is entirely decoupled from SQL generation (SqlGenerator), which is decoupled from execution (PgAdapter). This is what makes the compiler core fully unit-testable without a live database connection.
Project Status
Beiju was developed as an undergraduate thesis (TCC) project at Instituto Federal de Sergipe, Campus Lagarto, in the Sistemas de Informação program. It is functional and validated against PostgreSQL with both unit and integration tests, but should be considered a research artifact rather than a production-hardened library at this stage.
Currently out of scope (tracked as future work): CSV/Parquet adapters, HAVING, DISTINCT, nested WHERE grouping with mixed AND/OR precedence, and CTE support.
Contributing
Beiju is open source and contributions are welcome, whether that's a bug report, a new adapter, additional Window Functions, or improvements to the Portuguese vocabulary. Feel free to open an issue to discuss an idea before submitting a pull request.
See CONTRIBUTING.md · CONTRIBUINDO.md
If you're using Beiju in a real project or experimenting with it for study purposes, we'd love to hear about it.
Changelog
See CHANGELOG.md for a history of notable changes.
Community
Join our Discord Discord
License
MIT. See LICENSE.md.
Acknowledgments
Developed by Junior Teixeira (junior-zip) as an academic project at the Instituto Federal de Sergipe.
Explorer des projets similaires
Asabeneh/30-Days-Of-Python
Le défi de programmation 30 Days of Python est un guide pas à pas pour apprendre le langage de programmation Python en 30 jours. Ce défi peut prendre plus de 100 jours. Avancez à votre rythme. Ces vidéos peuvent aussi vous aider : https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,618 étoilesgrafana/grafana
Plateforme ouverte et composable d’observabilité et de visualisation de données. Visualise les métriques, les journaux et les traces issus de plusieurs sources, comme Prometheus, Loki, Elasticsearch, InfluxDB, Postgres et bien d’autres.
77,859 étoilesredis/redis
Pour les développeurs qui créent des applications en temps réel pilotées par les données, Redis est le cache, le serveur de structures de données et le moteur de requêtes documentaires et vectorielles préféré, le plus rapide et le plus riche en fonctionnalités.
77,472 étoilesapache/superset
Apache Superset est une plateforme de visualisation et d'exploration de données.
75,495 étoiles