Skip to content

Commit 7e6c258

Browse files
feat: add basic-astro extractor (#30)
Astro files speak. Archlette listens. Extract architecture from .astro components. Each file becomes a component. Frontmatter JSDoc defines actors. Imports create relationships. Supports: - Component detection from file structure and JSDoc tags - Actor extraction from @Actor annotations - Relationship mapping from imports and @uses tags - Code element extraction from frontmatter (classes, functions, types) Astro components map to C4 components. Natural fit. No special handling for islands. Pure architectural extraction. Completes the JavaScript/TypeScript extraction trilogy: basic-node, basic-wrangler, basic-astro.
1 parent 3332254 commit 7e6c258

File tree

136 files changed

+16653
-4814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+16653
-4814
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- run: npm run lint
2525
- run: npm run typecheck
2626
- run: npm test
27+
- run: npm run build
2728
- name: Publish
2829
run: npm publish --access public --provenance
2930
env:

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
> **Code speaks. Archlette listens. Architecture evolves.**
44
55
[![npm version](https://img.shields.io/npm/v/@chrislyons-dev/archlette?color=blue&logo=npm)](https://www.npmjs.com/package/@chrislyons-dev/archlette)
6+
[![npm downloads](https://img.shields.io/npm/dm/@chrislyons-dev/archlette?color=blue)](https://www.npmjs.com/package/@chrislyons-dev/archlette)
67
[![CI](https://github.com/chrislyons-dev/archlette/actions/workflows/ci.yml/badge.svg)](https://github.com/chrislyons-dev/archlette/actions/workflows/ci.yml)
78
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
89

@@ -35,14 +36,18 @@ See Archlette documenting itself: [architecture docs](docs/architecture/README.m
3536
npm install -D @chrislyons-dev/archlette
3637
```
3738

38-
**Requirements:** Node.js ≥ 18, Java ≥ 11
39+
**Requirements:** Node.js ≥ 18 (Node 20+ recommended), Java ≥ 11
3940

4041
**Free and open-source** — MIT licensed. No accounts, no telemetry, no lock-in.
4142

4243
See [Installation Guide](https://chrislyons-dev.github.io/archlette/getting-started/installation/) for platform-specific setup.
4344

4445
### Annotate
4546

47+
Works with **TypeScript, JavaScript, and Astro** components:
48+
49+
**TypeScript/JavaScript:**
50+
4651
```typescript
4752
/**
4853
* @module UserService
@@ -58,6 +63,31 @@ export class UserService {
5863
}
5964
```
6065

66+
**Astro Components:**
67+
68+
```astro
69+
---
70+
/**
71+
* @component Button
72+
* Reusable button component with multiple variants
73+
*
74+
* @uses Icon Displays button icon
75+
* @actor User {Person} {in} Clicks button to trigger action
76+
*/
77+
78+
interface Props {
79+
variant?: 'primary' | 'secondary';
80+
disabled?: boolean;
81+
}
82+
83+
const { variant = 'primary', disabled = false } = Astro.props;
84+
---
85+
86+
<button class={`btn btn-${variant}`} disabled={disabled}>
87+
<slot />
88+
</button>
89+
```
90+
6191
### Configure
6292

6393
Create `.aac.yaml`:
@@ -69,9 +99,14 @@ project:
6999
extractors:
70100
- use: extractors/builtin/basic-node
71101
inputs:
72-
include: ['src/**/*.ts']
102+
include: ['src/**/*.ts', 'src/**/*.js']
103+
- use: extractors/builtin/basic-astro
104+
inputs:
105+
include: ['src/**/*.astro']
73106
```
74107
108+
**Note:** Use `basic-node` for TypeScript/JavaScript files and `basic-astro` for Astro components. Both produce compatible IR for aggregation.
109+
75110
### Generate
76111

77112
```bash
@@ -118,6 +153,48 @@ npx archlette
118153

119154
---
120155

156+
## Extractors
157+
158+
Archlette includes built-in extractors for multiple languages:
159+
160+
### basic-node
161+
162+
Extracts architecture from **TypeScript and JavaScript** codebases using AST analysis with ts-morph.
163+
164+
- Detects components from directory structure or explicit `@component` tags
165+
- Extracts classes, functions, types, and interfaces
166+
- Parses JSDoc annotations for actors and relationships
167+
- Identifies dependencies from import statements
168+
169+
**When to use:** TypeScript/JavaScript projects, Node.js backends, frontend libraries
170+
171+
### basic-astro
172+
173+
Extracts architecture from **Astro components** using the Astro compiler.
174+
175+
- Identifies components from Astro file names or `@component` tags
176+
- Extracts component props, slots, and client directives
177+
- Parses frontmatter code for additional type information
178+
- Detects component composition from template markup
179+
- Works seamlessly with basic-node for full-stack analysis
180+
181+
**When to use:** Astro-based projects, island architecture, mixed TypeScript + Astro applications
182+
183+
### basic-python
184+
185+
Extracts architecture from **Python** codebases using AST parsing (no runtime required).
186+
187+
- Supports Python 3.8+ syntax
188+
- Detects classes, functions, and dependencies
189+
190+
**When to use:** Python projects, data science applications, mixed-language monorepos
191+
192+
### custom-extractors
193+
194+
Write your own extractor to support additional languages or frameworks. See [Plugin Development](https://chrislyons-dev.github.io/archlette/plugins/extractors/).
195+
196+
---
197+
121198
## Features
122199

123200
**Pipeline:**

THIRD_PARTY_LICENSES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The following packages are installed as production dependencies via `package.jso
3636
### NPM Dependencies Summary
3737

3838
```
39-
├─ MIT: 76
39+
├─ MIT: 77
4040
├─ ISC: 10
4141
├─ BSD-3-Clause: 2
4242
├─ Apache-2.0: 1
@@ -61,4 +61,4 @@ This script:
6161

6262
---
6363

64-
**Last generated**: 2025-10-26
64+
**Last generated**: 2025-10-28

archlette.config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ extractors:
3434
- '/users/chris/git/bond-math/iac/workers/pricing.toml'
3535
- '/users/chris/git/bond-math/iac/workers/valuation.toml'
3636

37+
- use: extractors/builtin/basic-astro
38+
inputs:
39+
include:
40+
- '/users/chris/git/bond-math/ui/**/*.astro'
41+
exclude:
42+
- '**/*.test.astro'
43+
- '**/.astro/**'
44+
- '**/dist/**'
45+
- '**/build/**'
46+
- '**/node_modules/**'
47+
- '**/*.test.*'
48+
- '**/*.spec.*'
49+
- '**/test/**'
50+
- '**/tests/**'
51+
- '**/vitest.config.ts'
52+
3753
- use: extractors/builtin/basic-node
3854
inputs:
3955
include:
@@ -45,6 +61,8 @@ extractors:
4561
- '/users/chris/git/bond-math/ui/**/*.tsx'
4662
exclude:
4763
- '**/node_modules/**'
64+
- '**/dist/**'
65+
- '**/build/**'
4866
- '**/*.test.*'
4967
- '**/*.spec.*'
5068
- '**/test/**'
@@ -60,6 +78,8 @@ extractors:
6078
- '/users/chris/git/bond-math/services/gateway/**/*.tsx'
6179
exclude:
6280
- '**/node_modules/**'
81+
- '**/dist/**'
82+
- '**/build/**'
6383
- '**/*.test.*'
6484
- '**/*.spec.*'
6585
- '**/test/**'
@@ -75,6 +95,8 @@ extractors:
7595
- '/users/chris/git/bond-math/services/daycount/**/*.tsx'
7696
exclude:
7797
- '**/node_modules/**'
98+
- '**/dist/**'
99+
- '**/build/**'
78100
- '**/*.test.*'
79101
- '**/*.spec.*'
80102
- '**/test/**'
@@ -93,6 +115,10 @@ extractors:
93115
- '**/*.venv/***'
94116
- '**/test/**'
95117
- '**/tests/**'
118+
- '**/flarelette/**'
119+
- '**/dateutil/**'
120+
- '**/pythonjsonlogger/**'
121+
- '**/six.py'
96122

97123
# ir json in, ir json out (or errors)
98124
validators:

docs/architecture/README.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)