Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [Unreleased]

### Added
- **`@kidkender/archmind-express-parser` 0.1.0 (new package): Express.js, JavaScript and TypeScript.** One graph per route: routers mounted across files (`require` / `module.exports`, ES modules, `router.route()` chains, routers mounted from arrays in a `forEach`, registrar functions handed the app); the middleware chain in Express order, classified by npm package, name and — for project middleware — body into `ir:auth_gate`, `ir:authz_check` and `ir:validation_gate` (rate limiting, optional auth and CSRF as `ir:unknown_middleware` with that role; body parsers, logging, CORS left out); the handler through controller modules, class methods and wrappers; service calls, including class controllers with constructor-injected services; transactions (Sequelize, TypeORM, Prisma, Mongoose, Knex) in the handler or one call below, with the writes inside them as `ir:txn_write`; ownership checks from `archmind.json`.
- `analysis`, the CLI and the MCP server detect an Express project (`package.json` depends on `express`, not NestJS; at the root or one directory down when the root is not another backend) after every other framework. The MCP server caches Express graphs and re-parses when a JS/TS file changes; `archmind_get_dependents` indexes Express service calls (`userService` / `userService::createUser`).
- `research/cross-framework`: Express versions of auth-only, auth-authz, auth-validation, auth-service-call and auth-transaction; Express matches NestJS and Laravel on each.
- `research/express-corpus`: the projects, commits, scripts and results the parser was measured with.

### Changed
- `analysis`: a route counts as throttled when a node has role `rate_limiting` (Express rate limiters, Laravel `throttle:`), not only when an auth node is named so; without it every rate-limited login route reported `no_rate_limiting`.

### Measured, with limits
- On six projects read while building it: 163 of 163 route registration sites (regex count). On six it had not seen: 101 of 101 real registrations (the regex also counted three HTTP client calls), every route that opens a transaction in a production Sequelize app (sfbrigade/bats-server), and 9 of 15 security middleware classified correctly blind, 15 of 15 after fixes made on that same set.
- Decorator-based routing (routing-controllers, tsoa) is not read: such a project yields no routes. Not extracted: tenant isolation, side effects, response shaping. Not yet through the LLM accuracy benchmark.

## [0.9.1] - 2026-10-28

### Added
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ArchMind

**Semantic execution graph engine for Laravel, NestJS, Spring Boot, and Go/Gin — built for AI assistants and CI.**
**Semantic execution graph engine for Laravel, NestJS, Spring Boot, Go/Gin and Express — built for AI assistants and CI.**

ArchMind parses your app into a structured execution graph and gives AI assistants (Claude, Cursor, Copilot) the minimal relevant subgraph for a query — achieving comparable or better answer quality at a fraction of the tokens that naive file-dump RAG uses.

Expand Down Expand Up @@ -29,6 +29,8 @@ The difference compounds on large codebases where a single route touches dozens

**Go/Gin support is newer and not yet held to the same bar.** The numbers above are Laravel/NestJS/Spring Boot only, from hand-verified ground truth compared against real LLM calls. Go/Gin has been validated structurally — full-project parsing against 3 real Gin+GORM codebases with zero crashes and spot-checked node accuracy — but not yet run through the same hand-verified accuracy benchmark. Treat it as functional but less battle-tested until that benchmark exists.

**Express support is the newest, measured structurally only.** On six projects it had not seen it found every real route (101 of 101) and every transaction-opening route of a production app, and classified 9 of 15 security middleware correctly before fixes made on that same set (15 of 15 after) — see [`research/express-corpus`](research/express-corpus/README.md). It has not been through the LLM accuracy benchmark either.

---

## MCP Server (Claude Code / AI assistants)
Expand Down Expand Up @@ -226,12 +228,21 @@ DELETE /api/vaults/{id}

A handler that calls one of them (directly, or one hop into a helper method on the same receiver) is treated as authorized by ownership. A handler that acts on a URL `:id` without resolving the caller is still reported — that is the case worth looking at. `ignoreFindings` drops whole finding types (e.g. `["missing_authorization"]`) for a project where the rule does not apply at all.

