High-Level Overview
Deno’s architecture separates concerns into distinct layers:- CLI Layer (
cli/) - User-facing interface and high-level integration - Runtime Layer (
runtime/) - JavaScript runtime assembly and worker management - Extensions Layer (
ext/) - Native functionality exposed to JavaScript - Core Libraries (
libs/) - Shared utilities and foundational components
The
deno crate (in cli/) provides the user-visible interface, while deno_runtime (runtime/) assembles the JavaScript runtime with all extensions.Top-Level Directories
cli/ - CLI Implementation
The user-facing CLI implementation, containing:
cli/main.rs- Entry point, delegates tolib.rscli/lib.rs- Main application logic and command routingcli/args/flags.rs- All CLI flags and subcommand definitionscli/module_loader.rs- Module loading and resolution logiccli/file_fetcher.rs- Fetching and caching remote modules
runtime/ - JavaScript Runtime
Assembles the JavaScript runtime and manages execution contexts:
- Workers - JavaScript execution contexts (main worker, web workers)
- Permissions - Runtime permission system for security
- Bootstrap - Runtime initialization and setup
- Ops - Rust functions exposed to JavaScript
ext/ - Extensions
Extensions provide native functionality to JavaScript. Each extension is a separate crate:
lib.rs- Extension definition, ops registration*.rsfiles - Rust implementation of ops*.jsfiles - JavaScript API wrappersCargo.toml- Crate dependencies
libs/ - Core Libraries
Shared libraries and foundational components:
deno_core- Core V8 integration and op systemops- Procedural macros for defining opsserde_v8- Serialization between Rust and V8node_resolver- Node.js module resolution algorithm
tests/ - Test Suite
Comprehensive test coverage:
Spec tests are the primary integration test format. See Testing for details.
tools/ - Development Tools
Scripts and utilities for development:
Key Files
Configuration Files
Cargo.toml- Workspace configuration for all Rust cratesCargo.lock- Locked dependency versionsimport_map.json- Import map for Deno’s own coderust-toolchain.toml- Rust toolchain version.dprint.json- Code formatting configuration.dlint.json- Linting configuration
Documentation
README.md- Project overview and quick startCLAUDE.md- Development guide (this documentation source)Releases.md- Release historyLICENSE.md- MIT license
Architecture Flow
- CLI parses arguments and routes to appropriate tool
- Runtime initializes workers and sets up execution environment
- Extensions provide native APIs to JavaScript
- Core interfaces with V8 and manages the op system
Common Patterns
Ops (Operations)
Rust functions exposed to JavaScript:Extensions
Collections of ops and JS code:Resources
Managed objects passed between Rust and JS (files, sockets, etc.):Finding Your Way
Adding a new CLI command
Adding a new CLI command
- Define flags in
cli/args/flags.rs - Create handler in
cli/tools/<command>.rs - Wire up in
cli/lib.rs - Add spec tests in
tests/specs/<command>/
Adding a new extension
Adding a new extension
- Create directory in
ext/<name>/ - Define ops in Rust
- Create JavaScript wrapper
- Register in
runtime/worker.rs - Add to workspace
Cargo.toml
Modifying an existing op
Modifying an existing op
- Find the op in
ext/<extension>/ - Modify the Rust implementation
- Update JavaScript wrapper if needed
- Update or add tests
Next Steps
Runtime Internals
Learn how the runtime works internally
Extensions
Working with Deno extensions
Testing
Running and writing tests
Debugging
Debugging techniques