Skip to content

Bijayanee/codesearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeSearch

Fast keyword search engine for code repositories, built in Rust.

Instead of scanning files on every query, CodeSearch builds a persistent inverted index — enabling sub-millisecond lookups on large codebases.


Install

cargo build --release
cp target/release/codesearch ~/.local/bin/

Usage

Build index

codesearch index ./my-project

Search

codesearch search websocket
codesearch search websocket --ext rs
codesearch search socket --partial

Update index (only re-indexes changed files)

codesearch update ./my-project

Stats

codesearch stats

Example output

$ codesearch search websocket

  3 result(s) for 'websocket'

  src/network/server.cpp:45
  src/client/ws.cpp:12
  src/client/ws.cpp:38

Benchmarks

Tested on the Linux kernel source tree (~70k files):

Operation Time
First index build ~1.4s
Subsequent query < 10ms
grep -r (no index) ~8.2s

Project structure

codesearch/
├── src/
│   ├── main.rs         — CLI entry point + command routing
│   ├── config.rs       — paths, constants, extension filters
│   ├── error.rs        — single AppError type
│   ├── tokenizer.rs    — text → tokens
│   ├── index.rs        — inverted index data structure
│   ├── indexer.rs      — file walker + parallel index builder
│   ├── serializer.rs   — binary save/load (bincode)
│   └── searcher.rs     — exact + partial query execution
├── benches/
├── tests/
├── Cargo.toml
└── README.md

Crates used

Crate Purpose
clap CLI argument parsing
walkdir Recursive directory traversal
rayon Parallel file processing
serde Serialization framework
bincode Binary encoding
ignore .gitignore-aware file walking

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages