You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+90-23Lines changed: 90 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,46 +4,113 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
This is a Rust-based Node.js native addon project that aims to integrate Python capabilities into Node.js applications. It uses NAPI-RS to create Node.js bindings for Rust code.
7
+
This is a Rust-based Node.js native addon that enables running **ASGI-compatible Python applications** within Node.js environments. It uses NAPI-RS to create Node.js bindings for Rust code that integrates with Python via PyO3.
8
8
9
9
## Build Commands
10
10
11
11
```bash
12
12
# Install dependencies
13
-
yarn install
13
+
npm install
14
14
15
15
# Build release version for current platform
16
-
yarn build
16
+
npm run build
17
17
18
18
# Build debug version
19
-
yarn build:debug
19
+
npm run build:debug
20
20
21
21
# Run tests
22
-
yarn test
22
+
npm test
23
+
24
+
# Lint code
25
+
npm run lint
23
26
```
24
27
25
28
## Architecture
26
29
27
-
The project structure follows NAPI-RS conventions:
28
-
-**Rust code**: `/src/lib.rs` contains the native addon implementation
29
-
-**Node.js interface**: `/index.js` and `/index.d.ts` provide the JavaScript API
30
-
-**Cross-platform builds**: Configured for macOS (arm64, x64) and Linux (x64-gnu)
30
+
The project implements a complete ASGI 3.0 server that bridges Node.js, Rust, and Python:
31
+
32
+
**Core Components:**
33
+
-**Rust Backend** (`/src/lib.rs`): Main NAPI addon exposing `PythonHandler` class to JavaScript
34
+
-**ASGI Implementation** (`/src/asgi/mod.rs`): Complete ASGI protocol handler with HTTP, WebSocket, and Lifespan support
35
+
-**Protocol Modules** (`/src/asgi/`): Individual ASGI message types and connection scopes
36
+
-**Node.js Interface** (`/index.js`, `/index.d.ts`): Auto-generated NAPI bindings
37
+
38
+
**Key Architecture Details:**
39
+
- Uses PyO3 with `pyo3-async-runtimes` for Python async integration
40
+
- Supports Python virtual environments via `VIRTUAL_ENV` environment variable
41
+
- Implements tokio runtime management for async Python code execution
42
+
- Cross-platform builds for macOS (arm64, x64) and Linux (x64-gnu)
43
+
44
+
## Python Integration
45
+
46
+
**ASGI Support:**
47
+
- Full ASGI 3.0 specification implementation
48
+
- HTTP request/response handling with streaming support
49
+
- WebSocket connections (implementation in progress)
50
+
- Lifespan management for application startup/shutdown
51
+
52
+
**Python Environment:**
53
+
- Automatically detects and uses Python virtual environments
0 commit comments