basic-astro — Code View¶
← Back to Container | ← Back to System
Component Information¶
| Field | Value |
|---|---|
| Component | basic-astro |
| Container | Application |
| Type | module |
| Description | Astro component extractor |
| --- |
Code Structure¶
Class Diagram¶

Code Elements¶
25 code element(s)
#### Functions ##### `basicAstroExtractor()` Extract architecture information from an Astro codebase | Field | Value | | --- | --- | | **Type** | `function` | | **Visibility** | `public` | | **Async** | Yes || **Returns** | `Promiseany — - Configuration node with include/exclude patterns- `ctx`: import("C:/Users/chris/git/archlette/src/core/types").PipelineContext — - Pipeline context with logger and config
**Examples:**
---
##### `extractCodeFromFrontmatter()`
Extract TypeScript/JavaScript code from Astro frontmatter
Parses the frontmatter section (code between --- markers) as TypeScript
and extracts code elements using the basic-node AST extractors:
- Classes and their methods
- Functions (both regular and arrow functions)
- Type aliases (type X = ...)
- TypeScript interfaces
Returns empty result if frontmatter is empty or parsing fails (errors are logged).
Graceful error handling ensures one malformed Astro file doesn't break the extraction pipeline.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/code-extractor").CodeExtractionResult` - CodeExtractionResult with extracted classes, functions, types, and interfaces || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/code-extractor.ts:61` |
**Parameters:**
- `frontmatter`: string — - The frontmatter code (TypeScript/JavaScript between --- markers)- `filePath`: string — - Original Astro file path (used for error reporting and virtual TS path)
**Examples:**
---
##### `createSyntheticRenderFunction()`
Create a synthetic render function for an Astro component
Every Astro component is fundamentally a server-side render function that:
1. Receives props (if Props interface is defined)
2. Processes the component logic (frontmatter code)
3. Renders the template to HTML
4. Returns an HTML string
Since Astro's compiler doesn't explicitly define this, we create a synthetic function
to represent the component's executable behavior in the IR.
The function is named after the file (without .astro extension):
- Button.astro → function Button()
- index.astro → function index()
- settings/Profile.astro → function Profile()
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-node/types").ExtractedFunction` - Synthetic ExtractedFunction representing the component's render behavior || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/code-extractor.ts:153` |
**Parameters:**
- `filePath`: string — - Absolute path to the Astro file- `interfaces`: import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-node/types").ExtractedInterface[] — - Extracted interfaces from frontmatter (used to detect Props interface)
**Examples:**
---
##### `extractJSDocBlocks()`
Extract all JSDoc comment blocks from source code
Matches /** ... *\/ style comments and parses their tags
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `JSDocBlock[]` || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:27` |
**Parameters:**
- `source`: string
---
##### `parseJSDocBlock()`
Parse a single JSDoc comment block into description and tags
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `JSDocBlock` || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:49` |
**Parameters:**
- `comment`: string
---
##### `extractFileComponent()`
Extract component information from frontmatter JSDoc
Attempts to identify the component in this file using JSDoc tags:
1. Checks for
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").ComponentInfo` - ComponentInfo with id, name, and optional description, or undefined || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:118` |
**Parameters:**
- `frontmatter`: string — - TypeScript/JavaScript code from frontmatter section- `filePath`: string — - Absolute path to the Astro file (used for inference)
**Examples:**
---
##### `extractComponentName()`
Extract component name from a JSDoc tag value
Parses the tag value to extract the component name, handling various formats:
- Simple name: ComponentName
- With description: ComponentName - Description
- Module path: path/to/module (extracts last directory component)
- Dashes preserved: My-Component-Name
For module paths like "utils/helpers", extracts "utils" (the last directory
before the filename) to enable component grouping.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `string` - Extracted component name, or undefined if value is empty || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:191` |
**Parameters:**
- `value`: string — - The JSDoc tag value (text after
**Examples:**
---
##### `extractFileActors()`
Extract actors from frontmatter JSDoc
Identifies external actors (users, systems) that interact with the component.
Actors are specified using
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").ActorInfo[]` - Array of identified actors, or empty array if none found || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:250` |
**Parameters:**
- `frontmatter`: string — - TypeScript/JavaScript code from frontmatter
**Examples:**
---
##### `parseActorTag()`
Parse an
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").ActorInfo` || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:277` |
**Parameters:**
- `value`: string
---
##### `extractFileRelationships()`
Extract relationships from frontmatter JSDoc
Identifies component dependencies using
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").RelationshipInfo[]` - Array of identified relationships, or empty array if none found || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:333` |
**Parameters:**
- `frontmatter`: string — - TypeScript/JavaScript code from frontmatter
**Examples:**
---
##### `parseUsesTag()`
Parse a
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").RelationshipInfo` || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:357` |
**Parameters:**
- `value`: string
---
##### `inferComponentFromPath()`
Infer component name from file path
When no explicit
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").ComponentInfo` - ComponentInfo with inferred component name || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/component-detector.ts:400` |
**Parameters:**
- `filePath`: string — - Absolute path to the Astro file
**Examples:**
---
##### `findSourceFiles()`
Find Astro source files matching the given patterns
Locates all .astro files in the workspace using glob patterns.
Returns absolute paths to enable downstream processing.
Default patterns include src directory and exclude node_modules, dist, build, and .astro.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Async** | Yes || **Returns** | `Promise{ include?: string[]; exclude?: string[]; } — - Configuration object
**Examples:**
---
##### `findPackageJsonFiles()`
Find all package.json files in the workspace
Extracts base directories from include patterns and searches multiple directory levels
to locate all package.json files. Useful for identifying container boundaries and
package metadata (name, version, description).
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Async** | Yes || **Returns** | `Promise{ include?: string[]; exclude?: string[]; } — - Configuration object
**Examples:**
---
##### `readPackageInfo()`
Read package.json and extract metadata
Parses a package.json file and extracts key metadata fields: name, version, and description.
Returns null on read or parse errors (logged as warnings).
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Async** | Yes || **Returns** | `Promisestring — - Absolute path to package.json file
**Examples:**
---
##### `findNearestPackage()`
Find the nearest package.json for a given file
Searches through all known packages and finds the one whose directory is the closest
parent of the given file. Packages are sorted by depth (deepest first) to prioritize
monorepo sub-packages over workspace root packages.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").PackageInfo` - The closest parent package, or null if file is not within any package || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/file-finder.ts:172` |
**Parameters:**
- `filePath`: string — - Absolute path to the file- `packages`: import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").PackageInfo[] — - Array of discovered package.json metadata objects
**Examples:**
---
##### `parseFiles()`
Parse Astro files using
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Async** | Yes || **Returns** | `Promisestring[] — - Array of absolute paths to Astro files
**Examples:**
---
##### `extractFrontmatter()`
Extract frontmatter content from Astro file
Astro files have two sections separated by --- markers:
- Frontmatter: TypeScript/JavaScript code at the top (server-side)
- Template: HTML markup and component usage (client-side)
This function extracts only the frontmatter section. Returns empty string if no frontmatter.
Handles both Unix and Windows line endings for cross-platform compatibility.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `string` - Frontmatter code between the --- markers, or empty string || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/file-parser.ts:157` |
**Parameters:**
- `content`: string — - Full Astro file content
**Examples:**
---
##### `extractImports()`
Extract import statements from frontmatter
Parses all import declarations using regex and categorizes them:
- Default imports: import Foo from 'bar'
- Named imports: import { Foo, Bar } from 'baz'
- Namespace imports: import * as Foo from 'bar'
Also handles aliased imports like: import { Foo as F } from 'bar'
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `{ source: string; importedNames: string[]; isDefault: boolean; isNamespace: boolean; }[]` - Array of import declarations with categorization || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/file-parser.ts:183` |
**Parameters:**
- `frontmatter`: string — - TypeScript/JavaScript code from frontmatter
**Examples:**
---
##### `findSlots()`
Find slot tags in the template
Astro components can define slots to allow content projection:
- Default slot: string — - Full Astro file content (used to calculate line numbers)
**Examples:**
---
##### `findClientDirective()`
Find client directive in component usage
Astro allows hydration directives to run components on the client:
- client:load - Eager hydration
- client:idle - Hydrate when browser is idle
- client:visible - Hydrate when component enters viewport
- client:media - Hydrate when media query matches
- client:only - Hydrate only on client (no SSR)
Returns the first directive found. Used to indicate interactive components.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `string` - The directive found (e.g., 'client:load'), or undefined || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/file-parser.ts:291` |
**Parameters:**
- `content`: string — - Full Astro file content
**Examples:**
---
##### `extractComponentUsage()`
Extract component usage from template
Identifies which imported components are actually used in the template markup.
Only includes components that:
1. Start with an uppercase letter (C4 naming convention)
2. Are found in the import statements
3. Appear in the template markup
Component names in Astro are PascalCase by convention (e.g., Header, Footer).
This function uses the import list to avoid false positives from HTML elements.
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").ExtractedComponent[]` - Array of ExtractedComponent objects for used components || **Location** | `C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/file-parser.ts:317` |
**Parameters:**
- `content`: string — - Full Astro file content- `imports`: { source: string; importedNames: string[]; }[] — - List of imports from extractImports()- `filePath`: string — - File path (used for location tracking)
**Examples:**
---
##### `mapToIR()`
Map file extractions to ArchletteIR
Transforms extracted Astro component data into standardized ArchletteIR format.
This is the final step before DSL generation and diagram rendering.
Algorithm (4 main steps):
1. **Aggregation** - Combine all file extractions:
- Register components, actors, code items from all files
- Detect and merge duplicates (same component in multiple files)
- Build relationship graph from
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `public` |
| **Returns** | `z.inferimport("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").FileExtraction[] — - Array of FileExtraction (from parseFiles)- `packages`: import("C:/Users/chris/git/archlette/src/extractors/builtin/basic-astro/types").PackageInfo[] — - Optional array of PackageInfo for container detection- `systemInfo`: z.infer — - Optional system metadata (name, description, repository)
**Examples:**
---
##### `mapClassToCodeItems()`
Map a class to code items (class + methods)
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `z.inferimport("C:/Users/chris/git/archlette/src/extractors/builtin/basic-node/types").ExtractedClass- `componentId`: string- `filePath`: string
---
##### `mapFunctionToCodeItem()`
Map a function to a code item
| Field | Value |
| --- | --- |
| **Type** | `function` |
| **Visibility** | `private` |
| **Returns** | `z.inferimport("C:/Users/chris/git/archlette/src/extractors/builtin/basic-node/types").ExtractedFunction- `componentId`: string- `filePath`: string
---