Architecture
System Architecture
example.tsts
1┌─────────────────────────────────────────┐2│ Reface │3│ │4│ ┌─────────────┐ ┌────────────┐ │5│ │ Deno │ │ Router │ │6│ │ Server │─────▶ │ System │ │7│ └─────────────┘ └────────────┘ │8│ │ │ │9│ ▼ ▼ │10│ ┌─────────────┐ ┌────────────┐ │11│ │ Static │ │ Layouts │ │12│ │ Files │ │ │ │13│ └─────────────┘ └────────────┘ │14│ │ │15│ ▼ │16│ ┌─────────────────────────────────┐ │17│ │ RefaceComposer │ │18│ │ │ │19│ │ ┌──────────┐ ┌──────────┐ │ │20│ │ │ Plugin │ │ Template │ │ │21│ │ │ System │ │ Process │ │ │22│ │ └──────────┘ └──────────┘ │ │23│ └─────────────────────────────────┘ │24│ │25│ ┌─────────────────────────────────┐ │26│ │ Interactive System │ │27│ │ │ │28│ │ ┌──────────┐ ┌────────┐ │ │29│ │ │ Partials │ │Islands │ │ │30│ │ │ (HTMX) │ │ (RPC) │ │ │31│ │ └──────────┘ └────────┘ │ │32│ └─────────────────────────────────┘ │33└─────────────────────────────────────────┘
Core Components
1. Reface Framework
High-level framework providing:
Deno server integration
Static file handling
Routing system
Layout management
Plugin configuration
Interactive architecture
2. RefaceComposer
Template composition engine:
Plugin management
Template processing
HTML generation
Component system
3. Interactive System
Partials (HTMX)
Live components
REST-based updates
HTMX integration
State management
Islands (RPC)
Micro-applications
RPC protocol support
Rich interactions
Isolated state
Implementation Details
Server Layer
example.typescripttypescript
1class Reface {2 constructor(options: { layout: Layout }) {3 this.layout = options.layout;4 }56 // Page routing7 page(route: string, generator: TemplateGenerator<PageProps>) {8 // Page registration9 }1011 // Server adapters12 hono() {13 /* Hono integration */14 }15 oak() {16 /* Oak integration */17 }18 express() {19 /* Express integration */20 }21}
Interactive Components
example.typescripttypescript
1// Partial Component (HTMX-based)2const Counter = partial(async () => {3 return (4 <div>5 <button {...Counter.trigger()}>Increment</button>6 </div>7 );8}, "counter");910// Island Component (RPC-based)11const TodoApp = Reface.addIsland({12 name: "todo",13 template: ({ rpc, rest }) => (14 <div>15 <button {...rpc.hx.addTodo()}>Add</button>16 <button {...rest.hx("self", "get", "/list")}>Refresh</button>17 </div>18 ),19 rpc: {20 addTodo: async ({ args }) => {21 /* RPC handler */22 },23 },24 rest: {25 "get|/list": async (req) => {26 /* REST handler */27 },28 },29});
Module Structure
example.undefined
1@reface/2├── core/ # Core composition engine3│ └── RefaceComposer # Template composition4│5├── framework/ # Reface framework6│ ├── server/ # Deno server7│ ├── router/ # Routing system8│ └── static/ # Static files9│10├── interactive/ # Interactive components11│ ├── partials/ # HTMX components12│ └── islands/ # RPC components13│14└── plugins/ # Official plugins
Development Plans
Near Future
Framework Layer
Full server integration
Advanced routing
Middleware system
Static optimization
Islands Architecture
Enhanced RPC system
State management
TypeScript integration
Development tools
Build System
Asset optimization
Code splitting
Tree shaking
Bundle analysis