How davesnx/styled-ppx works
Main Components
a. Core Components:
• PPX Transformation Engine (packages/ppx)
• CSS Property Parser (packages/css-property-parser)
• CSS Spec Parser (packages/css-spec-parser)
• Runtime Libraries (packages/runtime)
• Melange Runtime
• Native Runtime
• ReScript Runtime
b. Supporting Components:
• Parser System (packages/parser)
• String Interpolation Engine (packages/string_interpolation)
• Editor Integration (packages/editors)
• Testing Infrastructure (various test directories)
Component Relationships
Source Code → PPX Transform → Runtime → Final Output
• ↑
• (uses)
• CSS Parser Components
Detailed Architecture
┌─────────────────────────┐
• Source Code │
• (.re/.res files with │
• styled components) │
• ┬──────────┘
• ↓
┌─────────────────────────┐
• PPX Transform │
• CSS Property Parser │
• CSS Spec Parser │
• String Interpolation │
• ┬──────────┘
• ↓
┌─────────────────────────┐
• Runtime Libraries │
• ┌─────────────────┐ │
• Melange │ │
• ┘ │
• ┌─────────────────┐ │
• Native │ │
• ┘ │
• ┌─────────────────┐ │
• ReScript │ │
• ┘ │
• ┬──────────┘
• ↓
┌─────────────────────────┐
• Final Output │
• (Compiled JavaScript │
• or Native Code) │
• ┘
Additional Elements
Supporting components in a side panel:
• Editor Support (VSCode, Vim)
• Testing Infrastructure
• Build System (dune)
Key Interactions to Highlight
• How the PPX transformer processes the source code
• How the CSS parsers feed into the transformation
• Demonstrate the different runtime paths for Melange, Native, and ReScript
• How editor support integrates with the development workflow
Technical Details
• Emotion integration for web output
• CSS property parsing and validation flow
• Type-safety mechanisms
• Build system integration
The type-safety aspects of the system
This system design should help developers understand both the high-level architecture and the detailed interactions between components while maintaining a clear view of the project's main purpose: providing type-safe styled components for ReScript, Melange, and Native OCaml development.