🚀 AI-free Codebase Explainer - A CLI tool that analyzes repositories and generates comprehensive documentation including architecture overviews, dependency graphs, and onboarding guides.
- 📊 Architecture Overview - Identifies layers, patterns, and tech stack
- 🔗 Dependency Graph - Visualizes module and file dependencies with Mermaid diagrams
- 📚 Onboarding Guide - "Where to start" guide for new developers
⚠️ Risky Files Detection - Identifies god objects and complex files- 🎨 Mermaid Diagrams - Generates visual dependency graphs
- 🔍 AST-based Analysis - Uses ts-morph for accurate TypeScript/JavaScript parsing
- 🚫 No AI Required - Deterministic analysis based on code structure
pnpm add -g code-orientpnpm dlx code-orient ./my-reponpx code-orient ./my-repo# Analyze a repository
code-orient ./path-to-repo
# Specify custom output directory
code-orient ./path-to-repo -o ./docs
# Skip diagram generation (faster)
code-orient ./path-to-repo --no-diagramsUsage: code-orient <repo-path> [options]
Options:
-o, --output <dir> Output directory for generated reports (default: "./code-orient-output")
--no-diagrams Skip generating diagrams
-h, --help Display help for command
-V, --version Display version number
The tool generates the following markdown files in the output directory:
| File | Description |
|---|---|
README.md |
Overview and summary of the analysis |
architecture.md |
Architecture layers, patterns, and tech stack |
dependency-graph.md |
Module and file dependencies with Mermaid diagrams |
onboarding-guide.md |
Step-by-step guide for new developers |
risky-files.md |
Files that may need refactoring |
dependency-graph.mmd |
Mermaid diagram source file (if diagrams enabled) |
- AST Parsing - Uses
ts-morphto parse TypeScript/JavaScript files - Module Detection - Identifies modules based on directory structure
- Dependency Analysis - Tracks imports/exports to build dependency graph
- Complexity Metrics - Calculates cyclomatic complexity and identifies risky files
- Pattern Recognition - Detects common architectural patterns (hooks, services, components)
- Report Generation - Creates markdown reports with diagrams
## 🏗️ Architecture Layers
### Presentation Layer
UI components, views, and user-facing elements
### Service Layer
Business logic, API clients, and external service integrations
### Data Layer
Data models, entities, type definitions, and schemasgraph TD
components --> services
services --> models
hooks --> components
The tool generates a comprehensive guide including:
- Entry points to start reading
- Key modules to understand
- Learning path recommendations
- Code organization patterns
- Things to watch out for
- Node.js 18+
- pnpm 8+
# Clone the repository
git clone <repo-url>
cd code-orient
# Install dependencies
pnpm install
# Build the project
pnpm build
# Run locally
pnpm dev ./path-to-repo
# Or run the built version
pnpm start ./path-to-repocode-orient/
├── src/
│ ├── cli.ts # CLI entry point
│ ├── analyzer.ts # Main codebase analyzer
│ ├── architecture.ts # Architecture pattern detection
│ ├── complexity.ts # Complexity and risk analysis
│ ├── report.ts # Report generator
│ ├── types.ts # TypeScript type definitions
│ └── reports/ # Individual report generators
│ ├── architecture.ts
│ ├── dependency.ts
│ ├── onboarding.ts
│ └── risky-files.ts
├── dist/ # Compiled JavaScript output
└── package.json
- Onboarding New Developers - Quickly understand codebase structure
- Code Reviews - Identify risky files and architectural issues
- Documentation - Generate up-to-date architecture documentation
- Refactoring - Find god objects and complex files that need attention
- Dependency Analysis - Understand module dependencies and relationships
The tool automatically detects:
- TypeScript/JavaScript files (
.ts,.tsx,.js,.jsx) - Entry points (
index.ts,main.ts,app.ts) - Architecture layers (components, services, models, etc.)
- Tech stack (React, Node.js, Express, etc.)
- Common patterns (hooks, services, components)
- Files: All TypeScript and JavaScript files
- Exports: Named and default exports
- Imports: Relative and absolute imports
- Classes: Methods, properties, inheritance
- Functions: Parameters, async/await, exports
- Interfaces & Types: Type definitions
- Complexity: Cyclomatic complexity metrics
Files are flagged as risky if they have:
- High cyclomatic complexity (>50)
- Large file size (>500 lines)
- Too many dependencies (>20 imports)
- Too many exports (>15) - potential god object
- Multiple classes in one file (>5)
- Large classes/functions (>200/100 lines)
- ✅ Deterministic - No AI, just AST parsing and analysis
- ✅ Fast - Analyzes codebases quickly
- ✅ Accurate - Uses proper AST parsing, not regex
- ✅ Developer-focused - Solves real onboarding pain points
- ✅ Visual - Generates diagrams for better understanding
- ✅ Zero Configuration - Works out of the box
- ✅ Privacy-friendly - All analysis happens locally
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
Built with: