# Getting started

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

---

LLMS index: [llms.txt](/codeweb/llms.txt)

---

## What codeweb does {#what-codeweb-does}

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

```text
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 {#build-from-source}

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

```bash
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](/codeweb/docs/architecture/) for the full feature matrix.

## Create a project {#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:

```bash
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:

```toml
[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 {#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):

```bash
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 {#trace-your-first-chain}

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

```bash
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 {#pick-an-interface}

| Surface | Command | Feature | What you get |
| ------- | ------- | ------- | ------------ |
| CLI | `codeweb <command>` | default | All analysis and export commands |
| TUI | `codeweb tui` | default | Terminal explorer with search and node detail |
| Browser UI | `codeweb serve` | `serve` | Cytoscape.js canvas plus a REST API |
| MCP | `codeweb mcp` | `mcp` | 11 JSON-RPC tools for LLM clients |

## Next steps {#next-steps}

- [CLI reference](/codeweb/docs/cli-reference/) — every command and flag.
- [Graph model](/codeweb/docs/graph-model/) — node types, edge kinds, and naming rules.
- [Trace and query](/codeweb/docs/trace-and-query/) — impact analysis and the JSON query engine.
- [HTTP API](/codeweb/docs/serve/) and [MCP tools](/codeweb/docs/mcp/) — automate codeweb.

---

Backlinks:

- [Documentation](/codeweb/docs/)
- [Releases](/codeweb/release/)
