# Strata **Static Template Rendering Architecture** Strata is a compile-time web framework that resolves templates to pure HTML at build time. Zero runtime framework overhead. Maximum performance. ``` ╔═══════════════════════════════════════════════════════╗ ║ ███████╗████████╗██████╗ █████╗ ████████╗ █████╗ ║ ║ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗ ║ ║ ███████╗ ██║ ██████╔╝███████║ ██║ ███████║ ║ ║ ╚════██║ ██║ ██╔══██╗██╔══██║ ██║ ██╔══██║ ║ ║ ███████║ ██║ ██║ ██║██║ ██║ ██║ ██║ ██║ ║ ║ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ║ ╚═══════════════════════════════════════════════════════╝ ``` --- ## Table of Contents - [Philosophy](#philosophy) - [Design Pattern: STRC](#design-pattern-strc) - [Installation](#installation) - [Quick Start](#quick-start) - [CLI Commands](#cli-commands) - [Project Structure](#project-structure) - [File Types](#file-types) - [Template Syntax](#template-syntax) - [Examples](#examples) - [Import Hierarchy](#import-hierarchy) - [Development](#development) - [License](#license) --- ## Philosophy Strata follows three core principles: 1. **Compile-Time Resolution**: All template logic is resolved during build, not at runtime 2. **Zero Runtime Overhead**: Output is pure HTML/CSS/JS with no framework dependencies 3. **Strict Separation of Concerns**: Each file type has a single responsibility --- ## Design Pattern: STRC Strata implements the **STRC Pattern** (Static Template Resolution with Compartmentalized Layers): ``` ┌─────────────────────────────────────────────────────────────┐ │ BUILD TIME │ ├─────────────────────────────────────────────────────────────┤ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ .strata │◄───│ .compiler.sts│◄───│ .service.sts │ │ │ │ (Template) │ │ (Variables) │ │ (Logic) │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │ │ │ │ │ │ │ │ │ │ │ ▼ ▼ ▼ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ STATIC COMPILER │ │ │ │ Resolves all variables, loops, and conditionals │ │ │ └─────────────────────────────────────────────────────┘ │ │ │ │ └───────────────────────────┼─────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ RUNTIME │ ├─────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ PURE HTML │ │ │ │ No Strata syntax, no framework code │ │ │ └─────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────┘ ``` ### STRC Layer Responsibilities | Layer | File Extension | Purpose | Execution | |-------|---------------|---------|-----------| | **Template** | `.strata` | HTML structure with directives | Build time | | **Compiler** | `.compiler.sts` | Variable definitions, data | Build time | | **Service** | `.service.sts` | Business logic, API calls | Build time* | | **Runtime** | `.service.sts` | Optional browser interactivity | Runtime | *Services can define both build-time data fetching and optional runtime interactivity. --- ## Installation ### Prerequisites - Go 1.21+ (for building the compiler) - Node.js 18+ (for project scaffolding) ### Install Strata CLI ```bash # Clone the repository git clone https://github.com/CarGDev/strata.git cd strata # Build the compiler make build # Install globally make install ``` This installs: - `strata` - The main CLI compiler - `create-strata` - Project scaffolding tool --- ## Quick Start ### Create a New Project ```bash # Create a new Strata project npx create-strata-compile my-app # Navigate to project cd my-app # Install dependencies npm install # Start development server npm run dev ``` Open http://localhost:3000 to see your app. ### Build for Production ```bash npm run build ``` Output is in the `dist/` folder - pure static HTML ready for any hosting. --- ## CLI Commands ### Main CLI (`strata`) ```bash # Development server with HMR strata-compile dev [--port 3000] [--open] # Production build strata-compile build [--output dist] # Preview production build strata-compile preview [--port 4000] ``` ### Generator Commands Generate new files with the correct structure: ```bash # Generate a component strata-compile gcomponent Button # Creates: src/components/Button/ # ├── Button.strata # ├── Button.compiler.sts # ├── Button.service.sts # └── Button.scss # Generate a page strata-compile gpage about # Creates: src/pages/about/ # ├── about.strata # ├── about.compiler.sts # ├── about.service.sts # └── about.scss # Generate a service strata-compile gservice auth # Creates: src/services/auth.service.sts # Generate an API contract strata-compile gapi users # Creates: src/api/users.api.sts # Generate a utility strata-compile gutil format # Creates: src/utils/format.sts # Generate a store strata-compile gstore cart # Creates: src/stores/cart.store.sts ``` ### Shorthand Commands ```bash strata-compile gc Button # component strata-compile gp about # page strata-compile gs auth # service strata-compile ga users # api strata-compile gu format # util ``` --- ## Project Structure ``` my-app/ ├── src/ │ ├── components/ # Reusable UI components │ │ └── Button/ │ │ ├── Button.strata │ │ ├── Button.compiler.sts │ │ ├── Button.service.sts │ │ └── Button.scss │ │ │ ├── pages/ # Route-based pages │ │ ├── index/ │ │ │ ├── index.strata │ │ │ ├── index.compiler.sts │ │ │ ├── index.service.sts │ │ │ └── index.scss │ │ └── about/ │ │ └── ... │ │ │ ├── services/ # Business logic │ │ └── auth.service.sts │ │ │ ├── api/ # API contracts │ │ └── users.api.sts │ │ │ ├── stores/ # State management │ │ └── cart.store.sts │ │ │ ├── utils/ # Pure utilities │ │ └── format.sts │ │ │ └── assets/ │ └── styles/ │ ├── _variables.scss │ └── global.scss │ ├── public/ # Static assets (copied as-is) ├── dist/ # Build output ├── strataconfig.ts # Project configuration └── package.json ``` --- ## File Types ### `.strata` - Template Files Pure HTML structure with Strata directives. No logic, no JavaScript. ```html ``` **Rules:** - Must contain a single `