@tryjourney/architecture 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Journey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Journey architecture
2
+
3
+ `@tryjourney/architecture` deterministically scans a repository into a bounded
4
+ architecture graph. It records only derived component, connection, technology,
5
+ and relative-path evidence metadata; it does not include source contents,
6
+ environment values, absolute paths, or file modification times.
7
+
8
+ It is used by `@tryjourney/cli` to observe project architecture while Journey
9
+ MCP is running.
@@ -0,0 +1,37 @@
1
+ export type Component = {
2
+ id: string;
3
+ name: string;
4
+ type: string;
5
+ workspace: string;
6
+ technology: string[];
7
+ evidence: {
8
+ path: string;
9
+ line: number;
10
+ }[];
11
+ confidence: "high" | "medium";
12
+ };
13
+ export type Connection = {
14
+ id: string;
15
+ from: string;
16
+ to: string;
17
+ type: string;
18
+ evidence: {
19
+ path: string;
20
+ line: number;
21
+ }[];
22
+ };
23
+ export type Graph = {
24
+ schema_version: 1;
25
+ components: Component[];
26
+ connections: Connection[];
27
+ coverage: string[];
28
+ };
29
+ export type Change = {
30
+ type: "added" | "removed" | "changed";
31
+ entity: "component" | "connection";
32
+ id: string;
33
+ };
34
+ export declare function scan(root: string, extraExclusions?: string[]): Graph;
35
+ export declare function fingerprint(graph: Graph): string;
36
+ export declare function diff(before: Graph | null, after: Graph): Change[];
37
+ export declare function readExclusions(root: string): string[];
package/dist/index.js ADDED
@@ -0,0 +1,81 @@
1
+ import { createHash } from "node:crypto";
2
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
3
+ import { join, relative, sep } from "node:path";
4
+ const excluded = new Set([".git", ".astro", ".next", "dist", ".venv", "__pycache__", "node_modules", ".wrangler", ".codex", ".claude", "coverage"]);
5
+ const recognized = new Set(["package.json", "pnpm-workspace.yaml", "astro.config.mjs", "next.config.ts", "vite.config.ts", "wrangler.jsonc", "pyproject.toml", "requirements.txt", "alembic.ini", "Dockerfile", "main.py", "server.py", "orm.py", "database.py", "index.ts", "mcp.ts", "api.ts"]);
6
+ function digest(value) { return createHash("sha256").update(value).digest("hex"); }
7
+ function safeRelative(root, path) { return relative(root, path).split(sep).join("/"); }
8
+ export function scan(root, extraExclusions = []) {
9
+ const files = [];
10
+ const omitted = new Set([...excluded, ...extraExclusions]);
11
+ function visit(dir) {
12
+ for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
13
+ if (entry.isSymbolicLink() || omitted.has(entry.name) || entry.name.startsWith(".env") || entry.name.endsWith(".db"))
14
+ continue;
15
+ const path = join(dir, entry.name);
16
+ if (entry.isDirectory())
17
+ visit(path);
18
+ else if (entry.isFile() && recognized.has(entry.name))
19
+ files.push(safeRelative(root, path));
20
+ }
21
+ }
22
+ visit(root);
23
+ const has = (path) => files.includes(path);
24
+ const components = [];
25
+ const add = (id, name, type, workspace, technology, evidence) => {
26
+ const found = evidence.filter(has);
27
+ if (!found.length)
28
+ return;
29
+ components.push({ id, name, type, workspace, technology, evidence: found.map(path => ({ path, line: 1 })), confidence: "high" });
30
+ };
31
+ // Manifests and conventional entry points are evidence. No source text or package values leave the machine.
32
+ add("landing", "Landing site", "web", "apps/landing", ["Astro"], ["apps/landing/astro.config.mjs"]);
33
+ add("web", "Web app", "web", "apps/web", ["Next.js"], ["apps/web/next.config.ts"]);
34
+ add("cli", "CLI and MCP gateway", "cli", "packages/cli", ["Node.js", "MCP"], ["packages/cli/src/index.ts", "packages/cli/src/commands/mcp.ts"]);
35
+ add("api", "API and MCP server", "service", "apps/server", ["Python", "FastAPI", "FastMCP"], ["apps/server/app/main.py", "apps/server/app/mcp/server.py"]);
36
+ add("persistence", "Persistence", "database", "apps/server", ["SQLAlchemy", "Alembic"], ["apps/server/app/db/orm.py", "apps/server/alembic.ini"]);
37
+ add("deployment", "Cloudflare deployment", "deployment", "infra/cloudflare", ["Cloudflare"], ["infra/cloudflare/api/wrangler.jsonc", "apps/web/wrangler.jsonc"]);
38
+ if (!components.length) {
39
+ if (has("astro.config.mjs"))
40
+ add("root:astro", "Astro site", "web", ".", ["Astro"], ["astro.config.mjs"]);
41
+ if (has("next.config.ts"))
42
+ add("root:next", "Next.js app", "web", ".", ["Next.js"], ["next.config.ts"]);
43
+ if (has("app/main.py"))
44
+ add("root:api", "Python API", "service", ".", ["Python", "FastAPI"], ["app/main.py"]);
45
+ if (has("package.json"))
46
+ add("root:package", "Node package", "package", ".", ["Node.js"], ["package.json"]);
47
+ }
48
+ const connections = [];
49
+ const link = (from, to, type, path) => {
50
+ if (components.some(c => c.id === from) && components.some(c => c.id === to) && has(path))
51
+ connections.push({ id: `${from}:${to}:${type}`, from, to, type, evidence: [{ path, line: 1 }] });
52
+ };
53
+ link("cli", "api", "MCP over HTTPS", "packages/cli/src/commands/mcp.ts");
54
+ link("web", "api", "HTTP API", "apps/web/lib/api.ts");
55
+ link("api", "persistence", "SQLAlchemy", "apps/server/app/db/database.py");
56
+ components.sort((a, b) => a.id.localeCompare(b.id));
57
+ connections.sort((a, b) => a.id.localeCompare(b.id));
58
+ return { schema_version: 1, components, connections, coverage: ["Recognized manifests and entry points only; unrecognized runtime relationships may be missing."] };
59
+ }
60
+ function canonical(value) { if (Array.isArray(value))
61
+ return `[${value.map(canonical).join(",")}]`; if (value && typeof value === "object")
62
+ return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`; return JSON.stringify(value); }
63
+ export function fingerprint(graph) { return digest(canonical(graph)); }
64
+ export function diff(before, after) {
65
+ const changes = [];
66
+ for (const entity of ["component", "connection"]) {
67
+ const previous = new Map((before?.[entity === "component" ? "components" : "connections"] ?? []).map(item => [item.id, JSON.stringify(item)]));
68
+ const current = new Map(after[entity === "component" ? "components" : "connections"].map(item => [item.id, JSON.stringify(item)]));
69
+ for (const [id, value] of current)
70
+ if (!previous.has(id) || previous.get(id) !== value)
71
+ changes.push({ type: previous.has(id) ? "changed" : "added", entity, id });
72
+ for (const id of previous.keys())
73
+ if (!current.has(id))
74
+ changes.push({ type: "removed", entity, id });
75
+ }
76
+ return changes.sort((a, b) => `${a.entity}:${a.id}`.localeCompare(`${b.entity}:${b.id}`));
77
+ }
78
+ export function readExclusions(root) {
79
+ const path = join(root, ".journeyignore");
80
+ return existsSync(path) ? readFileSync(path, "utf8").split(/\r?\n/).map(s => s.trim()).filter(s => s && !s.startsWith("#") && !s.includes("/")) : [];
81
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@tryjourney/architecture",
3
+ "version": "0.1.0",
4
+ "description": "Deterministic, privacy-preserving architecture scanning for Journey",
5
+ "keywords": [
6
+ "journey",
7
+ "architecture",
8
+ "scanner"
9
+ ],
10
+ "type": "module",
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/dharunvs/tryjourney.dev.git",
24
+ "directory": "packages/architecture"
25
+ },
26
+ "homepage": "https://tryjourney.dev",
27
+ "bugs": {
28
+ "url": "https://github.com/dharunvs/tryjourney.dev/issues"
29
+ },
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "@types/node": "^24.0.0",
33
+ "tsx": "^4.21.0",
34
+ "typescript": "^5.9.0"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "typecheck": "tsc --noEmit",
39
+ "test": "tsx --test test/*.test.ts"
40
+ }
41
+ }