How ndxbn/bun works
1. Project shape
- This is a single Bun + TypeScript package generated from a template, with a clear split between:
- a public library entrypoint,
- a CLI entrypoint,
- a server entrypoint,
- and a small application-specific implementation area under app/.
2. Public API boundary
- src/index.ts is the package-facing entrypoint.
- The README explicitly says this is the file to import from other projects, so it acts as the stable external surface of the repository.
3. Executable boundaries
- src/cli.ts is the command-line bootstrap used by bun cli.
- src/server.ts is the server bootstrap used by bun start.
- These are not the business logic themselves; they are the runtime adapters that wire execution into the underlying app code.
4. Application layer
- app/ConsoleApplication.ts is the main named application module in the tree.
- That suggests the repo keeps domain/workflow logic separate from bootstrapping, with app/ serving as the place for application behavior while src/ contains entrypoints and exported interfaces.
5. Execution flows
- There are two primary runtime paths:
- CLI flow: user runs bun cli ... → src/cli.ts → console application logic.
- Server flow: user runs bun start → src/server.ts → server runtime and request handling.
- Both flows likely share code through the package internals rather than duplicating logic.
6. Testing strategy
- src/main.test.ts and src/server.large.test.ts indicate the repo uses Bun’s built-in test runner with both:
- a general/main test suite,
- and a larger server-focused suite.
- This implies the server path is tested separately from lighter unit-style coverage.
7. Developer tooling
- The project is configured around Bun, Biome, and Lefthook.
- biome.json handles formatting/linting, and .lefthook.yaml suggests git hooks are used to enforce code quality locally before CI.
8. Environment and typing
- .env.example and .env.test show the app is environment-driven, even if the exact variables are not visible here.
- src/env.d.ts indicates typed environment access is part of the codebase, so configuration is treated as a first-class boundary.
9. Containerization and local orchestration
- Dockerfile is for production packaging.
- compose.yaml supports development dependencies and local middleware startup.
- .github/lint.compose.yaml suggests Docker Compose is also used to run lint-related tooling in a reproducible environment.
10. Automation and release pipeline
- GitHub Actions cover linting, coverage, Docker publishing, and security checks.
- This means the repo is set up as a shippable artifact, not just a local app or library.
11. Documentation boundary
- README.md is the developer-facing onboarding guide.
- docs/ contains additional documentation, including Japanese-localized docs under docs/ja, so documentation is maintained as a separate concern from code.
12. What is not present
- There is no visible database layer, queue consumer, message broker, or cloud-service adapter in the tree.
- Architecturally, this looks like a small self-contained Bun application/library template with CLI and server entrypoints rather than a distributed system.
13. How to draw it
- A good diagram would show:
- external users entering through CLI or server,
- both reaching a shared application/core layer,
- the public package export exposed via src/index.ts,
- and separate surrounding boxes for tests, tooling, Docker/Compose, and CI/CD.
Main entry points: index.ts Package API · cli.ts CLI Boot · server.ts Server Boot · main.test.ts Main Test
Components 20
Entrypoints
Public package surface and runtime bootstraps
- Package API · Stable import surface for consumers
src/index.ts - CLI Boot · Bun CLI entrypoint
src/cli.ts - Server Boot · Bun server entrypoint
src/server.ts
Application
Shared application logic
- Console App · Main application workflow and command handling
app/ConsoleApplication.ts - Typed Env · Typed environment declarations
src/env.d.ts
Tests
Bun test suites
- Main Test · General Bun test coverage
src/main.test.ts - Server Test · Larger server-focused test coverage
src/server.large.test.ts
Tooling
Formatting, hooks, scripts, and container orchestration
- Dev Script · Local development helper
scripts/dev.ts - Biome · Formatting and linting rules
biome.json - Lefthook · Local pre-commit and pre-push automation
.lefthook.yaml - Compose · Development and tooling services
compose.yaml
Delivery
CI, packaging, and documentation
- Dockerfile · Production image definition
Dockerfile - README · Primary onboarding and usage guide
README.md - Docs · Additional documentation and localized guides
docs/README.md - Lint Compose · Compose file for reproducible lint execution
.github/lint.compose.yaml - Lint CI · Automated lint checks
.github/workflows/lint.yaml - Coverage CI · Coverage reporting pipeline
.github/workflows/coverage.yaml - Coveralls · Coverage publishing integration
.github/workflows/coverage.coveralls.yaml - Docker Publish · Container image publishing pipeline
.github/workflows/docker-push.yaml - Security CI · Security checks and automation
.github/workflows/security.yml
Connections 20
- CLI Boot → Console App: uses · CLI bootstrap delegates to console application logic
- Server Boot → Console App: shares core · Server runtime reuses shared application behavior
- Package API → Console App: exports · Package API exposes the shared implementation surface
- CLI Boot → Typed Env: reads config · CLI path depends on typed environment access
- Server Boot → Typed Env: reads config · Server path depends on typed environment access
- Main Test → CLI Boot: tests · General suite covers the CLI/runtime boundary
- Main Test → Package API: tests · General suite covers the public package surface
- Server Test → Server Boot: tests · Server-focused suite covers request/runtime behavior
- Dev Script → CLI Boot: drives · Development helper likely launches the CLI workflow
- Biome → Package API: formats · Code style applies across the package
- Lefthook → Biome: enforces · Git hooks likely run formatting and lint checks
- Compose → Lint Compose: mirrors · Local orchestration supports reproducible lint tooling
- Dockerfile → Server Boot: packages · Container image is built around the server runtime
- README → Package API: documents · README points consumers to the package entrypoint
- Docs → README: extends · Additional docs expand on the main guide
- Lint CI → Biome: runs · CI lint workflow enforces repository style
- Coverage CI → Main Test: runs · Coverage pipeline executes the test suite
- Coveralls → Coverage CI: publishes · Coveralls workflow consumes coverage output
- Docker Publish → Dockerfile: builds · Workflow publishes the container image
- Security CI → Package API: checks · Security automation guards the shipped package