barkapi 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +177 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,24 @@
1
- # BarkAPI
1
+ <p align="center">
2
+ <img src="https://em-content.zobj.net/source/apple/391/dog-face_1f436.png" width="80" />
3
+ </p>
2
4
 
3
- **Your API's watchdog.** Detects schema drift between your OpenAPI spec and live API responses — before things break in production.
5
+ <h1 align="center">BarkAPI</h1>
6
+
7
+ <p align="center">
8
+ <strong>Your API's watchdog.</strong><br/>
9
+ Detects schema drift between your OpenAPI spec and live API responses — before things break in production.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/barkapi"><img src="https://img.shields.io/npm/v/barkapi" alt="npm version" /></a>
14
+ <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="Node.js >= 18" />
15
+ <img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License" />
16
+ <img src="https://img.shields.io/badge/typescript-strict-blue" alt="TypeScript" />
17
+ </p>
18
+
19
+ ---
20
+
21
+ **BarkAPI** parses your OpenAPI spec, hits your live endpoints, compares response shapes, and reports mismatches — like **ESLint for your API contracts**. Ships with a CLI for your terminal and CI pipelines, plus a real-time web dashboard with schema visualization and drift annotations.
4
22
 
5
23
  ```
6
24
  GET /api/users/:id
@@ -13,6 +31,25 @@ GET /api/orders
13
31
  ✗ 2 breaking ⚠ 1 warning ✓ 8 passing (12 endpoints checked)
14
32
  ```
15
33
 
34
+ ---
35
+
36
+ ## Features
37
+
38
+ - **Zero-config setup** — auto-detects your OpenAPI spec and project type
39
+ - **Recursive schema diffing** — catches type changes, missing fields, nullability shifts, and undocumented additions
40
+ - **Severity classification** — `breaking` / `warning` / `info` so you know what matters
41
+ - **CI-friendly** — exits with code 1 on breaking drift, plug it into any pipeline
42
+ - **Continuous watch mode** — monitor endpoints on an interval
43
+ - **`barkapi dev`** — one command starts watch mode + dashboard, auto-opens browser
44
+ - **Real-time dashboard** — bento grid layout, animated health rings, schema viewer with drift annotations
45
+ - **Schema visualization** — interactive tree rendering of your OpenAPI spec with inline drift markers
46
+ - **Alerting** — configure Slack webhook and email notifications
47
+ - **Spec diffing** — compare two versions of an OpenAPI spec offline
48
+ - **CI generation** — auto-generate GitHub Actions workflows
49
+ - **Embedded SQLite** — no external database to set up or maintain
50
+
51
+ ---
52
+
16
53
  ## Install
17
54
 
18
55
  ```bash
@@ -27,22 +64,25 @@ npm install -g barkapi
27
64
  - Ubuntu/Debian: `sudo apt install build-essential python3`
28
65
  - Windows: install the "Desktop development with C++" workload from Visual Studio Build Tools
29
66
 
67
+ ---
68
+
30
69
  ## Quick Start
31
70
 
32
71
  ```bash
33
- # Navigate to your API project
72
+ # 1. Navigate to your API project
34
73
  cd /path/to/your-api
35
74
 
36
- # Initialize — auto-detects your OpenAPI spec
75
+ # 2. Initialize — auto-detects your OpenAPI spec
37
76
  barkapi init --spec openapi.yaml --base-url http://localhost:3000
38
77
 
39
- # Run a one-time check
40
- barkapi check
41
-
42
- # Start dashboard + watch mode (opens browser automatically)
78
+ # 3. Start dashboard + watch mode (opens browser automatically)
43
79
  barkapi dev
44
80
  ```
45
81
 
82
+ That's it — two commands. The dashboard opens at `http://localhost:3100` and auto-refreshes every 3 seconds.
83
+
84
+ ---
85
+
46
86
  ## Commands
47
87
 
48
88
  ### `barkapi init`
@@ -58,9 +98,11 @@ Options:
58
98
  --name <name> Project name (default: from package.json)
59
99
  ```
60
100
 
101
+ Auto-detects spec files at common paths: `openapi.yaml`, `swagger.json`, `docs/openapi.yml`, etc.
102
+
61
103
  ### `barkapi check`
62
104
 
63
- Parses your spec, calls each endpoint, diffs the response against the expected schema, and prints an ESLint-style report. Exits with code 1 on breaking drift — perfect for CI.
105
+ Parses your spec, calls each endpoint, diffs the response against the expected schema, and prints an ESLint-style report.
64
106
 
65
107
  ```bash
66
108
  barkapi check [options]
@@ -71,6 +113,8 @@ Options:
71
113
  --base-url <url> Override base URL
