Skip to content

Getting started

Build codeweb, analyze a real project, and trace your first call chain.

What codeweb does

codeweb parses a source tree and builds a directed semantic graph. The core chain connects four layers:

Java Method ──InvokesMapper──▶ MappedStatement ──CallsProcedure──▶ Procedure ──DirectCall──▶ Procedure
                                                                    │
                                                                    └──TableAccess──▶ Table
  • SQL layer: procedures, functions, packages, tables, views, triggers, and other DDL objects parsed from openGauss / GaussDB dialect SQL.
  • Mapper layer: MyBatis/iBatis <select> / <update> / <insert> / <delete> statements from XML mapper files.
  • Java layer: methods and classes parsed with tree-sitter, plus SQL embedded in annotations and JDBC calls.
  • JSP layer (default feature jsp): SQL embedded in scriptlets, declarations, and expressions.

The result is queryable in both directions: who calls a procedure, what does a Java method touch, and what breaks when a table changes.

Build from source

codeweb is a single Rust crate. Rust’s latest stable toolchain is required.

git clone https://github.com/c2j/codeweb.git
cd codeweb

# CLI + TUI + JSP + Java extraction (default features)
cargo build --release

# Add the HTTP server and browser UI
cargo build --release --features serve

# Add the MCP server for LLM clients
cargo build --release --features mcp

# Everything at once
cargo build --release --features full

The binary lands in target/release/codeweb. Which subcommands exist depends on the feature set: serve needs the serve feature, mcp needs the mcp feature. See Architecture for the full feature matrix.

Create a project

codeweb init writes a codeweb.toml and a .codeweb/ state directory, registers the source directories to analyze, and immediately runs the first full analysis:

codeweb init my-project \
  -d ./src/main/java \
  -d ./src/main/resources/mapper \
  -d ./sql
  • Without --root, the project is created in the current directory and every -d path is registered for analysis. A -d that points outside the current directory does not move the project there.
  • --root <dir> creates the project in <dir> instead. A non-empty root without an existing codeweb.toml is refused unless you pass --force.

The generated codeweb.toml controls what is analyzed:

[project]
name = "my-project"

[analysis]
paths = ["./src/main/java", "./src/main/resources/mapper", "./sql"]
# exclude = ["**/test/**"]
# discriminator_columns = ["operation_no"]

[analysis.java]
# extra_sql_methods = ["doQuery"]
# extra_sql_var_patterns = ["QUERY"]

Analyze and inspect

Run from the same directory where you ran codeweb init — the project root holding codeweb.toml (or pass -p <dir> from anywhere):

codeweb analyze        # init already ran the first analysis; this refreshes incrementally
codeweb stats          # node/edge counts by type
codeweb files          # analyzed files with node counts
codeweb diff           # what changed since the last analysis

Subsequent codeweb analyze runs only re-parse files whose fingerprint (blake3 hash) changed, so iterations are fast. To force a full re-analysis, delete the .codeweb/fingerprints state.

Trace your first chain

With the repository’s demo sources, run inside the codeweb checkout:

codeweb init demo \
  -d lib/codeweb-complex-demo/sql \
  -d lib/codeweb-complex-demo/xml \
  -d lib/codeweb-complex-demo/java
codeweb analyze
codeweb trace "process_order"
codeweb trace-sql "UPDATE inventory"

trace prints the callers and callees of the matched node as a tree. trace-sql finds MappedStatement and JavaSql nodes by SQL fragment and walks back to the Java methods that reach them.

Pick an interface

SurfaceCommandFeatureWhat you get
CLIcodeweb <command>defaultAll analysis and export commands
TUIcodeweb tuidefaultTerminal explorer with search and node detail
Browser UIcodeweb serveserveCytoscape.js canvas plus a REST API
MCPcodeweb mcpmcp11 JSON-RPC tools for LLM clients

Next steps