Skip to content

Commit e850ed1

Browse files
committed
docs(map): add utilities and logging entries to CODEBASE_MAP
Update the codebase map to include new CLI utilities, IaC client files, and logging modules for webhooks, functions, and audit. The map now reflects the latest project structure and added documentation for the new files.
1 parent 9c72bf6 commit e850ed1

1 file changed

Lines changed: 101 additions & 32 deletions

File tree

CODEBASE_MAP.md

Lines changed: 101 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BetterBase — Codebase Map
22

3-
> Last updated: 2026-03-28
3+
> Last updated: 2026-03-29
44
55
## What is BetterBase?
66

@@ -279,16 +279,17 @@ betterbase/
279279
│ │ │ │ ├── watcher.ts # File watcher for hot reload
280280
│ │ │ │ ├── error-formatter.ts # Error formatting
281281
│ │ │ │ └── query-log.ts # Query logging (NEW)
282-
│ │ │ └── utils/ # CLI utilities (8 files)
283-
│ │ │ ├── context-generator.ts # Generates .betterbase-context.json
284-
│ │ │ ├── logger.ts # Colored console logging
285-
│ │ │ ├── prompts.ts # Interactive prompts (Inquirer)
286-
│ │ │ ├── provider-prompts.ts # Database provider selection
287-
│ │ │ ├── route-scanner.ts # Hono route scanning
288-
│ │ │ ├── schema-scanner.ts # Drizzle schema scanning
289-
│ │ │ ├── scanner.ts # Schema scanner core
290-
│ │ │ └── migrate-utils.ts # Migration utilities
291-
│ │ └── test/ # CLI tests (20+ test files)
282+
│ │ │ └── utils/ # CLI utilities (9 files)
283+
│ │ │ │ ├── api-client.ts # API client for cloud operations
284+
│ │ │ │ ├── context-generator.ts # Generates .betterbase-context.json
285+
│ │ │ │ ├── credentials.ts # Credentials management
286+
│ │ │ │ ├── logger.ts # Colored console logging
287+
│ │ │ │ ├── prompts.ts # Interactive prompts (Inquirer)
288+
│ │ │ │ ├── provider-prompts.ts # Database provider selection
289+
│ │ │ │ ├── route-scanner.ts # Hono route scanning
290+
│ │ │ │ ├── schema-scanner.ts # Drizzle schema scanning
291+
│ │ │ │ └── scanner.ts # Schema scanner core
292+
│ │ └── test/ # CLI tests (30+ test files)
292293
│ │
293294
│ ├── client/ # @betterbase/client - TypeScript SDK
294295
│ │ ├── package.json
@@ -304,8 +305,14 @@ betterbase/
304305
│ │ │ ├── query-builder.ts # Chainable query builder
305306
│ │ │ ├── realtime.ts # Realtime subscription client
306307
│ │ │ ├── storage.ts # Storage client
307-
│ │ │ └── types.ts # TypeScript definitions
308-
│ │ └── test/ # Client tests (6+ test files)
308+
│ │ │ ├── types.ts # TypeScript definitions
309+
│ │ │ └── iac/ # IaC client (Phase 3)
310+
│ │ │ ├── index.ts # IaC exports
311+
│ │ │ ├── hooks.ts # React hooks (useQuery, useMutation, useAction)
312+
│ │ │ ├── vanilla.ts # Non-React client
313+
│ │ │ ├── paginated-query.ts # Paginated query support
314+
│ │ │ └── embeddings.ts # Embedding utilities
315+
│ │ └── test/ # Client tests (10+ test files)
309316
│ │
310317
│ ├── core/ # @betterbase/core - Core backend engine
311318
│ │ ├── package.json
@@ -405,25 +412,51 @@ betterbase/
405412
│ │ │ └── 014_inngest_support.sql
406413
│ │ └── src/
407414
│ │ ├── index.ts # Server entry point
415+
│ │ ├── types.d.ts # TypeScript declarations
408416
│ │ ├── lib/
409417
│ │ │ ├── db.ts # Database connection
410418
│ │ │ ├── migrate.ts # Migration runner
411419
│ │ │ ├── env.ts # Environment validation
412420
│ │ │ ├── auth.ts # Auth utilities
413421
│ │ │ ├── admin-middleware.ts # Admin auth middleware
414422
│ │ │ ├── inngest.ts # Inngest client & functions
415-
│ │ │ └── webhook-dispatcher.ts # Webhook event dispatcher
423+
│ │ │ ├── webhook-dispatcher.ts # Webhook event dispatcher
424+
│ │ │ ├── webhook-logger.ts # Webhook delivery logging
425+
│ │ │ ├── function-logger.ts # Function invocation logging
426+
│ │ │ └── audit.ts # Audit logging
416427
│ │ └── routes/
417428
│ │ ├── admin/ # Admin API routes
418429
│ │ │ ├── index.ts
419430
│ │ │ ├── auth.ts
420431
│ │ │ ├── projects.ts
421432
│ │ │ ├── users.ts
422433
│ │ │ ├── metrics.ts
434+
│ │ │ ├── metrics-enhanced.ts # Enhanced metrics
423435
│ │ │ ├── storage.ts
424436
│ │ │ ├── webhooks.ts
425437
│ │ │ ├── functions.ts
426-
│ │ │ └── logs.ts
438+
│ │ │ ├── logs.ts
439+
│ │ │ ├── audit.ts
440+
│ │ │ ├── roles.ts # Role management
441+
│ │ │ ├── notifications.ts # Notification system
442+
│ │ │ ├── smtp.ts # SMTP configuration
443+
│ │ │ ├── api-keys.ts # API key management
444+
│ │ │ ├── cli-sessions.ts # CLI session management
445+
│ │ │ ├── inngest.ts # Inngest integration
446+
│ │ │ ├── instance.ts # Instance settings
447+
│ │ │ └── project-scoped/ # Project-specific routes
448+
│ │ │ ├── index.ts
449+
│ │ │ ├── database.ts # Database management
450+
│ │ │ ├── functions.ts # Function management
451+
│ │ │ ├── users.ts # Project users
452+
│ │ │ ├── env.ts # Environment variables
453+
│ │ │ ├── auth-config.ts # Auth configuration
454+
│ │ │ ├── webhooks.ts # Project webhooks
455+
│ │ │ ├── realtime.ts # Realtime settings
456+
│ │ │ └── iac.ts # IaC management
457+
│ │ ├── betterbase/ # BetterBase IaC API routes
458+
│ │ │ ├── index.ts # Main IaC API handler
459+
│ │ │ └── ws.ts # WebSocket handler
427460
│ │ └── device/ # Device auth routes
428461
│ │ └── index.ts
429462
│ │
@@ -1064,6 +1097,38 @@ Infrastructure as Code module - Convex-inspired database and functions.
10641097
**Purpose:** Registry for all IaC functions.
10651098
- **Exports:** `registerFunction`, `lookupFunction`, `listFunctions`
10661099