### Express

- JavaScript and TypeScript; routers mounted across files through `require` / `module.exports` and ES modules, `router.route()` chains, routers mounted from arrays, registrar functions handed the app
- Middleware chain in Express order (global, path-scoped, per-router, per-route, arrays), classified by package, name and — for project middleware — body: passport / express-jwt / custom JWT checks as auth gates, role checks as authorization, celebrate / express-validator / Joi wrappers as validation, rate limiters, CSRF, optional auth; body parsers, logging, CORS and the like left out
- Handlers resolved through controller modules, class methods and wrappers (`catchAsync`); service calls, including class controllers with constructor-injected services
- Transactions (Sequelize, TypeORM, Prisma, Mongoose, Knex) in the handler or one call below, with the writes inside them
- Ownership authorization (as above) and `guards` from `archmind.json`
- Not read: decorator-based routing (routing-controllers, tsoa); tenant isolation and side effects are not extracted. Details: [`packages/express-parser`](packages/express-parser/README.md)

---

## Requirements

- Node.js ≥ 18
- A Laravel (≥8, tested on 10/11/12), NestJS, Spring Boot (Maven or Gradle), or Go/Gin project
- A Laravel (≥8, tested on 10/11/12), NestJS, Spring Boot (Maven or Gradle), Go/Gin, or Express project

## License