72
114
  ```
73
115
 
116
+ **Exit code 1** if any breaking drift is detected — perfect for CI gates.
117
+
74
118
  ### `barkapi dev`
75
119
 
76
120
  The all-in-one development command. Starts the web dashboard and watch mode together. Auto-opens your browser.
@@ -99,7 +143,7 @@ Options:
99
143
 
100
144
  ### `barkapi diff`
101
145
 
102
- Compares two OpenAPI spec versions and shows schema differences.
146
+ Compares two OpenAPI spec versions and shows schema differences between them.
103
147
 
104
148
  ```bash
105
149
  barkapi diff <old-spec> <new-spec> [options]
@@ -132,6 +176,8 @@ Options:
132
176
  --config <path> Path to .barkapi.yml
133
177
  ```
134
178
 
179
+ ---
180
+
135
181
  ## Configuration
136
182
 
137
183
  BarkAPI uses a `.barkapi.yml` file in your project root:
@@ -146,7 +192,7 @@ auth:
146
192
  type: bearer # bearer | header | query
147
193
  token_env: API_TOKEN # reads from environment variable
148
194
 
149
- # Optional: path parameters
195
+ # Optional: path parameters for parameterized endpoints
150
196
  path_params:
151
197
  id: "1"
152
198
 
@@ -159,42 +205,146 @@ endpoints:
159
205
  - /api/internal
160
206
  ```
161
207
 
162
- ## Dashboard
208
+ ### Auth Types
163
209
 
164
- The `barkapi dev` command launches a web dashboard at `http://localhost:3100` with:
210
+ | Type | Description | Config |
211
+ |------|------------|--------|
212
+ | `bearer` | `Authorization: Bearer <token>` header | `token_env`: env var name |
213
+ | `header` | Custom header | `token_env` + `header_name` |
214
+ | `query` | Query parameter | `token_env` + `query_param` |
165
215
 
166
- - **Bento grid layout** — health ring, stat cards, drift distribution at a glance
167
- - **Schema viewer** — interactive tree of your OpenAPI schema with drift annotations inline
168
- - **Endpoint health map** — color-coded grid showing status of every endpoint
169
- - **Drift history** — grouped by field path with side-by-side expected vs actual diffs
170
- - **Timeline charts** — area charts showing drift trends over time
171
- - **Breadcrumb navigation** — always know where you are
172
- - **Alerting** — Slack webhook and email notifications
173
- - **Real-time updates** — auto-refreshes every 3s, no manual refresh needed
216
+ ---
174
217
 
175
218
  ## Drift Detection
176
219
 
220
+ The diff engine performs recursive structural comparison between your OpenAPI spec schemas and actual API response shapes.
221
+
177
222
  | Drift Type | Severity | What it means |
178
223
  |------------|----------|---------------|
179
- | Removed required field | `breaking` | A required field is gone |
180
- | Removed optional field | `warning` | An optional field disappeared |
224
+ | Removed required field | `breaking` | A field your consumers depend on is gone |
225
+ | Removed optional field | `warning` | A field disappeared but wasn't required |
181
226
  | Type changed | `breaking` | Field type shifted (e.g. `string` → `number`) |
182
227
  | Nullable → non-null | `breaking` | Consumers handling null will break |
183
228
  | Non-null → nullable | `warning` | Field can now be null |
184
229
  | Required changed | `breaking` | Required/optional status changed |
185
230
  | Enum changed | `warning` | Allowed enum values differ |
186
- | Format changed | `warning` | Field format differs |
231
+ | Format changed | `warning` | Field format differs (e.g. `date-time` missing) |
187
232
  | Undocumented field added | `info` | Response has a field not in the spec |
188
233
 
