Gallery · Architecture explained · Score · TypeScript
SvelteKit architecture: modules, API surface, dependency graph
Web development, streamlined. Generated from sveltejs/kit at cb758b6, MIT.
Scanned packages/kit. Adapters and playgrounds are not included.
- Files
- 205
- Modules
- 11
- API routes
- 0
- Documents
- 17
Node.jsJavaScript
Executive Summary
At a Glance
| Aspect | Summary |
|---|---|
| What | SvelteKit is a well-structured command-line tool |
| Built With | general-purpose + Node.js, JavaScript |
| Scale | 11 modules across 205 files |
| Maturity | Well-structured (2/3 indicators) |
What This System Does
SvelteKit is a general-purpose command-line tool built with Node.js, JavaScript. It operates as a command-line interface, enabling users to interact with the system through terminal commands. This architecture is optimized for automation, scripting, and integration into CI/CD pipelines.
Business Capabilities
The system is organized around 6 functional domains, each representing a distinct business capability:
| Domain | Capability | Scale |
|---|---|---|
| Other | Uncategorized module | 6 modules, 136 files |
| Core Engine | path packages/kit/src/core matches core | 1 modules, 31 files |
| Shared Utilities | path packages/kit/src/utils matches util | 1 modules, 25 files |
| Notifications | path packages/kit/src/messages matches message | 1 modules, 11 files |
| CLI & Commands | path packages/kit/src/cli.js matches cli | 1 modules, 1 files |
| Configuration | path packages/kit/src/constants.js matches constant | 1 modules, 1 files |
Technical Foundation
| Layer | Technologies | Purpose |
|---|---|---|
| Language | Node.js, JavaScript | Primary development language |
| Build | Vite | Compilation and bundling |
| Testing | Vitest | Quality assurance |
Module Composition
The codebase follows a layered architecture with clear separation of concerns:
| Layer | Count | Key Modules | Responsibility |
|---|---|---|---|
| Other Modules | 7 | runtime, messages | General purpose functionality |
| core | 1 | core | Supporting application functionality |
| publisher | 1 | exports | Supporting application functionality |
| Shared Libraries | 1 | utils | Provides shared utilities and abstractions used across modules |
| cli | 1 | cli.js | Supporting application functionality |
Monorepo Structure
This is a pnpm workspaces monorepo containing 45 packages. This structure enables:
- Independent versioning and deployment of packages
- Shared code reuse across internal projects
- Coordinated development with clear ownership boundaries
Key packages:
@sveltejs/kit— packages/kittest-write-types-actions— packages/kit/src/core/sync/write_types/test/actionstest-write-types-app-types— packages/kit/src/core/sync/write_types/test/app-typestest-write-types-layout— packages/kit/src/core/sync/write_types/test/layouttest-write-types-layout-advanced— packages/kit/src/core/sync/write_types/test/layout-advancedtest-write-types-param-type-inference— packages/kit/src/core/sync/write_types/test/param-type-inference
Codebase Health
Overall Health: 🟡 70/100
| Metric | Value | Status |
|---|---|---|
| Internal imports | 607 edges | ✅ Connected |
| External Packages | 14 | ✅ Manageable |
| Circular Dependencies | 4 | 🔴 4 detected |
| Orphan Files | 13 | ⚠️ 13 unused |
Key Insights
- 🔴 Architectural concern — 4 circular dependencies detected. These create tight coupling and make testing difficult.
- ✅ Healthy coupling — Most-imported module (
packages/kit/src/messages/server-errors) serves 27 files without excessive centralization.
Key Data Flows
The system processes information through 5 identified flows:
- client Command Flow (critical) — Import chain starting from
packages/kit/src/runtime/client/client— traces how this entry point depends on 3 downstream modules - vite Request Flow (critical) — Import chain starting from
packages/kit/src/exports/vite— traces how this entry point depends on 1 downstream module - prerender Request Flow (critical) — Import chain starting from
packages/kit/src/core/postbuild/prerender— traces how this entry point depends on 3 downstream modules - analyse Request Flow (critical) — Import chain starting from
packages/kit/src/core/postbuild/analyse— traces how this entry point depends on 2 downstream modules - client Command Flow (critical) — Import chain starting from
packages/kit/src/runtime/app/forms/client— traces how this entry point depends on 3 downstream modules
Strategic Observations
- The codebase follows Core/kernel architecture — `packages/kit/src/core`; high fan-in, CLI tool architecture — `packages/kit/src/cli.js`, Shared utility layer — `packages/kit/src/utils`; high fan-in, ⚠️ 4 circular dependency cycle(s) detected architectural patterns, providing a familiar structure for developers.
- With 6 distinct domains, the system has clear separation of concerns suitable for team-based development.
- As a CLI tool, this system is automation-friendly and can integrate into existing workflows and pipelines.
This executive summary was generated from comprehensive repository analysis including dependency graphs, data flow detection, and architectural pattern recognition. Enable AI enhancement with `GITHUB_TOKEN` for strategic recommendations, risk assessments, and plain-language explanations tailored for non-technical stakeholders.
<!-- repolens:docs-badge -->  · Examples
System Overview
The Big Picture
SvelteKit is a focused codebase with a clear purpose, containing 11 modules spread across 205 files.
| Dimension | Details |
|---|---|
| Total Files | 205 |
| Module Count | 11 |
| Functional Domains | 6 |
| Interface Type | Command-Line Tool |
Technology Stack
The system is built on a modern technology foundation:
| Layer | Technologies | Purpose |
|---|---|---|
| Language | Node.js, JavaScript | Primary development language |
| Build | Vite | Compilation and asset processing |
| Quality | Vitest | Automated testing |
Architecture Patterns
The codebase follows 4 identified architectural patterns:
- Core/kernel architecture — `packages/kit/src/core`; high fan-in — A structured approach to organizing code and managing complexity.
- CLI tool architecture — `packages/kit/src/cli.js` — The system operates as a command-line interface, accepting user input through terminal commands and producing structured output.
- Shared utility layer — `packages/kit/src/utils`; high fan-in — A structured approach to organizing code and managing complexity.
- ⚠️ 4 circular dependency cycle(s) detected — A structured approach to organizing code and managing complexity.
Module Architecture
The system is organized into 5 architectural layers:
| Layer | Modules | Key Examples | Responsibility |
|---|---|---|---|
| Other Modules | 7 | runtime, messages | General purpose functionality |
| core | 1 | core | Supporting application functionality |
| publisher | 1 | exports | Supporting application functionality |
| Shared Libraries | 1 | utils | Provides shared utilities and abstractions used across modules |
| cli | 1 | cli.js | Supporting application functionality |
Layer Details
Other Modules — 7 modules
packages/kit/src/runtime— 105 files — Core application modulepackages/kit/src/messages— 11 files — Core application modulepackages/kit/src/constants.js— 1 files — Core application modulepackages/kit/src/pathname.js— 1 files — Core application module- +3 more modules
core — 1 module
packages/kit/src/core— 31 files — Core application module
publisher — 1 module
packages/kit/src/exports— 27 files — Core application module
Shared Libraries — 1 module
packages/kit/src/utils— 25 files — Utility and helper functions
cli — 1 module
packages/kit/src/cli.js— 1 files — Core application module
Functional Domains
The following domains represent the largest functional areas by file count:
| Rank | Domain | Scale | Business Capability |
|---|---|---|---|
| 1 | Other | 136 files | Uncategorized module |
| 2 | Core Engine | 31 files | path packages/kit/src/core matches core |
| 3 | Shared Utilities | 25 files | path packages/kit/src/utils matches util |
| 4 | Notifications | 11 files | path packages/kit/src/messages matches message |
| 5 | CLI & Commands | 1 files | path packages/kit/src/cli.js matches cli |
| 6 | Configuration | 1 files | path packages/kit/src/constants.js matches constant |
Dependency Graph
Codebase Health: 🟡 70/100
| Metric | Value | Assessment |
|---|---|---|
| Internal Imports | 607 | Modules are connected |
| External Packages | 14 | Lean dependencies |
| Circular Dependencies | 4 | ⚠️ Needs attention |
| Orphan Files | 13 | ⚠️ 13 unused |
Hub modules (most imported):
packages/kit/src/messages/server-errors— imported by 27 filespackages/kit/src/utils/functions— imported by 23 filespackages/kit/src/utils/os— imported by 21 files
Monorepo Structure
This is a pnpm workspaces monorepo containing 45 packages:
| Package | Location | Description |
|---|---|---|
@sveltejs/kit | packages/kit | Package functionality |
test-write-types-actions | packages/kit/src/core/sync/write_types/test/actions | Testing utilities |
test-write-types-app-types | packages/kit/src/core/sync/write_types/test/app-types | Frontend application |
test-write-types-layout | packages/kit/src/core/sync/write_types/test/layout | Testing utilities |
test-write-types-layout-advanced | packages/kit/src/core/sync/write_types/test/layout-advanced | Testing utilities |
test-write-types-param-type-inference | packages/kit/src/core/sync/write_types/test/param-type-inference | Testing utilities |
test-write-types-simple-page-server-and-shared | packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared | Backend/API server |
test-write-types-simple-page-server-only | packages/kit/src/core/sync/write_types/test/simple-page-server-only | Backend/API server |
| +12 more | — | Additional packages |
This system overview was generated from comprehensive repository analysis. Enable AI enhancement with `GITHUB_TOKEN` for narrative context, architectural rationale, technology trade-off analysis, and scalability recommendations.
<!-- repolens:docs-badge -->  · Examples
Business Domains
Overview
SvelteKit is organized into 6 functional domains, each representing a distinct area of business capability. This document maps the technical structure to business-oriented functional areas.
Quick Reference:
| Domain | Modules | Files | Primary Capability |
|---|---|---|---|
| Other | 6 | 136 | Supporting business operations |
| Core Engine | 1 | 31 | Supporting business operations |
| Shared Utilities | 1 | 25 | Cross-cutting utility functions |
| Notifications | 1 | 11 | User notifications and messaging |
| CLI & Commands | 1 | 1 | Supporting business operations |
| Configuration | 1 | 1 | Application configuration |
1. Other
Business Capability
Uncategorized module
This is a major domain with 6 modules and 136 source files.
Key Modules
| Module | Purpose |
|---|---|
packages/kit/src/runtime | Core application module |
packages/kit/src/exports | Core application module |
packages/kit/src/pathname.js | Core application module |
packages/kit/src/runner.js | Core application module |
packages/kit/src/telemetry.js | Core application module |
Business Impact
- Change Frequency Impact: High — Changes here affect 136 files
- Domain Complexity: Complex (multiple modules)
- Recommendation: Ensure comprehensive testing before modifying this domain
2. Core Engine
Business Capability
path packages/kit/src/core matches core
This is a significant domain with 1 module and 31 source files.
Key Modules
| Module | Purpose |
|---|---|
packages/kit/src/core | Core application module |
Business Impact
- Change Frequency Impact: Medium — Changes here affect 31 files
- Domain Complexity: Simple
3. Shared Utilities
Business Capability
path packages/kit/src/utils matches util
This is a significant domain with 1 module and 25 source files.
Key Modules
| Module | Purpose |
|---|---|
packages/kit/src/utils | Utility and helper functions |
Business Impact
- Change Frequency Impact: Medium — Changes here affect 25 files
- Domain Complexity: Simple
4. Notifications
Business Capability
path packages/kit/src/messages matches message
This is a focused domain with 1 module and 11 source files.
Key Modules
| Module | Purpose |
|---|---|
packages/kit/src/messages | Core application module |
Business Impact
- Change Frequency Impact: Low — Changes here affect 11 files
- Domain Complexity: Simple
5. CLI & Commands
Business Capability
path packages/kit/src/cli.js matches cli
This is a focused domain with 1 module and 1 source file.
Key Modules
| Module | Purpose |
|---|---|
packages/kit/src/cli.js | Core application module |
Business Impact
- Change Frequency Impact: Low — Changes here affect 1 file
- Domain Complexity: Simple
6. Configuration
Business Capability
path packages/kit/src/constants.js matches constant
This is a focused domain with 1 module and 1 source file.
Key Modules
| Module | Purpose |
|---|---|
packages/kit/src/constants.js | Core application module |
Business Impact
- Change Frequency Impact: Low — Changes here affect 1 file
- Domain Complexity: Simple
Cross-Domain Dependencies
The following modules serve as shared infrastructure across multiple domains:
| Module | Consumers | Role |
|---|---|---|
packages/kit/src/messages/server-errors | 27 modules | Core application module |
packages/kit/src/utils/functions | 23 modules | Utility and helper functions |
packages/kit/src/utils/os | 21 modules | Utility and helper functions |
Cross-Domain Integration Points
These modules facilitate communication and data sharing between domains:
- `packages/kit/src/messages/server-errors` serves as a central integration point, imported by 27 different modules. Changes to this module have wide-ranging impact and should be carefully coordinated.
- `packages/kit/src/utils/functions` serves as a central integration point, imported by 23 different modules. Changes to this module have wide-ranging impact and should be carefully coordinated.
- `packages/kit/src/utils/os` serves as a central integration point, imported by 21 different modules. Changes to this module have wide-ranging impact and should be carefully coordinated.
Domain Health Summary
| Metric | Value | Assessment |
|---|---|---|
| Total Domains | 6 | Well-balanced |
| Avg Files/Domain | 34 | Appropriate size |
| Largest Domain | Other (136 files) | Consider breaking down |
| Domain Concentration | 66% in largest | ⚠️ High concentration |
Domain mapping is based on directory naming conventions and code organization patterns. Enable AI enhancement with `GITHUB_TOKEN` for business-language descriptions, stakeholder impact analysis, strategic recommendations, and cross-domain relationship narratives.
<!-- repolens:docs-badge -->  · Examples
Architecture Overview
Architectural Philosophy
SvelteKit follows a Core/kernel architecture — `packages/kit/src/core`; high fan-in architecture with elements of CLI tool architecture — `packages/kit/src/cli.js`, Shared utility layer — `packages/kit/src/utils`; high fan-in, ⚠️ 4 circular dependency cycle(s) detected.
Pattern Analysis
Core/kernel architecture — `packages/kit/src/core`; high fan-in
A structured approach to organizing code and managing complexity.
Benefits: Structured organization, maintainability, clarity
CLI tool architecture — `packages/kit/src/cli.js`
The system operates as a command-line interface, accepting user input through terminal commands and producing structured output.
Benefits: Automation-friendly, scriptable, integrates with CI/CD pipelines
Shared utility layer — `packages/kit/src/utils`; high fan-in
A structured approach to organizing code and managing complexity.
Benefits: Structured organization, maintainability, clarity
⚠️ 4 circular dependency cycle(s) detected
A structured approach to organizing code and managing complexity.
Benefits: Structured organization, maintainability, clarity
System Layers
The system is organized into 6 functional layers, each encapsulating a distinct area of responsibility:
| Layer | Responsibility | Scale | Key Insight |
|---|---|---|---|
| Other | Uncategorized module | 136 files | Large domain — consider breaking down |
| Core Engine | path packages/kit/src/core matches core | 31 files | Single large module — evaluate decomposition |
| Shared Utilities | path packages/kit/src/utils matches util | 25 files | Shared infrastructure — high reuse |
| Notifications | path packages/kit/src/messages matches message | 11 files | Standard domain |
| CLI & Commands | path `packages/kit/src/cli | 1 files | Standard domain |
| Configuration | path `packages/kit/src/constants | 1 files | Standard domain |
Module Layers
Modules are classified into 5 architectural roles:
Other Modules
Role: General purpose functionality
| Module | Files | Description |
|---|---|---|
packages/kit/src/runtime | 105 | Core application module |
packages/kit/src/messages | 11 | Core application module |
packages/kit/src/constants.js | 1 | Core application module |
packages/kit/src/pathname.js | 1 | Core application module |
packages/kit/src/runner.js | 1 | Core application module |
| +2 more | — | Additional modules |
core
Role: Supporting application functionality
| Module | Files | Description |
|---|---|---|
packages/kit/src/core | 31 | Core application module |
publisher
Role: Supporting application functionality
| Module | Files | Description |
|---|---|---|
packages/kit/src/exports | 27 | Core application module |
Shared Libraries
Role: Provides shared utilities and abstractions used across modules
| Module | Files | Description |
|---|---|---|
packages/kit/src/utils | 25 | Utility and helper functions |
cli
Role: Supporting application functionality
| Module | Files | Description |
|---|---|---|
packages/kit/src/cli.js | 1 | Core application module |
Technology Foundation
| Layer | Technologies | Architectural Implication |
|---|---|---|
| Language | Node.js, JavaScript | Dynamic typing, flexible but requires discipline |
| Build | Vite | Modern bundling and optimization |
| Quality | Vitest | Enables confident refactoring |
Scale & Complexity Analysis
| Dimension | Value | Assessment |
|---|---|---|
| Total Files | 205 | large project |
| Module Count | 11 | low complexity |
| Domain Spread | 6 domains | Good separation |
| Interface | CLI | Terminal-driven interaction |
Dependency Health
Architecture Health Score: 🟡 70/100
| Metric | Value | Status | Recommendation |
|---|---|---|---|
| Import Edges | 607 | ✅ | Healthy module connectivity |
| External Packages | 14 | ✅ | Lean dependency set |
| Circular Deps | 4 | 🔴 | Refactor to break cycles |
| Orphan Files | 13 | ⚠️ | Review for dead code |
Architectural Strengths
- Balanced coupling — No single module dominates the import graph. This reduces change risk and enables parallel development.
- Testing infrastructure — Automated testing with Vitest supports confident evolution.
Concerns
- Circular dependencies detected — 4 circular dependencies create tight coupling, complicate testing, and hinder refactoring. Priority: High.
Hub modules (most imported):
packages/kit/src/messages/server-errors— imported by 27 filespackages/kit/src/utils/functions— imported by 23 filespackages/kit/src/utils/os— imported by 21 files
Monorepo Architecture
This project uses a pnpm workspaces monorepo with 45 packages.
Package Structure
| Package | Location | Architectural Role |
|---|---|---|
@sveltejs/kit | packages/kit | Package functionality |
test-write-types-actions | packages/kit/src/core/sync/write_types/test/actions | Testing utilities |
test-write-types-app-types | packages/kit/src/core/sync/write_types/test/app-types | Frontend application |
test-write-types-layout | packages/kit/src/core/sync/write_types/test/layout | Testing utilities |
test-write-types-layout-advanced | packages/kit/src/core/sync/write_types/test/layout-advanced | Testing utilities |
test-write-types-param-type-inference | packages/kit/src/core/sync/write_types/test/param-type-inference | Testing utilities |
test-write-types-simple-page-server-and-shared | packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared | Backend/API server |
test-write-types-simple-page-server-only | packages/kit/src/core/sync/write_types/test/simple-page-server-only | Backend/API server |
test-write-types-simple-page-shared-only | packages/kit/src/core/sync/write_types/test/simple-page-shared-only | Utility libraries |
test-write-types-slugs | packages/kit/src/core/sync/write_types/test/slugs | Testing utilities |
| +10 more | — | — |
Monorepo Benefits
- Shared infrastructure — Common tooling and configurations
- Atomic changes — Cross-package updates in single commits
- Independent deployment — Each package can be released separately
- Clear ownership — Package boundaries define team responsibilities
This architecture overview was generated from comprehensive dependency graph analysis and pattern detection. Enable AI enhancement with `GITHUB_TOKEN` for architectural narratives, design rationale explanations, scalability analysis, and refactoring recommendations.
<!-- repolens:docs-badge -->  · Examples
Module Catalog
A complete inventory of all code modules in the repository, organized by location and size. Each module represents a distinct area of responsibility within the codebase.
Total modules: 11
Module Inventory
| Module | Files | Role |
|---|---|---|
packages/kit/src/runtime | 105 | Application module · Orchestrator (coordinates 133 modules) |
packages/kit/src/core | 31 | Core business logic and shared foundations · Critical shared infrastructure (imported by 22 modules) |
packages/kit/src/exports | 27 | Application module · Shared infrastructure (imported by 5 modules) |
packages/kit/src/utils | 25 | Shared utilities and helper functions · Critical shared infrastructure (imported by 159 modules) |
packages/kit/src/messages | 11 | Application module · Critical shared infrastructure (imported by 107 modules) |
packages/kit/src/cli.js | 1 | CLI entry point and commands |
packages/kit/src/constants.js | 1 | Application module |
packages/kit/src/pathname.js | 1 | Application module |
packages/kit/src/runner.js | 1 | Application module |
packages/kit/src/telemetry.js | 1 | Application module |
packages/kit/src/version.js | 1 | Application module |
Module detection is based on the `module_roots` setting in your RepoLens configuration. Adjust this setting to change how modules are grouped.
<!-- repolens:docs-badge -->  · Examples
Route Map
A complete listing of user-facing pages and backend API endpoints. This map shows every URL a user or client can interact with, along with the source file that handles each route.
Route Detection
This project is a CLI tool — it does not expose HTTP routes or serve web pages. This is expected behavior, not a detection failure.
CLI tools interact through terminal commands rather than URLs. See the System Overview or Developer Onboarding documents for command documentation.
<!-- repolens:docs-badge -->  · Examples
API Surface
This page documents both the API endpoints the application exposes and the external services it integrates with. Use it as a reference for understanding the system's interfaces.
Internal API Endpoints
These are the backend services the application provides to handle incoming requests.
No API routes were detected in this scan. If your project uses a routing framework (Express, Fastify, NestJS, etc.), ensure the relevant directories are included in your scan.include patterns.
External API Integrations
Third-party services the application connects to, grouped by category.
No external API integrations were detected. This section populates automatically when RepoLens identifies SDK imports or API client usage in your codebase.
Documented Exports
Exported functions with JSDoc/TSDoc documentation. Documentation coverage: 97%
⚠️ Deprecated Functions
jsoninpackages/kit/src/exports/index.js: useResponse.jsontextinpackages/kit/src/exports/index.js: usenew ResponseinvalidateAllinpackages/kit/src/runtime/client/client.js: Use `refreshAll` instead. UnlikeinvalidateAll,refreshAlldoes not resetpage.state.pushStateinpackages/kit/src/runtime/client/client.js: Usegoto(url, { state, shallow: true })instead.replaceStateinpackages/kit/src/runtime/client/client.js: Usegoto(url, { state, shallow: true, replace: true })instead.
Function Documentation
packages/kit/src/pathname.js
`has_data_suffix()`
Parameters:
pathname(string)
`add_data_suffix()`
Parameters:
pathname(string)
`strip_data_suffix()`
Parameters:
pathname(string)
`has_resolution_suffix()`
Parameters:
pathname(string)
Returns: boolean
`add_resolution_suffix()`
Convert a regular URL to a route to send to SvelteKit's server-side route resolution endpoint
Parameters:
pathname(string)
Returns: string
`strip_resolution_suffix()`
Parameters:
pathname(string)
Returns: string
packages/kit/src/runner.js
`get_runner()`
Parameters:
vite(typeof vite): the vite module that created the serverserver(ViteDevServer)
packages/kit/src/core/adapt/builder.js
`create_builder()`
Creates the Builder which is passed to adapters for building the application.
Returns: Builder
packages/kit/src/core/adapt/index.js
`adapt()`
Parameters:
config(import('types').ValidatedConfig)build_data(import('types').BuildData)server_metadata(import('types').ServerMetadata)prerendered(import('types').Prerendered)prerender_map(import('types').PrerenderMap)app_manifest(typeof import('$app/manifest'))log(import('types').Logger)remotes(import('types').RemoteChunk[])vite_config(import('vite').ResolvedConfig)explicit_env_config(Record<string, import('@sveltejs/kit/env').EnvVarConfig<any>> | null)
packages/kit/src/core/config/index.js
`split_config()`
Splits the config passed to the sveltekit Vite plugin into the options that SvelteKit processes itself and the options that are forwarded to vite-plugin-svelte. SvelteKit makes no assumptions about which options vite-plugin-svelte accepts — it plucks out its own options and passes everything else along (vite-plugin-svelte does its own validation).
Parameters:
config(Config)
Returns: { svelte_config: Config, vite_plugin_svelte_config: Record<string, any> — }
`load_template()`
Loads the template (src/app.html by default) and validates that it has the required content.
Parameters:
cwd(string)config(ValidatedConfig)
`load_error_page()`
Loads the error page (src/error.html by default) if it exists. Falls back to a generic error page content.
Parameters:
config(ValidatedConfig)
`load_vite_config()`
Parameters:
config(string) (optional)vite(typeof import('vite')) (optional)
`extract_svelte_config()`
Parameters:
vite_config(ResolvedConfig)
Returns: ValidatedConfig
`process_config()`
Parameters:
config(ValidatedConfig)cwd(string)
Returns: ValidatedConfig
`validate_config()`
Parameters:
config(Config)
Returns: ValidatedConfig
packages/kit/src/core/config/options.js
`object()`
Parameters:
children(Record<string, Validator>)allow_unknown(boolean) (optional)
Returns: Validator
`validate()`
Parameters:
fallback(any)fn((value: any, keypath: string) => any)
Returns: Validator
packages/kit/src/core/env.js
`resolve_env_entry()`
Parameters:
config(ValidatedConfig)root(string)
Returns: string | null
`load_explicit_env()`
Parameters:
kit(ValidatedConfig)file(string | null)root(string)mode(string)
Returns: Promise<{ variables: Record<string, EnvVarConfig<any>> | null, deps: Set<string> — >}
`create_env_modules()`
Creates the <sveltekit:generated>/env/* modules, keyed by path relative to dir. Every module derives from one pass over variables, so an inlined value is validated once per build.
Parameters:
config(ValidatedConfig)variables(Record<string, EnvVarConfig<any>> | null)env(Record<string, string>)dir(string)entry(string | null)is_dev(boolean)
Returns: Record<string, string>
`create_explicit_env_types()`
Parameters:
variables(Record<string, EnvVarConfig<any>>)relative(string)type(EnvType)
`create_exported_declarations()`
Generates export const declarations (and, for reserved-word names that need aliasing, const + re-export specifiers) for a set of named exports. For regular names, emits a single efficient export const name = expr; statement. For reserved-word names (e.g. delete, class), emits const alias = expr; plus a re-export specifier (alias as name), since reserved words can't be const binding names but CAN appear in export specifiers. You can do evil things like export { c as class }. In order to import/re-export these, you need to alias the binding, then un-alias it when re-exporting: const _0 = ...; // safe binding name export { _0 as class }; // valid — class is allowed in export specifiers Aliases are chosen to avoid collisions with any of the supplied names. The namespace binding (used to hold the imported module) is likewise chosen to avoid collisions.
Parameters:
names(Iterable<string>): — the export namesbuild_expression((name: string, namespace: string) => string): — called for each name to produce the right-hand side of the declaration; receives the chosen namespace binding so it can reference the imported modulenamespace_prefix(string): — the preferred binding name for the namespace (suffixed with a number if it collides with any export name)
Returns: { namespace: string, declarations: string[], reexports: string[] — }
packages/kit/src/core/features.js
`check_feature()`
Parameters:
route_id(string)config(Record<string, any>)feature(string)adapter(import('@sveltejs/kit').Adapter | undefined)
packages/kit/src/core/params.js
`collect_matcher_names()`
Parameters:
routes(import('types').RouteData[])
Returns: Set<string>
`validate_param_matchers()`
Parameters:
params(Record<string, unknown>)names(Set<string>)file(string) (optional)
`load_and_validate_params()`
Returns: Promise<Record<string, ParamMatcher> | null>
packages/kit/src/core/utils.js
`get_global_name()`
The name of the globalThis.__sveltekit_xxx object the app's payload is attached to
Parameters:
version_name(string)dev(boolean)
`get_runtime_base()`
This allows us to import SvelteKit internals that aren't exposed via pkg.exports in a way that works whether @sveltejs/kit is installed inside the project's node_modules or in a workspace root
Parameters:
root(string)
Returns: string
`logger()`
Showing 30 of 629 documented exports.
Documentation Summary:
- Total exports: 650
- Documented: 629
- Undocumented: 21
- Coverage: 97%
HTTP method reference — GET: retrieve data, POST: create, PUT/PATCH: update, DELETE: remove.
<!-- repolens:docs-badge -->  · Examples
Data Flows
Understanding Data Movement
Data flows describe how information moves through SvelteKit — from external inputs through processing layers to storage or presentation. Understanding these flows is essential for debugging, performance optimization, and architectural decisions.
Flow Summary
5 data flows identified in the codebase:
| Flow | Type | Complexity | Critical |
|---|---|---|---|
| client Command Flow | Integration | Medium (4 steps) | 🔴 Yes |
| vite Request Flow | Integration | Low (2 steps) | 🔴 Yes |
| prerender Request Flow | Integration | Medium (4 steps) | 🔴 Yes |
| analyse Request Flow | Integration | Medium (3 steps) | 🔴 Yes |
| client Command Flow | Integration | Medium (4 steps) | 🔴 Yes |
1. client Command Flow 🔴 CRITICAL FLOW
Description
Import chain starting from packages/kit/src/runtime/client/client — traces how this entry point depends on 3 downstream modules
Characteristics
| Property | Value |
|---|---|
| Steps | 4 |
| Modules Involved | 4 |
| Criticality | Critical |
Processing Steps
| Step | Action | Purpose |
|---|---|---|
| 1 | client (entry point, imports 23 modules) | Data acquisition |
| 2 | functions (shared infrastructure, used by 23 files) | Processing step |
| 3 | server-errors (shared infrastructure, used by 27 files) | Processing step |
| 4 | server (shared infrastructure, used by 5 files) | Processing step |
Flow Diagram
┌─ START ─┐
│ `client` (entry point, imports 23 modules) │
│ ↓
│ `functions` (shared infrastructure, used by 23 ... │
│ ↓
│ `server-errors` (shared infrastructure, used by... │
│ ↓
│ `server` (shared infrastructure, used by 5 files) │
└─ END ───┘
Involved Modules
| Module | Role |
|---|---|
client | Core application module |
functions | Utility and helper functions |
server-errors | Core application module |
server | Core application module |
Dependencies
Shared libraries used: packages/kit/src/utils
Insights
- ⚠️ Critical path — Failures here have significant business impact
- 📊 Consider adding monitoring and alerting
- 🧪 Ensure comprehensive test coverage
2. vite Request Flow 🔴 CRITICAL FLOW
Description
Import chain starting from packages/kit/src/exports/vite — traces how this entry point depends on 1 downstream module
Characteristics
| Property | Value |
|---|---|
| Steps | 2 |
| Modules Involved | 2 |
| Criticality | Critical |
Processing Steps
| Step | Action | Purpose |
|---|---|---|
| 1 | vite (entry point, imports 20 modules) | Data acquisition |
| 2 | os (shared infrastructure, used by 21 files) | Processing step |
Flow Diagram
┌─ START ─┐
│ `vite` (entry point, imports 20 modules) │
│ ↓
│ `os` (shared infrastructure, used by 21 files) │
└─ END ───┘
Involved Modules
| Module | Role |
|---|---|
vite | Core application module |
os | Utility and helper functions |
Dependencies
Shared libraries used: packages/kit/src/utils
Insights
- ⚠️ Critical path — Failures here have significant business impact
- 📊 Consider adding monitoring and alerting
- 🧪 Ensure comprehensive test coverage
3. prerender Request Flow 🔴 CRITICAL FLOW
Description
Import chain starting from packages/kit/src/core/postbuild/prerender — traces how this entry point depends on 3 downstream modules
Characteristics
| Property | Value |
|---|---|
| Steps | 4 |
| Modules Involved | 4 |
| Criticality | Critical |
Processing Steps
| Step | Action | Purpose |
|---|---|---|
| 1 | prerender (entry point, imports 18 modules) | Data acquisition |
| 2 | functions (shared infrastructure, used by 23 files) | Processing step |
| 3 | server-errors (shared infrastructure, used by 27 files) | Processing step |
| 4 | server (shared infrastructure, used by 5 files) | Processing step |
Flow Diagram
┌─ START ─┐
│ `prerender` (entry point, imports 18 modules) │
│ ↓
│ `functions` (shared infrastructure, used by 23 ... │
│ ↓
│ `server-errors` (shared infrastructure, used by... │
│ ↓
│ `server` (shared infrastructure, used by 5 files) │
└─ END ───┘
Involved Modules
| Module | Role |
|---|---|
prerender | User interface components |
functions | Utility and helper functions |
server-errors | Core application module |
server | Core application module |
Dependencies
Shared libraries used: packages/kit/src/utils
Insights
- ⚠️ Critical path — Failures here have significant business impact
- 📊 Consider adding monitoring and alerting
- 🧪 Ensure comprehensive test coverage
4. analyse Request Flow 🔴 CRITICAL FLOW
Description
Import chain starting from packages/kit/src/core/postbuild/analyse — traces how this entry point depends on 2 downstream modules
Characteristics
| Property | Value |
|---|---|
| Steps | 3 |
| Modules Involved | 3 |
| Criticality | Critical |
Processing Steps
| Step | Action | Purpose |
|---|---|---|
| 1 | analyse (entry point, imports 11 modules) | Data acquisition |
| 2 | server-errors (shared infrastructure, used by 27 files) | Processing step |
| 3 | server (shared infrastructure, used by 5 files) | Processing step |
Flow Diagram
┌─ START ─┐
│ `analyse` (entry point, imports 11 modules) │
│ ↓
│ `server-errors` (shared infrastructure, used by... │
│ ↓
│ `server` (shared infrastructure, used by 5 files) │
└─ END ───┘
Involved Modules
| Module | Role |
|---|---|
analyse | User interface components |
server-errors | Core application module |
server | Core application module |
Dependencies
Shared libraries used: packages/kit/src/utils
Insights
- ⚠️ Critical path — Failures here have significant business impact
- 📊 Consider adding monitoring and alerting
- 🧪 Ensure comprehensive test coverage
5. client Command Flow 🔴 CRITICAL FLOW
Description
Import chain starting from packages/kit/src/runtime/app/forms/client — traces how this entry point depends on 3 downstream modules
Characteristics
| Property | Value |
|---|---|
| Steps | 4 |
| Modules Involved | 4 |
| Criticality | Critical |
Processing Steps
| Step | Action | Purpose |
|---|---|---|
| 1 | client (entry point, imports 7 modules) | Data acquisition |
| 2 | functions (shared infrastructure, used by 23 files) | Processing step |
| 3 | server-errors (shared infrastructure, used by 27 files) | Processing step |
| 4 | server (shared infrastructure, used by 5 files) | Processing step |
Flow Diagram
┌─ START ─┐
│ `client` (entry point, imports 7 modules) │
│ ↓
│ `functions` (shared infrastructure, used by 23 ... │
│ ↓
│ `server-errors` (shared infrastructure, used by... │
│ ↓
│ `server` (shared infrastructure, used by 5 files) │
└─ END ───┘
Involved Modules
| Module | Role |
|---|---|
client | Core application module |
functions | Utility and helper functions |
server-errors | Core application module |
server | Core application module |
Dependencies
Shared libraries used: packages/kit/src/utils
Insights
- ⚠️ Critical path — Failures here have significant business impact
- 📊 Consider adding monitoring and alerting
- 🧪 Ensure comprehensive test coverage
Import Network
The system has 607 internal import edges connecting 205 source files.
Network Topology
| Metric | Value | Meaning |
|---|---|---|
| Total Edges | 607 | Direct import relationships |
| Hub Count | 3 | Central integration points |
| Avg Connections | ~3 per file | Coupling density |
Key Integration Points
These modules aggregate data from multiple sources:
| Hub | Inbound | Role |
|---|---|---|
server-errors | 27 files | Core application module |
functions | 23 files | Utility and helper functions |
os | 21 files | Utility and helper functions |
Flow detection uses naming conventions, import patterns, and dependency graph analysis. Enable AI enhancement with `GITHUB_TOKEN` for end-to-end flow narratives, failure mode analysis, data transformation descriptions, and performance bottleneck identification.
<!-- repolens:docs-badge -->  · Examples
Architecture Diff
No changes detected.
<!-- repolens:docs-badge -->  · Examples
System Map
What is this? This visual diagram shows how different parts of your codebase connect to each other. Arrows indicate dependencies (which modules use which).
Showing: 11 modules and 24 relationships
Source: Real import analysis
Architecture Diagram
┌─────────────────────────────────────────────────────────────┐
│ 🏗️ SYSTEM ARCHITECTURE MAP │
└─────────────────────────────────────────────────────────────┘
🎯 CLI ENTRY
│
└── cli.js (1 file)
→ core
→ utils
│
⚙️ CORE LOGIC
│
└── core (31 files)
→ utils
→ exports
→ messages
... +3 more
│
🛠️ UTILITIES
│
└── utils (25 files)
→ messages
→ runtime
│
📦 OTHER
│
├── runtime (105 files)
│ → messages
│ → utils
│ → pathname.js
│ ... +2 more
├── exports (27 files)
│ → constants.js
│ → pathname.js
│ → messages
│ ... +5 more
├── messages (11 files)
├── constants.js (1 file)
├── pathname.js (1 file)
├── runner.js (1 file)
│ → messages
├── telemetry.js (1 file)
└── version.js (1 file)
│
Legend:
→ imports / depends on
╌→ tests
Key Connections
Most depended-on modules (highest import count):
| Module | Imported by |
|---|---|
packages/kit/src/utils | 159 modules |
packages/kit/src/messages | 107 modules |
packages/kit/src/core | 22 modules |
packages/kit/src/constants.js | 11 modules |
packages/kit/src/exports | 5 modules |
Most dependent modules (highest dependency count):
| Module | Depends on |
|---|---|
packages/kit/src/runtime | 133 modules |
packages/kit/src/core | 91 modules |
packages/kit/src/exports | 80 modules |
packages/kit/src/utils | 7 modules |
packages/kit/src/cli.js | 5 modules |
<!-- repolens:docs-badge -->  · Examples
Developer Onboarding
Welcome to SvelteKit! 👋
This guide will help you get up to speed quickly. SvelteKit is a general-purpose tools project built with Node.js, JavaScript, containing 11 modules across 205 files.
What You'll Learn
- ✅ Repository structure and organization
- ✅ Technology stack and tools
- ✅ Key modules to understand first
- ✅ How data flows through the system
- ✅ How to start contributing
Quick Reference Card
| Aspect | Details |
|---|---|
| Languages | Node.js, JavaScript |
| Frameworks | general-purpose tools |
| Build Tools | Vite |
| Testing | Vitest |
| Size | 11 modules, 205 files |
| Domains | 6 functional areas |
| Type | Command-line interface |
Repository Structure
Understanding the directory layout is your first step to navigating the codebase:
| Directory | Purpose | Start Here? |
|---|---|---|
packages/kit/src | Project files | ⭐ Yes |
Where to Begin
Focus on these directories first:
- `packages/kit/src` — Project files
Monorepo Navigation
This is a pnpm workspaces monorepo with 45 packages. Here's how to navigate:
| Package | Location | What It Does |
|---|---|---|
@sveltejs/kit | packages/kit | Package functionality |
test-write-types-actions | packages/kit/src/core/sync/write_types/test/actions | Testing utilities |
test-write-types-app-types | packages/kit/src/core/sync/write_types/test/app-types | Frontend application |
test-write-types-layout | packages/kit/src/core/sync/write_types/test/layout | Testing utilities |
test-write-types-layout-advanced | packages/kit/src/core/sync/write_types/test/layout-advanced | Testing utilities |
test-write-types-param-type-inference | packages/kit/src/core/sync/write_types/test/param-type-inference | Testing utilities |
test-write-types-simple-page-server-and-shared | packages/kit/src/core/sync/write_types/test/simple-page-server-and-shared | Backend/API server |
test-write-types-simple-page-server-only | packages/kit/src/core/sync/write_types/test/simple-page-server-only | Backend/API server |
test-write-types-simple-page-shared-only | packages/kit/src/core/sync/write_types/test/simple-page-shared-only | Utility libraries |
test-write-types-slugs | packages/kit/src/core/sync/write_types/test/slugs | Testing utilities |
| +10 more | — | Additional packages |
Pro tip: Each package can typically be developed independently. Check the package's own README.md for specific setup instructions.
Technology Stack
| Layer | Technologies | What to Learn |
|---|---|---|
| Language | Node.js, JavaScript | Dynamic typing — use console.log for runtime inspection |
| Build | Vite | Understand the build pipeline |
| Testing | Vitest | Run existing tests to understand behavior |
Core Modules to Understand
These are the most important modules by size and centrality. Understanding them will unlock the rest of the codebase:
| Priority | Module | Files | Type | Why It Matters |
|---|---|---|---|---|
| ⭐ High | packages/kit/src/runtime | 105 | Other Modules | Large module — core functionality |
| ⭐ High | packages/kit/src/core | 31 | core | Large module — core functionality |
| ⭐ High | packages/kit/src/exports | 27 | publisher | Large module — core functionality |
| Medium | packages/kit/src/utils | 25 | Shared Libraries | Shared code — reused throughout |
| Medium | packages/kit/src/messages | 11 | Other Modules | Key system component |
| Medium | packages/kit/src/cli.js | 1 | cli | Key system component |
| Low | packages/kit/src/constants.js | 1 | Other Modules | Key system component |
| Low | packages/kit/src/pathname.js | 1 | Other Modules | Key system component |
| Low | packages/kit/src/runner.js | 1 | Other Modules | Key system component |
| Low | packages/kit/src/telemetry.js | 1 | Other Modules | Key system component |
Key Integration Points
These modules are imported by many other files. Changes here have wide impact:
- `packages/kit/src/messages/server-errors` — Used by 27 files — Core application module
- `packages/kit/src/utils/functions` — Used by 23 files — Utility and helper functions
- `packages/kit/src/utils/os` — Used by 21 files — Utility and helper functions
⚠️ Caution: Be extra careful when modifying these files. Consider the ripple effects.
How Data Flows
Understanding these flows helps you see how the system processes information end-to-end:
| Flow | Description | Key Modules |
|---|---|---|
| client Command Flow | Import chain starting from `packages/kit/src/runtime/client/... | client, functions |
| vite Request Flow | Import chain starting from packages/kit/src/exports/vite —... | vite, os |
| prerender Request Flow | Import chain starting from `packages/kit/src/core/postbuild/... | prerender, functions |
| analyse Request Flow | Import chain starting from `packages/kit/src/core/postbuild/... | analyse, server-errors |
| client Command Flow | Import chain starting from `packages/kit/src/runtime/app/for... | client, functions |
Debugging tip: When investigating issues, trace the data flow from input to output to identify where problems occur.
Getting Started Checklist
Follow these steps to set up your development environment:
1. Clone and Install
git clone <repository-url>
cd sveltekit
npm install # or yarn, pnpm
2. Explore the Structure
- Review the directory structure above
- Open the
README.mdfor project-specific instructions - Look for
CONTRIBUTING.mdfor contribution guidelines
3. Understand Core Modules
Start with the high-priority modules listed above. Read the code and comments to understand:
- What problem each module solves
- How modules interact with each other
- What data structures are used
4. Run the Tests
npm test # or: npx vitest run
Running tests helps you:
- Verify your setup is correct
- See expected behavior documented in test cases
- Understand module interfaces through test examples
5. Make Your First Change
Start small:
- Find a small bug or typo to fix
- Make the change in a feature branch
- Run tests to ensure nothing breaks
- Submit a pull request for review
Common Pitfalls
New contributors often run into these issues:
- Circular dependencies — This codebase has 4 circular imports. Be careful not to introduce more.
- Monorepo boundaries — Remember to build dependent packages when making changes.
- Environment setup — Check for
.env.examplefiles and ensure you have all required environment variables. - Branch naming — Follow the team's branch naming conventions (usually
feature/,fix/,docs/).
Additional Resources
| Resource | Purpose |
|---|---|
README.md | Project overview and quick start |
CONTRIBUTING.md | Contribution guidelines (if exists) |
CHANGELOG.md | Recent changes and release history |
package.json | Available scripts and dependencies |
Root package.json | Monorepo workspace configuration |
This onboarding guide was generated from comprehensive repository analysis. Enable AI enhancement with `GITHUB_TOKEN` for narrative walkthroughs, common pitfall documentation, debugging tips, architecture deep-dives, and personalized contribution recommendations.
Welcome to the team! Happy coding! 🚀
<!-- repolens:docs-badge -->  · Examples
GraphQL Schema
No GraphQL schema was detected in this repository.
RepoLens scans for .graphql and .gql schema files, inline SDL via tagged template literals (e.g. gql\...\``), resolver patterns, and popular GraphQL libraries including Apollo, Yoga, Nexus, Pothos, Mercurius, type-graphql, Relay, and urql.
If your project uses GraphQL, ensure the relevant source directories are included in your scan.include configuration.
<!-- repolens:docs-badge -->  · Examples
TypeScript Type Graph
No TypeScript type declarations were detected in this repository.
RepoLens analyzes .ts and .tsx files for interface declarations, type aliases, classes, and enums. Ensure your TypeScript source directories are included in the scan.include configuration.
<!-- repolens:docs-badge -->  · Examples
Dependency Graph
205 files · 607 imports · 14 external packages · ⚠️ 4 circular dependency cycle(s) · 13 orphan file(s)
This document maps every import relationship in the codebase, identifies the most-connected modules, and flags circular dependencies that may complicate refactoring or increase build times.
Overview
| Metric | Value |
|---|---|
| Source files | 205 |
| Import edges | 607 |
| External packages | 14 |
| Circular dependencies | 4 |
| Orphan files (no imports or importers) | 13 |
Hub Modules
These are the most-imported modules in the codebase. Changes to hub modules have the widest blast radius and should be reviewed carefully:
| Module | Imported By |
|---|---|
packages/kit/src/messages/server-errors | 27 files |
packages/kit/src/utils/functions | 23 files |
packages/kit/src/utils/os | 21 files |
Circular Dependencies
4 circular dependency chains were detected. Circular imports can cause initialization errors, increase bundle sizes, and make modules harder to test in isolation. Consider refactoring shared logic into a separate module.
packages/kit/src/runtime/server/internal→packages/kit/src/runtime/server/remote-functions→packages/kit/src/runtime/server/errors→packages/kit/src/runtime/server/internalpackages/kit/src/runtime/server/internal→packages/kit/src/runtime/server/remote-functions→packages/kit/src/runtime/server/page/actions→packages/kit/src/runtime/server/utils→packages/kit/src/runtime/server/internalpackages/kit/src/runtime/server/internal→packages/kit/src/runtime/server/remote-functions→packages/kit/src/runtime/server/internalpackages/kit/src/runtime/server/fetch→packages/kit/src/runtime/server/respond→packages/kit/src/runtime/server/fetch
External Dependencies
The codebase imports 14 external packages. These are third-party modules (not the language standard library):
| Package |
| --------- |
$app |
<sveltekit:generated> |
@opentelemetry/api |
@rolldown/pluginutils |
@sveltejs/kit |
cookie |
devalue |
esm-env |
magic-string |
mrmime |
sirv |
svelte |
typescript |
vite |
Generated by RepoLens import analysis. Dependency detection covers JavaScript and TypeScript (ES modules, dynamic import, CommonJS, re-exports; comments, strings, and type-only imports are skipped), Python (`import` / `from ... import`, including relative imports), and Go (`go.mod` module paths). Go `_test.go` files are not part of the graph.*
<!-- repolens:docs-badge -->  · Examples
Architecture Drift
No baseline found. Run
repolens publishonce to establish a baseline.
A baseline snapshot of the current architecture has been saved. On subsequent runs, this report will track structural changes across the following dimensions:
| Dimension | What is Tracked |
|---|---|
| Modules | New, removed, or significantly resized modules |
| API Endpoints | Added or removed backend routes |
| Dependencies | Changes to external package imports |
| Frameworks | Technology stack additions or removals |
| Circular Dependencies | Increases in dependency cycles |
| GraphQL Schema | Type additions or removals |
| Codebase Scale | Overall file count changes |
<!-- repolens:docs-badge -->  · Examples
Security Hotspots
20 security finding(s) · 20 low severity · across 16 file(s)
This report identifies code patterns that are commonly associated with security vulnerabilities. Each finding includes the relevant CWE classification and a recommended remediation.
Severity Overview
| Severity | Count |
|---|---|
| 🔵 Low | 20 |
205 source files scanned · 16 files with findings
ReDoS
Dynamic regex construction from user input can cause ReDoS. Use static regex or input validation.
| File | Line | Pattern | Severity | CWE |
|---|---|---|---|---|
packages/kit/src/core/postbuild/entities.js | 2240 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/core/sync/utils.js | 55 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/exports/vite/plugins/remote.js | 228 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/exports/vite/static_analysis/index.js | 20 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/runtime/server/page/serialize_data.js | 28 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/utils/escape.js | 26 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/utils/filesystem.js | 21 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/utils/routing.js | 42 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
packages/kit/src/utils/routing.js | 290 | Potentially catastrophic regex | 🔵 Low | CWE-1333 |
Prototype Pollution
Deep merge utilities may be vulnerable to prototype pollution if they don't check hasOwnProperty. Verify the implementation.
| File | Line | Pattern | Severity | CWE |
|---|---|---|---|---|
packages/kit/src/exports/node/index.js | 125 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/app/state/client.svelte.js | 25 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/client/client.js | 1491 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/client/client.js | 3537 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/form-utils.js | 873 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/server/errors.js | 58 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/server/errors.js | 94 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/server/data/index.js | 63 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/server/page/index.js | 191 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
packages/kit/src/runtime/server/page/index.js | 224 | Recursive object merge without prototype check | 🔵 Low | CWE-1321 |
Insecure Randomness
Math.random() is not cryptographically secure. Use crypto.randomUUID() or crypto.getRandomValues() for security tokens.
| File | Line | Pattern | Severity | CWE |
|---|---|---|---|---|
packages/kit/src/runtime/client/remote-functions/query-live/instance.svelte.js | 115 | Math.random() for security-sensitive operation | 🔵 Low | CWE-330 |
Affected Files
packages/kit/src/core/postbuild/entities.jspackages/kit/src/core/sync/utils.jspackages/kit/src/exports/node/index.jspackages/kit/src/exports/vite/plugins/remote.jspackages/kit/src/exports/vite/static_analysis/index.jspackages/kit/src/runtime/app/state/client.svelte.jspackages/kit/src/runtime/client/client.jspackages/kit/src/runtime/client/remote-functions/query-live/instance.svelte.jspackages/kit/src/runtime/form-utils.jspackages/kit/src/runtime/server/errors.jspackages/kit/src/runtime/server/data/index.jspackages/kit/src/runtime/server/page/index.jspackages/kit/src/runtime/server/page/serialize_data.jspackages/kit/src/utils/escape.jspackages/kit/src/utils/filesystem.jspackages/kit/src/utils/routing.js
Generated by RepoLens security pattern analysis. Detection is regex-based and may produce false positives. Findings should be triaged by a security-aware engineer.
<!-- repolens:docs-badge -->  · Examples
Code Health Report
205 files analyzed · Average health: 86/100 · 148 A, 22 B, 30 C, 5 D, 0 F
This report synthesizes complexity, coupling, documentation, and security signals into a single health score per module. Lower scores indicate higher risk and maintenance burden.
Overview
| Metric | Value |
|---|---|
| Files analyzed | 205 |
| Average health score | 86/100 |
| Average complexity | 21 |
| Hotspots (score < 60) | 20 |
Grade Distribution
| Grade | Count | Meaning |
|---|---|---|
| 🟢 A (80–100) | 148 | Healthy — low complexity, well-documented |
| 🔵 B (60–79) | 22 | Acceptable — minor improvements possible |
| 🟡 C (40–59) | 30 | Needs attention — elevated complexity or coupling |
| 🟠 D (20–39) | 5 | At risk — multiple quality signals degraded |
| 🔴 F (0–19) | 0 | Critical — immediate refactoring recommended |
Hotspots — Priority Refactoring Targets
These modules have the lowest health scores and should be prioritized for improvement:
| Module | Score | Grade | Complexity | Coupling | Doc% | Security |
|---|---|---|---|---|---|---|
packages/kit/src/runtime/client/client.js | 30 | 🟠 D | 549 | 16↓ 23↑ | 100% | 2 (0 high) |
packages/kit/src/runtime/app/server/remote/form.js | 36 | 🟠 D | 37 | 1↓ 3↑ | 0% | — |
packages/kit/src/core/sync/create_manifest_data/index.js | 37 | 🟠 D | 122 | 6↓ 10↑ | 100% | — |
packages/kit/src/core/env.js | 39 | 🟠 D | 42 | 6↓ 9↑ | 83% | — |
packages/kit/src/runtime/server/page/render.js | 39 | 🟠 D | 101 | 3↓ 17↑ | 100% | — |
packages/kit/src/runtime/server/respond.js | 40 | 🟡 C | 101 | 2↓ 23↑ | 100% | — |
packages/kit/src/runtime/shared.js | 41 | 🟡 C | 52 | 14↓ 3↑ | 100% | — |
packages/kit/src/runtime/server/remote-functions.js | 43 | 🟡 C | 74 | 4↓ 8↑ | 100% | — |
packages/kit/src/core/postbuild/analyse.js | 45 | 🟡 C | 48 | 0↓ 11↑ | — | — |
packages/kit/src/core/postbuild/prerender.js | 45 | 🟡 C | 109 | 0↓ 18↑ | — | — |
packages/kit/src/core/sync/create_manifest_data/sort.js | 45 | 🟡 C | 46 | 1↓ 1↑ | 100% | — |
packages/kit/src/core/sync/write_app_types.js | 45 | 🟡 C | 46 | 1↓ 7↑ | 100% | — |
packages/kit/src/core/sync/write_types/index.js | 45 | 🟡 C | 160 | 1↓ 5↑ | 100% | — |
packages/kit/src/exports/vite/dev/index.js | 45 | 🟡 C | 67 | 1↓ 21↑ | 100% | — |
packages/kit/src/exports/vite/index.js | 45 | 🟡 C | 44 | 0↓ 20↑ | 100% | — |
packages/kit/src/exports/vite/static_analysis/index.js | 45 | 🟡 C | 60 | 2↓ 1↑ | 100% | 1 (0 high) |
packages/kit/src/runtime/app/forms/client.js | 45 | 🟡 C | 50 | 0↓ 7↑ | 100% | — |
packages/kit/src/runtime/app/server/remote/query.js | 45 | 🟡 C | 43 | 2↓ 6↑ | 50% | — |
packages/kit/src/runtime/client/remote-functions/form.svelte.js | 45 | 🟡 C | 102 | 1↓ 5↑ | 100% | — |
packages/kit/src/runtime/form-utils.js | 45 | 🟡 C | 181 | 4↓ 4↑ | 100% | 1 (0 high) |
Most Complex Functions
These functions have the highest cyclomatic complexity and are the most likely sources of bugs:
| Function | File | Line | Complexity |
|---|---|---|---|
internal_respond() | packages/kit/src/runtime/server/respond.js | 93 | 83 |
_start_router() | packages/kit/src/runtime/client/client.js | 3091 | 76 |
push_href() | packages/kit/src/core/postbuild/crawl.js | 45 | 61 |
duplicate_files() | packages/kit/src/core/sync/create_manifest_data/index.js | 290 | 59 |
save() | packages/kit/src/core/postbuild/prerender.js | 542 | 50 |
render_page() | packages/kit/src/runtime/server/page/index.js | 42 | 50 |
navigate() | packages/kit/src/runtime/client/client.js | 1938 | 49 |
resolve() | packages/kit/src/runtime/server/respond.js | 590 | 49 |
load_route() | packages/kit/src/runtime/client/client.js | 1373 | 47 |
statically_analyse_page_options() | packages/kit/src/exports/vite/static_analysis/index.js | 32 | 45 |
read() | packages/kit/src/runtime/form-utils.js | 777 | 44 |
server_fetch() | packages/kit/src/runtime/server/fetch.js | 22 | 41 |
load_server_data() | packages/kit/src/runtime/server/page/load_data.js | 22 | 40 |
split() | packages/kit/src/core/sync/create_manifest_data/sort.js | 32 | 37 |
render_response() | packages/kit/src/runtime/server/page/render.js | 59 | 35 |
All Modules by Health Score
Showing 50 of 205 modules (sorted worst-first)
| Module | Score | Grade | Lines | Complexity | Fan-In | Fan-Out |
|---|---|---|---|---|---|---|
packages/kit/src/runtime/client/client.js | 30 | 🟠 D | 3821 | 549 | 16 | 23 |
packages/kit/src/runtime/app/server/remote/form.js | 36 | 🟠 D | 367 | 37 | 1 | 3 |
packages/kit/src/core/sync/create_manifest_data/index.js | 37 | 🟠 D | 586 | 122 | 6 | 10 |
packages/kit/src/core/env.js | 39 | 🟠 D | 444 | 42 | 6 | 9 |
packages/kit/src/runtime/server/page/render.js | 39 | 🟠 D | 703 | 101 | 3 | 17 |
packages/kit/src/runtime/server/respond.js | 40 | 🟡 C | 863 | 101 | 2 | 23 |
packages/kit/src/runtime/shared.js | 41 | 🟡 C | 366 | 52 | 14 | 3 |
packages/kit/src/runtime/server/remote-functions.js | 43 | 🟡 C | 612 | 74 | 4 | 8 |
packages/kit/src/core/postbuild/analyse.js | 45 | 🟡 C | 285 | 48 | 0 | 11 |
packages/kit/src/core/postbuild/prerender.js | 45 | 🟡 C | 761 | 109 | 0 | 18 |
packages/kit/src/core/sync/create_manifest_data/sort.js | 45 | 🟡 C | 163 | 46 | 1 | 1 |
packages/kit/src/core/sync/write_app_types.js | 45 | 🟡 C | 316 | 46 | 1 | 7 |
packages/kit/src/core/sync/write_types/index.js | 45 | 🟡 C | 879 | 160 | 1 | 5 |
packages/kit/src/exports/vite/dev/index.js | 45 | 🟡 C | 505 | 67 | 1 | 21 |
packages/kit/src/exports/vite/index.js | 45 | 🟡 C | 677 | 44 | 0 | 20 |
packages/kit/src/exports/vite/static_analysis/index.js | 45 | 🟡 C | 306 | 60 | 2 | 1 |
packages/kit/src/runtime/app/forms/client.js | 45 | 🟡 C | 270 | 50 | 0 | 7 |
packages/kit/src/runtime/app/server/remote/query.js | 45 | 🟡 C | 661 | 43 | 2 | 6 |
packages/kit/src/runtime/client/remote-functions/form.svelte.js | 45 | 🟡 C | 831 | 102 | 1 | 5 |
packages/kit/src/runtime/form-utils.js | 45 | 🟡 C | 934 | 181 | 4 | 4 |
packages/kit/src/runtime/server/cookie.js | 45 | 🟡 C | 335 | 53 | 1 | 5 |
packages/kit/src/runtime/server/fetch.js | 45 | 🟡 C | 224 | 40 | 1 | 5 |
packages/kit/src/runtime/server/page/csp.js | 45 | 🟡 C | 386 | 59 | 1 | 3 |
packages/kit/src/runtime/server/page/index.js | 45 | 🟡 C | 377 | 51 | 1 | 17 |
packages/kit/src/runtime/server/page/load_data.js | 45 | 🟡 C | 510 | 94 | 3 | 8 |
packages/kit/src/utils/routing.js | 45 | 🟡 C | 386 | 78 | 11 | 2 |
packages/kit/src/exports/vite/static_analysis/utils.js | 46 | 🟡 C | 119 | 37 | 1 | 0 |
packages/kit/src/runtime/client/remote-functions/query-live/instance.svelte.js | 46 | 🟡 C | 428 | 37 | 1 | 5 |
packages/kit/src/core/config/index.js | 47 | 🟡 C | 211 | 36 | 6 | 5 |
packages/kit/src/exports/vite/dev/generate_manifest.js | 50 | 🟡 C | 310 | 35 | 1 | 4 |
packages/kit/src/runtime/client/remote-functions/shared.svelte.js | 51 | 🟡 C | 299 | 37 | 10 | 3 |
packages/kit/src/core/config/options.js | 52 | 🟡 C | 476 | 53 | 1 | 3 |
packages/kit/src/runtime/client/utils.js | 52 | 🟡 C | 291 | 54 | 4 | 2 |
packages/kit/src/exports/node/index.js | 56 | 🟡 C | 349 | 51 | 2 | 2 |
packages/kit/src/runtime/client/fetcher.js | 58 | 🟡 C | 200 | 33 | 1 | 4 |
packages/kit/src/messages/shared-errors.js | 60 | 🔵 B | 369 | 87 | 15 | 1 |
packages/kit/src/core/adapt/builder.js | 65 | 🔵 B | 427 | 30 | 1 | 13 |
packages/kit/src/core/postbuild/crawl.js | 65 | 🔵 B | 260 | 30 | 1 | 2 |
packages/kit/src/runtime/server/endpoint.js | 67 | 🔵 B | 129 | 28 | 1 | 4 |
packages/kit/src/utils/filesystem.js | 67 | 🔵 B | 161 | 27 | 14 | 2 |
packages/kit/src/utils/url.js | 67 | 🔵 B | 223 | 31 | 12 | 2 |
packages/kit/src/runtime/server/instance.js | 70 | 🔵 B | 162 | 25 | 1 | 7 |
packages/kit/src/exports/index.js | 71 | 🔵 B | 329 | 31 | 0 | 6 |
packages/kit/src/runtime/server/sourcemaps.js | 71 | 🔵 B | 188 | 29 | 2 | 1 |
packages/kit/src/runtime/client/focus.js | 74 | 🔵 B | 95 | 21 | 1 | 1 |
packages/kit/src/core/sync/create_manifest_data/conflict.js | 76 | 🔵 B | 73 | 22 | 1 | 1 |
packages/kit/src/runtime/app/state/client.svelte.js | 76 | 🔵 B | 210 | 19 | 0 | 0 |
packages/kit/src/runtime/client/remote-functions/query/instance.svelte.js | 76 | 🔵 B | 310 | 19 | 1 | 4 |
packages/kit/src/core/sync/write_client_manifest.js | 77 | 🔵 B | 195 | 11 | 1 | 3 |
packages/kit/src/runtime/server/internal.js | 77 | 🔵 B | 100 | 23 | 14 | 5 |
Scoring Methodology
The health score (0–100) is computed from four dimensions:
| Factor | Weight | How It's Measured |
|---|---|---|
| Complexity | –1/pt above 10, –2/pt above 30 | Cyclomatic complexity for JavaScript/TypeScript, Python, and Go (regex, not AST) |
| Function complexity | –2/pt above 8 per function | Highest complexity function in the file |
| Coupling | –1/5 units above 20 | Fan-in × Fan-out (import connections) |
| Documentation | –10 if <50%, –5 if <80% | JSDoc/TSDoc coverage of exports |
| Security | –10/high, –5/medium finding | Security anti-pattern findings in file |
Generated by RepoLens code health analysis. Complexity covers JavaScript/TypeScript, Python, and Go. It is regex-based and may differ from AST-based tools. Scores are relative indicators, not absolute quality measures.
<!-- repolens:docs-badge -->  · Examples