|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is `@platformatic/python` - a Python stackable for Watt that integrates Python applications with the Platformatic framework. It enables serving Python ASGI applications through a Fastify server with proper request/response handling. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +- `npm test` - Run tests using Node.js built-in test runner |
| 12 | +- `npm run build` - Generate schema.json and config.d.ts from schema definitions |
| 13 | +- `npm run ci` - Run linting and tests (assumes lint script exists) |
| 14 | + |
| 15 | +## Architecture |
| 16 | + |
| 17 | +The project follows Platformatic's stackable pattern: |
| 18 | + |
| 19 | +### Core Components |
| 20 | + |
| 21 | +- **lib/index.js** - Main stackable export with configuration and plugin registration |
| 22 | +- **lib/plugin.js** - Fastify plugin that handles Python request routing and execution |
| 23 | +- **lib/generator.js** - Code generator for creating new Python stackable projects |
| 24 | +- **lib/schema.js** - JSON schema definitions for configuration validation |
| 25 | + |
| 26 | +### Key Architecture Patterns |
| 27 | + |
| 28 | +1. **Stackable Integration**: Extends `@platformatic/service` with Python-specific functionality |
| 29 | +2. **Request Handling**: All HTTP methods are captured by wildcard routes and forwarded to Python via `@platformatic/python-node` |
| 30 | +3. **Static File Serving**: Non-Python files in docroot are served statically with `@fastify/static` |
| 31 | +4. **Header Processing**: HTTP headers are capitalized for Python compatibility |
| 32 | +5. **Configuration Schema**: Uses JSON schema with automatic TypeScript generation |
| 33 | + |
| 34 | +### Generated Project Structure |
| 35 | + |
| 36 | +When using the generator, projects include: |
| 37 | +- `public/` directory as Python docroot with `main.py` containing a basic ASGI app |
| 38 | +- `platformatic.json` configuration file |
| 39 | +- `.env` and `.env.sample` for environment variables |
| 40 | +- Node.js v22.18.0+ and Python 3.8+ requirements |
| 41 | + |
| 42 | +### Testing Approach |
| 43 | + |
| 44 | +- Uses Node.js built-in test runner (`node --test`) |
| 45 | +- Tests cover generator functionality, configuration validation, and file generation |
| 46 | +- Test fixtures in `test/fixtures/` for integration testing |
0 commit comments