2.2 Overall architecture
Deno is a small monolith and runs as a single process. This is the same as other major interpreted runtimes like Node.js, Python, R, etc. All the runtimes run as a single process, with enough multi-threading to take care of CPU intensive operations.
Following is the block diagram that shows the major components that make Deno. This diagram shows all the components that make Deno, including third-party.
There are eight major components in Deno. Five are from the Deno project, while the remaining three are third-party.
Let's take a brief look at all the major components. We'll also go over them in detail in the next few sections.
This is one of the major parts of Deno. Except for the critical third-party components like tokio and v8, a majority of the user facing Deno functionality is implemented in CLI. This also works as the glue between all the other components. CLI is like an orchestrator and an executor. CLI orchestrates executing a TS/JS program with the help of the services from itself and all the other components. CLI is where the Deno process starts from. This is what runs when a Typescript program is executed in Deno.
Every major runtime or programming language comes with a standard library. Deno is no different. The standard library of Deno offers additional functionality, utilities, etc. The standard library is completely written in Typescript. Unlike Node.js, Deno's standard library offers fully async functionality.
This is the last major component that is part of the Deno project but doesn't reside in Deno's primary GitHub repository. Rusty_v8 has its own repository, but it comes under the Deno umbrella. It could be treated as a third-party service.
Rusty_v8 provides high-quality rust bindings to V8's C++ API.
Tokio is a third-party component, but it is a backbone for Deno. Deno wouldn't have been fully async if tokio wasn't there. Tokio is a runtime for writing reliable, asynchronous, and slim applications with the Rust programming language. Deno relies completely on tokio to offer asynchronous functionality.
This is a third-party component, but this is the one that runs the JS code. This is a very important part of Deno and Node.js too. JS programs can't execute if there is no V8 engine.
The typescript compiler is the final major third-party component in Deno (not shown in the diagram above). As mentioned earlier, V8 can only run JS code. Deno supports both TS and JS. Deno needs to convert TS to JS before giving it to V8. This is done by the TS compiler. There are two types of compilers: one provided by microsoft which can do typechecking and transpilation, and the other one is SWC which does only transpilation. Transpilation means converting TS code to JS code.
That was about the overall architecture and a brief on the major components present in Deno. Now, let's see each of the components in detail.