@totaland/create-starter-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # create-starter-kit
2
+
3
+ Scaffolding tool for creating new starter-kit projects.
4
+
5
+ ## Usage
6
+
7
+ ### Using pnpm create (recommended)
8
+
9
+ ```bash
10
+ pnpm create starter-kit my-new-project
11
+ ```
12
+
13
+ ### Using pnpm dlx
14
+
15
+ ```bash
16
+ pnpm dlx create-starter-kit my-new-project
17
+ ```
18
+
19
+ ### Using npx
20
+
21
+ ```bash
22
+ npx create-starter-kit my-new-project
23
+ ```
24
+
25
+ ## What it does
26
+
27
+ 1. Creates a new directory with your project name
28
+ 2. Copies the entire starter-kit template
29
+ 3. Updates the `package.json` name field to match your project name
30
+ 4. Provides next steps for installation and running the project
31
+
32
+ ## Local Development
33
+
34
+ To test this locally before publishing:
35
+
36
+ 1. Build the template:
37
+ ```bash
38
+ cd /path/to/starter-kit
39
+ ./scripts/sync-template.sh
40
+ ```
41
+
42
+ 2. Link the package globally:
43
+ ```bash
44
+ cd create-starter-kit
45
+ pnpm link --global
46
+ ```
47
+
48
+ 3. Test it:
49
+ ```bash
50
+ cd /tmp
51
+ pnpm create starter-kit test-project
52
+ ```
53
+
54
+ ## Publishing
55
+
56
+ To publish to npm:
57
+
58
+ ```bash
59
+ cd create-starter-kit
60
+ pnpm publish
61
+ ```
62
+
63
+ Once published, anyone can use:
64
+ ```bash
65
+ pnpm create starter-kit my-project
66
+ ```
package/bin/index.js ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { copyFileSync, mkdirSync, readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs';
4
+ import { dirname, join, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+
9
+ // Get the project name from command line arguments
10
+ const projectName = process.argv[2];
11
+
12
+ if (!projectName) {
13
+ console.error('Error: Please provide a project name');
14
+ console.log('Usage: pnpm create starter-kit <project-name>');
15
+ process.exit(1);
16
+ }
17
+
18
+ // Resolve paths
19
+ const templateDir = resolve(__dirname, '../template');
20
+ const targetDir = resolve(process.cwd(), projectName);
21
+
22
+ console.log(`Creating new starter-kit project: ${projectName}`);
23
+ console.log(`Target directory: ${targetDir}`);
24
+
25
+ // Function to recursively copy directory
26
+ function copyDir(src, dest) {
27
+ mkdirSync(dest, { recursive: true });
28
+
29
+ const entries = readdirSync(src, { withFileTypes: true });
30
+
31
+ for (const entry of entries) {
32
+ const srcPath = join(src, entry.name);
33
+ const destPath = join(dest, entry.name);
34
+
35
+ if (entry.isDirectory()) {
36
+ copyDir(srcPath, destPath);
37
+ } else {
38
+ copyFileSync(srcPath, destPath);
39
+ }
40
+ }
41
+ }
42
+
43
+ try {
44
+ // Copy template to target directory
45
+ copyDir(templateDir, targetDir);
46
+
47
+ // Update package.json with the new project name
48
+ const packageJsonPath = join(targetDir, 'package.json');
49
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
50
+
51
+ packageJson.name = projectName;
52
+
53
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
54
+
55
+ console.log('\n✅ Project created successfully!');
56
+ console.log('\nNext steps:');
57
+ console.log(` cd ${projectName}`);
58
+ console.log(' pnpm install');
59
+ console.log(' pnpm dev');
60
+
61
+ } catch (error) {
62
+ console.error('Error creating project:', error.message);
63
+ process.exit(1);
64
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@totaland/create-starter-kit",
3
+ "version": "1.0.0",
4
+ "description": "Scaffolding tool for creating new starter-kit projects",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "bin": {
10
+ "create-starter-kit": "./bin/index.js"
11
+ },
12
+ "files": [
13
+ "bin",
14
+ "template"
15
+ ],
16
+ "keywords": [
17
+ "starter-kit",
18
+ "scaffold",
19
+ "template"
20
+ ],
21
+ "dependencies": {
22
+ "fast-glob": "^3.3.2"
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ # Example .env file for Order System
2
+
3
+ # Database (Optional - if not set, uses in-memory storage)
4
+ # Uncomment to use PostgreSQL with Drizzle ORM
5
+ # DATABASE_URL=postgres://user:password@localhost:5432/orders_db
6
+
7
+ # Server Configuration
8
+ PORT=3000
@@ -0,0 +1,23 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ TypeScript sources live in `src/`, with graph traversal logic under `src/graph/` (crawl policy, state hashing, trajectory storage) and telemetry helpers in `src/telemetry.ts`. Example entrypoints such as `src/demo.ts` show how agents orchestrate flows. Generated JavaScript lands in `build/` (never hand-edit). Documentation and design notes are under `docs/`, and replay artifacts persist to `storage/` while running crawls or demo scripts. Keep tests adjacent to the code (for example `src/graph/xstate.test.ts`).
5
+
6
+ ## Build, Test, and Development Commands
7
+ - `pnpm install`: sets up dependencies for both the CLI and Playwright runtime.
8
+ - `pnpm typecheck`: runs `tsc --noEmit` against `tsconfig.json` to catch type regressions early.
9
+ - `pnpm build`: compiles `src/` to ESM output in `build/` via SWC; use `pnpm build:debug` when you need source maps.
10
+ - `pnpm test`, `pnpm test:watch`, `pnpm test:ui`: execute the Vitest suite in batch, watch, or UI mode.
11
+ - `pnpm knip`: detects unused files, exports, and dependencies—fix warnings before raising a PR.
12
+
13
+ ## Coding Style & Naming Conventions
14
+ Follow the repository's Biome configuration (`biome.json`) and run `npx biome check .` if needed. Use 2-space indentation, TypeScript `strict` semantics, and ECMAScript modules (`import/export`). Exported symbols and files should read as actions or nouns (`discoverState`, `persist.ts`). Tests mirror the file under test (`xstate.test.ts`). Prefer descriptive async function names reflecting their side effects.
15
+
16
+ ## Testing Guidelines
17
+ Vitest drives all unit and integration coverage. Name suites after the module (`describe("bfs")`) and isolate Playwright-heavy tests behind capability checks to keep CI fast. New behavior must include at least one test validating failure handling and a corresponding happy path. Run `pnpm test` locally before committing; `storage/` fixtures may be stubbed with lightweight mocks to avoid hitting real browsers.
18
+
19
+ ## Commit & Pull Request Guidelines
20
+ Use imperative, conventional messages observed in history (`feat:`, `chore:`, `fix:`). One logical change per commit, referencing an issue ID when relevant. Pull requests should describe motivation, summarize testing (`pnpm test` output, screenshots for Playwright interactions), and link design docs in `docs/` if expanded. Request review from an owner when touching crawl policy or telemetry layers, and ensure CI (typecheck, build, tests) passes before assignment.
21
+
22
+ ## Environment & Configuration Tips
23
+ Configure credentials through `.env` files consumed by Crawlee/Playwright—never hard-code tokens. For telemetry, set OpenTelemetry exporters via environment variables before running demos. Heavy crawls persist checkpoints to `storage/`; clean stale runs before committing to keep diffs focused.
@@ -0,0 +1,53 @@
1
+ # Architecture Pattern Examples
2
+
3
+ This starter kit demonstrates a blend of patterns from **"Designing Data-Intensive Applications"** and **"Patterns of Enterprise Application Architecture"**.
4
+
5
+ ## Order System Example
6
+
7
+ ### From Designing Data-Intensive Applications (DDIA):
8
+
9
+ 1. **Event Sourcing** - All state changes stored as immutable events
10
+ - `order.entity.ts`: Events are the source of truth
11
+ - Events: `OrderCreated`, `ItemAdded`, `OrderPlaced`
12
+
13
+ 2. **CQRS (Command Query Responsibility Segregation)**
14
+ - Commands: `commands.usecase.ts` - Write operations that generate events
15
+ - Queries: `queries.usecase.ts` - Read operations from materialized views
16
+
17
+ 3. **Materialized Views** - Denormalized data for fast queries
18
+ - `order.repository.impl.ts`: `readModel` maintains pre-computed summaries
19
+ - User index for O(1) lookups by user ID
20
+
21
+ 4. **Append-Only Log** - Event store never modifies existing data
22
+ - New events are appended, never updated or deleted
23
+
24
+ ### From Patterns of Enterprise Application Architecture (PEAA):
25
+
26
+ 1. **Repository Pattern** - Abstract data access
27
+ - `order.repository.ts`: Interface defining data operations
28
+ - Separates domain logic from persistence
29
+
30
+ 2. **Domain Model** - Rich business logic in entities
31
+ - `order.entity.ts`: Order entity with business rules and validation
32
+
33
+ 3. **Use Case / Service Layer** - Application logic orchestration
34
+ - Commands and queries as separate use cases
35
+ - Transaction boundaries and workflow management
36
+
37
+ ## API Endpoints
38
+
39
+ ```
40
+ POST /orders # Create new order
41
+ POST /orders/:id/items # Add item to order
42
+ POST /orders/:id/place # Place order
43
+ GET /orders/:id # Get order details
44
+ GET /orders/user/:userId # Get user's orders (fast via materialized view)
45
+ GET /orders/:id/events # Get event stream (audit log)
46
+ ```
47
+
48
+ ## Key Benefits
49
+
50
+ - **Scalability**: Read/write separation allows independent scaling
51
+ - **Auditability**: Complete event history for compliance/debugging
52
+ - **Performance**: Materialized views optimize common queries
53
+ - **Maintainability**: Clean architecture with separated concerns
@@ -0,0 +1,93 @@
1
+ # Order System with Drizzle ORM
2
+
3
+ ## Setup
4
+
5
+ ### 1. Environment Variables
6
+
7
+ Create a `.env` file:
8
+
9
+ ```bash
10
+ # Optional: PostgreSQL connection (if not set, uses in-memory)
11
+ DATABASE_URL=postgres://user:password@localhost:5432/orders_db
12
+
13
+ PORT=3000
14
+ ```
15
+
16
+ ### 2. Database Setup (Optional - for PostgreSQL)
17
+
18
+ If you want to use PostgreSQL instead of in-memory storage:
19
+
20
+ ```bash
21
+ # Generate migration
22
+ pnpm drizzle-kit generate
23
+
24
+ # Run migration
25
+ pnpm drizzle-kit migrate
26
+
27
+ # Or use push for development
28
+ pnpm drizzle-kit push
29
+ ```
30
+
31
+ ### 3. Run the Server
32
+
33
+ ```bash
34
+ # Development
35
+ pnpm dev
36
+
37
+ # Production
38
+ pnpm build
39
+ pnpm start
40
+ ```
41
+
42
+ ## API Endpoints
43
+
44
+ Base URL: `http://localhost:3000/api`
45
+
46
+ ### Create Order
47
+ ```bash
48
+ POST /api/orders
49
+ Content-Type: application/json
50
+
51
+ {
52
+ "userId": "550e8400-e29b-41d4-a716-446655440000"
53
+ }
54
+ ```
55
+
56
+ ### Add Item to Order
57
+ ```bash
58
+ POST /api/orders/:orderId/items
59
+ Content-Type: application/json
60
+
61
+ {
62
+ "productId": "660e8400-e29b-41d4-a716-446655440000",
63
+ "quantity": 2,
64
+ "price": 29.99
65
+ }
66
+ ```
67
+
68
+ ### Place Order
69
+ ```bash
70
+ POST /api/orders/:orderId/place
71
+ ```
72
+
73
+ ### Get Order Details
74
+ ```bash
75
+ GET /api/orders/:orderId
76
+ ```
77
+
78
+ ### Get User's Orders (Fast - from materialized view)
79
+ ```bash
80
+ GET /api/orders/user/:userId
81
+ ```
82
+
83
+ ### Get Order Event Stream (Audit log)
84
+ ```bash
85
+ GET /api/orders/:orderId/events
86
+ ```
87
+
88
+ ## Architecture
89
+
90
+ - **No DATABASE_URL**: Uses in-memory repository (for testing/demo)
91
+ - **With DATABASE_URL**: Uses Drizzle ORM with PostgreSQL
92
+ - Event Sourcing with materialized views for optimal read performance
93
+ - CQRS pattern with separate command and query operations
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["../biome.json"]
3
+ }
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+
3
+ export default defineConfig({
4
+ schema: './src/infrastructure/database/schema.ts',
5
+ out: './drizzle',
6
+ dialect: 'postgresql',
7
+ dbCredentials: {
8
+ url: process.env.DATABASE_URL || 'postgres://localhost:5432/orders_db',
9
+ },
10
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://unpkg.com/knip@5/schema.json",
3
+ "ignoreExportsUsedInFile": {
4
+ "interface": true,
5
+ "type": true
6
+ },
7
+ "tags": [
8
+ "-lintignore"
9
+ ]
10
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "ultimate-express-starter",
3
+ "version": "1.0.0",
4
+ "description": "Fast TypeScript backend starter kit with Ultimate Express, Scalar API docs, and Drizzle ORM.",
5
+ "type": "module",
6
+ "main": "build/index.js",
7
+ "scripts": {
8
+ "start": "node build/index.js",
9
+ "dev": "swc src -d build --strip-leading-paths --copy-files --watch & node --watch build/index.js",
10
+ "typecheck": "npx tsc --noEmit",
11
+ "build": "swc src -d build --strip-leading-paths --copy-files",
12
+ "build:debug": "swc src -d build --strip-leading-paths --copy-files --source-maps",
13
+ "test": "vitest run",
14
+ "test:watch": "vitest",
15
+ "test:ui": "vitest --ui",
16
+ "prebuild": "rm -rf build",
17
+ "knip": "knip",
18
+ "db:generate": "drizzle-kit generate",
19
+ "db:migrate": "drizzle-kit migrate",
20
+ "db:push": "drizzle-kit push",
21
+ "db:studio": "drizzle-kit studio"
22
+ },
23
+ "files": [
24
+ "build"
25
+ ],
26
+ "devDependencies": {
27
+ "@biomejs/biome": "2.0.6",
28
+ "@swc-node/register": "^1.11.1",
29
+ "@swc/cli": "0.7.7",
30
+ "@swc/core": "^1.10.1",
31
+ "@types/bun": "1.2.14",
32
+ "@types/cors": "^2.8.19",
33
+ "@types/node": "24.0.7",
34
+ "@vitest/ui": "^3.2.4",
35
+ "knip": "^5.69.1",
36
+ "tsx": "^4.20.6",
37
+ "typescript": "^5.8.3",
38
+ "vitest": "^4.0.10"
39
+ },
40
+ "dependencies": {
41
+ "@scalar/express-api-reference": "^0.8.25",
42
+ "cors": "^2.8.5",
43
+ "dotenv": "17.0.0",
44
+ "drizzle-kit": "^0.31.7",
45
+ "drizzle-orm": "^0.44.7",
46
+ "lru-cache": "^11.2.2",
47
+ "postgres": "^3.4.7",
48
+ "ultimate-express": "^2.0.12",
49
+ "ultimate-ws": "^2.0.6",
50
+ "zod": "^4.1.12"
51
+ },
52
+ "trustedDependencies": [
53
+ "@swc/core"
54
+ ]
55
+ }
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from "@playwright/test";
2
+ import { config as loadEnv } from "dotenv";
3
+
4
+ // Load environment variables (e.g. PLAYWRIGHT_BASE_URL) before tests spin up.
5
+ loadEnv();
6
+
7
+ export default defineConfig({
8
+ testDir: "src/generated/tests",
9
+ reporter: [
10
+ ["line"],
11
+ ["html", { outputFolder: "playwright-report", open: "never" }],
12
+ ],
13
+ use: {
14
+ baseURL: process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:3000",
15
+ },
16
+ });
@@ -0,0 +1,3 @@
1
+ onlyBuiltDependencies:
2
+ - '@swc/core'
3
+ - esbuild
@@ -0,0 +1,5 @@
1
+ import type { Request, Response } from 'ultimate-express';
2
+
3
+ export const getHealth = (req: Request, res: Response) => {
4
+ res.json({ status: 'ok', timestamp: new Date().toISOString() });
5
+ };
@@ -0,0 +1,6 @@
1
+ import { Router } from 'ultimate-express';
2
+ import { getHealth } from './controller.js';
3
+
4
+ export const healthRouter = Router();
5
+
6
+ healthRouter.get('/', getHealth);
@@ -0,0 +1,13 @@
1
+ import type { Request, Response } from 'ultimate-express';
2
+
3
+ export const getOrders = (req: Request, res: Response) => {
4
+ res.json([
5
+ { id: 1, item: 'Laptop', price: 1200 },
6
+ { id: 2, item: 'Mouse', price: 25 },
7
+ ]);
8
+ };
9
+
10
+ export const createOrder = (req: Request, res: Response) => {
11
+ const { item, price } = req.body;
12
+ res.status(201).json({ id: 3, item, price });
13
+ };
@@ -0,0 +1,7 @@
1
+ import { Router } from 'ultimate-express';
2
+ import { createOrder, getOrders } from './controller.js';
3
+
4
+ export const ordersRouter = Router();
5
+
6
+ ordersRouter.get('/', getOrders);
7
+ ordersRouter.post('/', createOrder);
@@ -0,0 +1,76 @@
1
+ // example backend with ultimate-express
2
+ import 'dotenv/config';
3
+ import express from 'ultimate-express';
4
+ import type { Request, Response } from 'ultimate-express';
5
+ import cors from 'cors';
6
+ import { ordersRouter } from './features/orders/index.js';
7
+ import { healthRouter } from './features/health/index.js';
8
+ import { apiReference } from '@scalar/express-api-reference';
9
+
10
+ const app = express();
11
+
12
+ app.use(cors());
13
+ app.use(express.json());
14
+
15
+ app.get('/', (req: Request, res: Response) => {
16
+ res.send('Hello, Ultimate Express!');
17
+ });
18
+
19
+ // Mount feature routes
20
+ app.use('/api/orders', ordersRouter);
21
+ app.use('/api/health', healthRouter);
22
+
23
+ // API Documentation with Scalar
24
+ app.use(
25
+ '/api/docs',
26
+ apiReference({
27
+ spec: {
28
+ url: '/openapi.json',
29
+ },
30
+ }),
31
+ );
32
+
33
+ // Example OpenAPI spec endpoint
34
+ app.get('/openapi.json', (req: Request, res: Response) => {
35
+ res.json({
36
+ openapi: '3.1.0',
37
+ info: {
38
+ title: 'Ultimate Express API',
39
+ version: '1.0.0',
40
+ description: 'API documentation for Ultimate Express starter kit',
41
+ },
42
+ servers: [
43
+ {
44
+ url: `http://localhost:${process.env.PORT || 3000}`,
45
+ description: 'Development server',
46
+ },
47
+ ],
48
+ paths: {
49
+ '/': {
50
+ get: {
51
+ summary: 'Hello endpoint',
52
+ description: 'Returns a greeting message',
53
+ responses: {
54
+ '200': {
55
+ description: 'Successful response',
56
+ content: {
57
+ 'text/html': {
58
+ schema: {
59
+ type: 'string',
60
+ example: 'Hello, Ultimate Express!',
61
+ },
62
+ },
63
+ },
64
+ },
65
+ },
66
+ },
67
+ },
68
+ },
69
+ });
70
+ });
71
+
72
+ const PORT = process.env.PORT || 3000;
73
+ app.listen(PORT, () => {
74
+ console.log(`Server is running on http://localhost:${PORT}`);
75
+ console.log(`API Documentation available at http://localhost:${PORT}/api/docs`);
76
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": false,
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "sourceMap": true
8
+ },
9
+ "exclude": ["node_modules", "build", "**/*.test.ts", "**/*.spec.ts"]
10
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./build",
4
+ "rootDir": "./",
5
+ "esModuleInterop": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "lib": ["ESNext", "DOM"],
8
+ "target": "ESNext",
9
+ "module": "ESNext",
10
+ "moduleDetection": "force",
11
+ "jsx": "react-jsx",
12
+ "allowJs": true,
13
+
14
+ // Node module resolution
15
+ "moduleResolution": "node",
16
+ "noEmit": true,
17
+
18
+ // Best practices
19
+ "strict": true,
20
+ "skipLibCheck": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+
23
+ // Some stricter flags (disabled by default)
24
+ "noUnusedLocals": false,
25
+ "noUnusedParameters": false,
26
+ "noPropertyAccessFromIndexSignature": false
27
+ },
28
+ "include": ["src/**/*", "scripts/**/*"],
29
+ "exclude": ["node_modules, examples"]
30
+ }
@@ -0,0 +1,24 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['tests/**/*.{test,spec}.{js,ts}', 'src/**/*.{test,spec}.{js,ts}'],
8
+ exclude: ['node_modules', 'build', 'src/generated/tests/**/*'],
9
+ coverage: {
10
+ reporter: ['text', 'json', 'html'],
11
+ exclude: [
12
+ 'node_modules/',
13
+ 'build/',
14
+ 'tests/',
15
+ '*.config.*'
16
+ ]
17
+ }
18
+ },
19
+ resolve: {
20
+ alias: {
21
+ '@': '/src',
22
+ }
23
+ }
24
+ });