Skip to main content
In this lesson we demonstrate how to audit a small Express (Node.js) project for software design, modularity, and architectural issues using Claude Code. The aim is a structured findings report with concrete, code-level remediation you can apply incrementally.
In this lesson we perform an automated software-quality audit using Claude Code. If you’ve participated in enterprise code reviews, you already know reviewers check architecture, design patterns, error handling, and operational practices. Claude Code automates that process at scale and produces actionable remediation tied to code locations. Example interactive session that starts Claude Code in the project folder:
The lesson uses a curated set of review prompts (instead of typing one-off prompts). The prompt set used for this lesson is available in the repo:
A dark‑theme screenshot of a GitHub repository page for "Claude-Code-Reviewing-Prompts" showing a list of markdown files (e.g., authentication-flow-review.md, database-security.md) and an About/sidebar panel on the right.
How the review is scoped (condensed prompt used for the audit):
While running, Claude Code inspects the repository: listing directories, reading key files, and searching for code patterns. Example actions (condensed):
Claude then wrote a structured audit to audits/SOFTWARE_DESIGN_ARCHITECTURE_ANALYSIS.md. The cleaned and consolidated version of that report follows. Project: Express Login Demo

Executive summary

Overall Architecture Score: 4/10 This Express Login Demo exhibits a minimal MVC-inspired structure but contains significant design and operational shortcomings. Business logic is embedded in route handlers, there’s limited abstraction, and the app lacks centralized error handling and input validation. These problems raise technical debt and make the code harder to test, secure, and scale.

Architecture analysis

1. Architectural pattern assessment

Pattern identified: Minimal MVC-like structure
  • Model: PostgreSQL integration via config/database.js
  • View: JSON API responses
  • Controller: Route handlers in routes/auth.js
Separation of concerns: 3/10
  • Business logic and data access are mixed into route handlers.
  • No service or repository layer is present.
  • DB config is separated (positive).

2. Project structure

Modularity: 3/10 — flat structure with most logic in routes/auth.js. No migrations, no distinct repositories or service abstractions.

3. Data flow (high-level)

  • HTTP request → routes/auth.js (validation, DB queries, auth logic) → config/database.js → PostgreSQL
  • Missing: service layer, caching, rate limiting, centralized logging, and centralized error handling
Potential bottlenecks:
  1. Single DB pool without explicit connection limits
  2. Blocking synchronous crypto (if used) can stall the Node event loop
  3. No caching — every request hits the database
  4. No rate limiting — auth endpoints exposed to brute-force attempts

Anti-patterns identified

  1. God object / God module (Severity: 8/10)
    • Location: routes/auth.js
    • Symptom: One file handles routing, validation, business logic, and DB access.
    • Impact: Hard to test and maintain.
  2. Primitive obsession (Severity: 6/10)
    • Location: routes/auth.js — raw SQL and primitive payload handling.
    • Example:
    • Remediation: Introduce repositories/models and token services.
  3. Copy-paste programming (Severity: 5/10)
    • Location: routes/auth.js
    • Symptom: Repeated error response patterns and duplicated logic.
    • Remediation: Centralize error responses with middleware.
  4. Tight coupling (Severity: 7/10)
    • Location: Route handlers require DB, bcrypt, and jwt directly.
    • Symptom: Hard to unit test and mock dependencies.
    • Remediation: Use dependency injection via factories.
  5. Missing input validation/sanitization (Severity: 6/10)
    • Location: routes/auth.js
    • Symptom: No robust validation (consider express-validator).
    • Remediation: Add validation middleware.

Detailed findings

High priority issues

Medium priority issues

Low priority issues


Layered architecture (conceptual)

Proposed directory structure

Dependency flow (text diagram)


Concrete remediations (drop-in examples)

Below are small, focused code patterns to reduce coupling, improve testability, and add defenses.
  • Auth service (move business logic out of routes):
  • Repository abstraction for data access:
  • Use a factory to wire routes with injected services:
  • Input validation middleware using express-validator:
  • Centralized error handler:
  • Token service:

Security & operational recommendations

  • Sanitize and validate all inputs (e.g., express-validator).
  • Always use parameterized queries (prepared statements) to prevent SQL injection.
  • Run CPU-bound crypto (bcrypt) using async APIs; consider background workers for heavy tasks.
  • Protect auth endpoints with rate limiting (express-rate-limit).
  • Implement structured logging (pino or winston) and attach correlation IDs to requests.
  • Add health and readiness endpoints for orchestration tooling.
  • Implement graceful shutdown to drain DB/pool connections on SIGTERM/SIGINT.

Final assessment and next steps

  • Current state: Functional but with high architectural debt.
  • Technical debt: High — refactoring required for scale and maintainability.
  • Immediate actions:
    1. Extract services and repositories from route handlers.
    2. Add global error handling middleware and an AppError pattern.
    3. Add input validation and sanitization.
    4. Introduce DI/factory functions to decouple dependencies.
    5. Implement structured logging and basic operational endpoints.
  • Long-term:
    1. Migrate to a layered architecture with clear responsibilities.
    2. Add automated tests (unit + integration).
    3. Add configuration management and environment-driven settings.
    4. Integrate observability: metrics & tracing.
This analysis delivers a prioritized set of findings and concrete code examples that you can apply incrementally. Subsequent lessons will expand this with more detailed design principles and a targeted security audit.

Watch Video