234
+ ---
235
+
236
+ ## Dashboard
237
+
238
+ The `barkapi dev` command launches a web dashboard at `http://localhost:3100` with:
239
+
240
+ - **Bento grid layout** — health ring, stat cards, drift distribution at a glance
241
+ - **Schema viewer** — interactive tree of your OpenAPI schema with drift annotations inline
242
+ - **Endpoint health map** — color-coded grid showing status of every endpoint
243
+ - **Drift history** — grouped by field path with side-by-side expected vs actual diffs
244
+ - **Timeline charts** — area charts showing drift trends over time
245
+ - **Breadcrumb navigation** — always know where you are: `Projects > My API > GET /users/{id}`
246
+ - **Alerting** — configure Slack webhook and email notifications
247
+ - **Real-time updates** — auto-refreshes every 3s via shared SQLite database
248
+
249
+ ### Dashboard Pages
250
+
251
+ | Page | Route | Description |
252
+ |------|-------|-------------|
253
+ | **Projects** | `/` | Overview cards with health donut, labeled status dots, drift count |
254
+ | **Project Detail** | `/projects/:id` | Bento grid with health ring, passing/breaking/warning stats, drift type distribution, endpoint health map |
255
+ | **Endpoint Detail** | `/projects/:id/endpoints/:eid` | Three tabs — **Overview** (stats), **Schema** (annotated tree), **History** (drift list grouped by field) |
256
+ | **Timeline** | `/projects/:id/timeline` | Area/line/bar charts + check run cards with mini health rings |
257
+ | **Alerts** | `/projects/:id/alerts` | Configure Slack and email notifications with severity filters |
258
+
259
+ ---
260
+
261
+ ## Example Project
262
+
263
+ The [`examples/`](https://github.com/mruduljohn/BarkAPI/tree/main/examples) directory contains a complete demo with intentional drift:
264
+
265
+ ```bash
266
+ # 1. Start the example API server (has intentional drift from spec)
267
+ cd examples
268
+ node server.js
269
+
270
+ # 2. In another terminal, run BarkAPI against it
271
+ cd examples
272
+ barkapi init --spec openapi.yaml --base-url http://localhost:4000
273
+ barkapi dev
274
+ ```
275
+
276
+ The example server returns responses that intentionally differ from its OpenAPI spec:
277
+ - `GET /api/users/:id` — `email` is a number (spec says string), missing `created_at`, extra `avatar` field
278
+ - `GET /api/products/:id` — `price` is a string (spec says number)
279
+
280
+ ---
281
+
189
282
  ## CI Integration
190
283
 
284
+ ### GitHub Actions
285
+
191
286
  ```yaml
192
- # GitHub Actions
193
287
  - name: Check API contracts
194
- run: npx barkapi check --spec openapi.yaml --base-url ${{ vars.STAGING_URL }}
288
+ run: |
289
+ npx barkapi check --spec openapi.yaml --base-url ${{ vars.STAGING_URL }}
290
+ ```
291
+
292
+ Or generate a workflow file automatically:
293
+
294
+ ```bash
295
+ barkapi ci-gen --base-url-var vars.STAGING_URL
296
+ ```
297
+
298
+ The `check` command exits with code 1 on breaking drift, failing your pipeline automatically.
299
+
300
+ ---
301
+
302
+ ## Architecture
303
+
304
+ ```
305
+ BarkAPI/
306
+ ├── packages/
307
+ │ ├── core/ @barkapi/core — shared engine
308
+ │ │ └── src/
309
+ │ │ ├── parser/ OpenAPI parser + response schema inferrer
310
+ │ │ ├── diff/ Recursive schema differ + severity classifier
311
+ │ │ ├── db/ SQLite connection, schema migration, queries
312
+ │ │ └── models/ CRUD for projects, endpoints, check runs, drifts, alerts
313
+ │ ├── cli/ barkapi — the npm package
314
+ │ │ └── src/
315
+ │ │ ├── commands/ init, check, watch, report, dev, diff, ci-gen
316
+ │ │ ├── config/ .barkapi.yml loader + project detector
317
+ │ │ ├── runner/ HTTP endpoint caller + check orchestrator
318
+ │ │ └── output/ ESLint-style chalk formatter
319
+ │ └── dashboard/ @barkapi/dashboard — Next.js web UI
320
+ │ └── app/
321
+ │ ├── api/ REST API routes (projects, endpoints, stats, schema, SSE)
322
+ │ ├── components/ UI primitives, schema viewer, health ring, breadcrumbs
323
+ │ ├── hooks/ usePolling, useSSE (real-time data fetching)
324
+ │ └── projects/ Project pages (health map, detail, timeline, alerts)
325
+ ├── examples/ Demo project with intentional drift
326
+ │ ├── openapi.yaml Sample OpenAPI spec
327
+ │ ├── server.js API server with mismatched responses
328
+ │ └── .barkapi.yml Pre-configured BarkAPI config
195
329
  ```
196
330
 
197
- Or generate a workflow automatically: `barkapi ci-gen`
331
+ ### Tech Stack
332
+
333
+ | Layer | Technology |
334
+ |-------|-----------|
335
+ | Language | TypeScript (strict) |
336
+ | CLI framework | Commander.js |
337
+ | Terminal UI | chalk + ora |
338
+ | API parsing | @apidevtools/swagger-parser |
339
+ | Database | SQLite via better-sqlite3 (WAL mode) |
340
+ | Web framework | Next.js 14 (App Router) |
341
+ | Styling | Tailwind CSS (dark mode) |
342
+ | Animations | Framer Motion |
343
+ | Charts | Recharts |
344
+ | Icons | Lucide React |
345
+ | Monorepo | npm workspaces |
346
+
347
+ ---
198
348
 
199
349
  ## License
200
350
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barkapi",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "API Contract Drift Detector — Your API's watchdog",
5
5
  "keywords": [
6
6
  "api",