1100+
#### [`iac/storage/`](packages/core/src/iac/storage/)
1101+
**Purpose:** IaC storage context for file operations.
1102+
1103+
#### [`iac/storage/storage-ctx.ts`](packages/core/src/iac/storage/storage-ctx.ts)
1104+
**Purpose:** Storage operations for IaC functions.
1105+
- **Exports:** `StorageContext`, `createStorageContext`
1106+
- **Key Features:**
1107+
- File upload and download
1108+
- Signed URL generation
1109+
- Storage policy enforcement
1110+
1111+
#### [`iac/realtime/`](packages/core/src/iac/realtime/)
1112+
**Purpose:** IaC realtime subscription infrastructure.
1113+
1114+
#### [`iac/realtime/table-dep-inferrer.ts`](packages/core/src/iac/realtime/table-dep-inferrer.ts)
1115+
**Purpose:** Infers table dependencies from queries for cache invalidation.
1116+
- **Exports:** `inferTableDependencies`, `TableDependencies`
1117+
1118+
#### [`iac/realtime/invalidation-manager.ts`](packages/core/src/iac/realtime/invalidation-manager.ts)
1119+
**Purpose:** Manages query result cache invalidation.
1120+
- **Exports:** `InvalidationManager`, `createInvalidationManager`
1121+
- **Key Features:**
1122+
- Tracks query dependencies
1123+
- Invalidates cached results on data changes
1124+
1125+
#### [`iac/realtime/subscription-tracker.ts`](packages/core/src/iac/realtime/subscription-tracker.ts)
1126+
**Purpose:** Tracks active subscriptions for realtime updates.
1127+
- **Exports:** `SubscriptionTracker`, `createSubscriptionTracker`
1128+
- **Key Features:**
1129+
- Manages subscription lifecycle
1130+
- Broadcasts updates to subscribers
1131+
10671132
### webhooks/
10681133