Expand Down
1 change: 1 addition & 0 deletions apps/cli/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ await build({
"@kidkender/archmind-laravel-parser",
"@kidkender/archmind-nestjs-parser",
"@kidkender/archmind-go-parser",
"@kidkender/archmind-express-parser",
"@kidkender/archmind-llm-client",
"@kidkender/archmind-orchestrator",
"@kidkender/archmind-protocol",
Expand Down
1 change: 1 addition & 0 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@kidkender/archmind-llm-client": "*",
"@kidkender/archmind-nestjs-parser": "*",
"@kidkender/archmind-go-parser": "*",
"@kidkender/archmind-express-parser": "*",
"@kidkender/archmind-orchestrator": "*",
"@kidkender/archmind-protocol": "*",
"@kidkender/archmind-retrieval": "*",
Expand Down
11 changes: 10 additions & 1 deletion apps/cli/src/utils/parse-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
} from "@kidkender/archmind-laravel-parser"
import { parseNestJSProject } from "@kidkender/archmind-nestjs-parser"
import { parseGinProjectAt, isGinProject, findGoFiles } from "@kidkender/archmind-go-parser"
import { parseExpressProjectAt, isExpressProject, findExpressRoot, findSourceFiles } from "@kidkender/archmind-express-parser"
import type { IntermediateExecutionGraph } from "@kidkender/archmind-protocol"

export type Framework = "laravel" | "nestjs" | "springboot" | "go" | "unknown"
export type Framework = "laravel" | "nestjs" | "springboot" | "go" | "express" | "unknown"

function tryParseSpringBoot(root: string): { graphs: IntermediateExecutionGraph[]; fileCount: number } | null {
try {
Expand Down Expand Up @@ -103,6 +104,8 @@ export function detectFramework(projectRoot: string): Framework {
if (existsSync(join(projectRoot, "artisan"))) return "laravel"
if (existsSync(join(projectRoot, "nest-cli.json"))) return "nestjs"
if (existsSync(join(projectRoot, "pom.xml")) || existsSync(join(projectRoot, "build.gradle"))) return "springboot"
// last: express is a dependency of many Node projects, so every other signal wins
if (isExpressProject(projectRoot)) return "express"

return "unknown"
}
Expand All @@ -126,6 +129,12 @@ export function parseProject(projectRoot: string): ParsedProject {
return { graphs, routeCount: graphs.length, fileCount: findGoFiles(projectRoot).length, projectRoot, framework }
}

if (framework === "express") {
const graphs = parseExpressProjectAt(projectRoot)
const appRoot = findExpressRoot(projectRoot) ?? projectRoot
return { graphs, routeCount: graphs.length, fileCount: findSourceFiles(appRoot).length, projectRoot, framework }
}

// Default: Laravel
const config = loadProjectConfig(projectRoot)
const { aliasMap, routeFiles, routeWrapping, routeNamespaceWrapping, routePrefixWrapping } = resolveAliasMap(projectRoot, config)
Expand Down
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/analysis/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ await build({
"@kidkender/archmind-nestjs-parser",
"@kidkender/archmind-springboot-parser",
"@kidkender/archmind-go-parser",
"@kidkender/archmind-express-parser",
],
minify: false,
})
Expand Down
1 change: 1 addition & 0 deletions packages/analysis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@kidkender/archmind-nestjs-parser": "*",
"@kidkender/archmind-springboot-parser": "*",
"@kidkender/archmind-go-parser": "*",
"@kidkender/archmind-express-parser": "*",
"@kidkender/archmind-protocol": "*"
},
"devDependencies": {
Expand Down
28 changes: 26 additions & 2 deletions packages/analysis/src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ export async function analyzeProject(projectRoot: string): Promise<RouteInfo[]>
const springbootParser = require("@kidkender/archmind-springboot-parser")
// eslint-disable-next-line @typescript-eslint/no-require-imports
const goParser = require("@kidkender/archmind-go-parser")
// eslint-disable-next-line @typescript-eslint/no-require-imports
const expressParser = require("@kidkender/archmind-express-parser")

const isNestJS = existsSync(join(projectRoot, "nest-cli.json"))
const isSpringBoot = !isNestJS && springbootParser.isSpringBootProject(projectRoot)
// go.mod is a strong, cheap-to-check signal unique to Go — checked before
// the PHP/JS/Java branches so a Gin project never falls through to the
// Laravel default below.
const isGin = !isNestJS && !isSpringBoot && goParser.isGinProject(projectRoot)
// Express last before the Laravel default: a package.json depending on
// express (and not NestJS), at the root or one directory down.
const isExpress = !isNestJS && !isSpringBoot && !isGin && expressParser.isExpressProject(projectRoot)

if (isNestJS) {
return analyzeNestJS(projectRoot, nestjsParser, userConfig)
Expand All @@ -35,6 +40,9 @@ export async function analyzeProject(projectRoot: string): Promise<RouteInfo[]>
if (isGin) {
return analyzeGin(projectRoot, goParser, userConfig)
}
if (isExpress) {
return analyzeExpress(projectRoot, expressParser, userConfig)
}
return analyzeLaravel(projectRoot, laravelParser, userConfig)
}

Expand Down Expand Up @@ -120,6 +128,22 @@ function analyzeGin(projectRoot: string, parser: any, userConfig?: ArchMindUserC
return routes
}

function analyzeExpress(projectRoot: string, parser: any, userConfig?: ArchMindUserConfig): RouteInfo[] {
const { parseExpressProjectAt } = parser
const graphs = parseExpressProjectAt(projectRoot) as any[]
const routes: RouteInfo[] = []

for (const graph of graphs) {
const handler = graph.nodes.find((n: any) => n.type === "ir:business_handler")
if (!handler) continue
try {
routes.push(buildRoute(graph, handler, "express", projectRoot, userConfig))
} catch { /* skip */ }
}

return routes
}

function inferPublicRoutes(routes: RouteInfo[]): void {
const someHaveAuth = routes.some(r => r.authGates.length > 0)
if (!someHaveAuth) return
Expand All @@ -138,8 +162,8 @@ function buildRoute(graph: any, handler: any, framework: string, projectRoot?: s
const services = graph.nodes.filter((n: any) => n.type === "ir:service_call").map((n: any) => n.symbol as string)
const hasTxn = graph.nodes.some((n: any) => n.type === "ir:txn_boundary")
const throttled = graph.nodes.some((n: any) =>
(n.type === "ir:auth_gate" || n.type === "ir:authz_check") &&
THROTTLE_RE.test(n.symbol as string)
n.role === "rate_limiting" ||
((n.type === "ir:auth_gate" || n.type === "ir:authz_check") && THROTTLE_RE.test(n.symbol as string))
)

const line = resolveHandlerLine(handler, projectRoot)
Expand Down
Loading