10691134
#### [`webhooks/index.ts`](packages/core/src/webhooks/index.ts)
@@ -1274,6 +1339,14 @@ Realtime subscriptions module for WebSocket-based live data updates.
12741339
- Cohere embeddings support
12751340
- Text-to-vector conversion
12761341

1342+
#### [`src/iac/paginated-query.ts`](packages/client/src/iac/paginated-query.ts)
1343+
**Purpose:** Paginated query support for IaC functions.
1344+
- **Exports:** `PaginatedQuery`, `createPaginatedQuery`
1345+
- **Key Features:**
1346+
- Cursor-based pagination
1347+
- Limit and offset support
1348+
- Total count estimation
1349+
12771350
---
12781351

12791352
## packages/cli
@@ -2003,27 +2076,23 @@ bun test
20032076

20042077
All notable changes to BetterBase will be documented in this file.
20052078

2006-
### Recent Updates (2026-03-26)
2079+
### Recent Updates (2026-03-29)
20072080

2008-
#### New Features
2009-
- **AI Context Generation**: Added intelligent context generation for AI assistants to understand project structure and provide more accurate recommendations
2010-
- **Branch Management**: New `bb branch` command for creating and managing database branches for development, staging, and production
2011-
- **Vector Search**: Integrated vector search capabilities for AI-powered semantic search functionality
2012-
- **Auto-REST**: Automatic REST API generation from Drizzle schema definitions
2013-
- **Enhanced CLI**: Expanded from 12 to 21 commands with improved migration, storage, webhook, and function management
2081+
#### Documentation Updates
2082+
- **CODEBASE_MAP.md**: Updated to reflect new IaC realtime modules, server routes, and client features
20142083

2015-
#### Self-Hosted Deployment
2016-
- **Admin Dashboard**: New React-based admin dashboard (`apps/dashboard`) for self-hosted instances
2017-
- **Server Package**: Comprehensive `@betterbase/server` package with admin API, project management, metrics, and device authentication
2018-
- **Nginx Reverse Proxy**: Docker-based nginx configuration for production deployments
2084+
#### New Modules Added
2085+
- **IaC Storage**: Added `iac/storage/storage-ctx.ts` for file operations in IaC functions
2086+
- **IaC Realtime**: Added `iac/realtime/` subdirectory with table dependency inference, invalidation manager, and subscription tracker
2087+
- **Server Routes**: Added project-scoped routes (database, functions, users, env, auth-config, webhooks, realtime, iac)
2088+
- **Server Libs**: Added webhook-logger.ts, function-logger.ts, audit.ts
2089+
- **CLI Utils**: Added api-client.ts, credentials.ts
2090+
- **Client IaC**: Added paginated-query.ts for cursor-based pagination
20192091

20202092
#### Package Updates
2021-
- **packages/cli**: 21 commands (init, dev, migrate, migrate preview, migrate production, migrate rollback, migrate history, auth, auth add-provider, generate crud, graphql, graphql playground, storage init, storage list, storage upload, rls, rls create, rls list, rls disable, rls test, webhook, function, branch, login, logout)
2022-
- **packages/client**: Auth, Query Builder, Realtime, Storage, Errors modules
2023-
- **packages/core**: Config, Functions, GraphQL, Middleware, Migration, Providers, RLS, Storage, Vector, Branching, Auto-REST, Webhooks, Logger, Realtime
2024-
- **packages/server**: Self-hosted server with admin routes, device auth, migrations
2025-
- **packages/shared**: Types, Errors, Constants, Utils
2026-
- **apps/dashboard**: React admin dashboard with project management, metrics, storage, webhooks, functions pages
2093+
- **packages/cli**: 30+ test files, 9 utility modules
2094+
- **packages/client**: IaC client with hooks, vanilla client, paginated queries, embeddings
2095+
- **packages/server**: Enhanced admin routes with roles, notifications, SMTP, API keys, CLI sessions, Inngest integration
20272096
- **apps/test-project**: Example project demonstrating all features
20282097

20292098
---

0 commit comments

Comments
 (0)