# ADR-003: Front-end Technology Stack ## Status Accepted ## Context StarPunk requires a front-end for: 1. Public interface (homepage, note permalinks) - Server-side rendered 2. Admin interface (note creation/editing) - Requires some interactivity 3. Progressive enhancement principle - Core functionality must work without JavaScript The front-end must be minimal, elegant, and align with the "no client-side complexity" principle stated in CLAUDE.MD. ## Decision ### Public Interface: Server-Side Rendered HTML - **Template Engine**: Jinja2 (included with Flask) - **CSS**: Custom CSS (no framework) - **JavaScript**: None required for V1 - **Build Tools**: None required ### Admin Interface: Enhanced Server-Side Rendering - **Template Engine**: Jinja2 (included with Flask) - **CSS**: Custom CSS (shared with public interface) - **JavaScript**: Minimal vanilla JavaScript for markdown preview only - **Build Tools**: None required ### Asset Management - **CSS**: Single stylesheet served statically - **JavaScript**: Single optional file for markdown preview - **No bundler**: Direct file serving - **No transpilation**: Modern browsers only (ES6+) ## Rationale ### Server-Side Rendering (SSR) **Simplicity Score: 10/10** - Zero build process - No JavaScript framework complexity - Direct Flask template rendering - Familiar Jinja2 syntax **Fitness Score: 10/10** - Perfect for content-first site - Faster initial page load - Better SEO (though not critical for single-user) - Works without JavaScript - Easier to implement microformats **Maintenance Score: 10/10** - Jinja2 is stable and mature - No framework version updates - No npm dependency hell - Templates are simple HTML ### No CSS Framework **Simplicity Score: 10/10** - Custom CSS is ~200 lines for entire site - No unused classes or styles - Full control over appearance - No framework learning curve **Fitness Score: 9/10** - StarPunk needs minimal, elegant design - Single theme, no customization needed - Mobile-responsive can be achieved with simple media queries - No complex components needed ### Minimal JavaScript Approach **Simplicity Score: 9/10** - Vanilla JavaScript only (no React/Vue/Svelte) - Single purpose: markdown preview in admin - Optional progressive enhancement - No build step required **Fitness Score: 10/10** - Markdown preview improves UX but isn't required - All functionality works without JavaScript - Can use fetch API for preview without library - Modern browser features are sufficient ## Consequences ### Positive - Zero build time - No node_modules directory - Instant development setup - Fast page loads - Works with JavaScript disabled - Easy to understand and modify - Microformats implementation is straightforward - Complete control over HTML output ### Negative - No TypeScript type checking - No hot module replacement (but Flask auto-reload works) - Manual CSS organization required - Must write responsive CSS manually ### Mitigation - Keep JavaScript minimal and well-commented - Organize CSS with clear sections - Use CSS custom properties for theming - Test manually in multiple browsers - Validate HTML with W3C validator ## Frontend File Structure ``` static/ ├── css/ │ └── style.css # Single stylesheet for entire site └── js/ └── preview.js # Optional markdown preview (admin only) templates/ ├── base.html # Base template with HTML structure ├── index.html # Homepage (note list) ├── note.html # Single note permalink └── admin/ ├── base.html # Admin base template ├── dashboard.html # Admin dashboard ├── new.html # Create new note └── edit.html # Edit existing note ``` ## CSS Architecture ### Custom CSS Properties (Variables) ```css :root { --color-text: #333; --color-bg: #fff; --color-link: #0066cc; --color-border: #ddd; --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; --font-mono: 'SF Mono', Monaco, monospace; --spacing-unit: 1rem; --max-width: 42rem; } ``` ### Mobile-First Responsive Design ```css /* Base: Mobile styles */ body { padding: 1rem; } /* Tablet and up */ @media (min-width: 768px) { body { padding: 2rem; } } ``` ## JavaScript Architecture ### Markdown Preview Implementation ```javascript // static/js/preview.js // Simple markdown preview using marked.js CDN (no build step) // Progressive enhancement - form works without this ``` **Decision**: Use marked.js from CDN for client-side preview - **Justification**: Same library as server-side (consistency) - **Simplicity**: No bundling required - **Reliability**: CDN delivers cached version - **Alternative**: No preview (acceptable fallback) ## Template Organization ### Jinja2 Template Strategy - **Inheritance**: Use base templates for common structure - **Blocks**: Define clear content blocks for overriding - **Macros**: Create reusable microformat snippets - **Filters**: Use Jinja2 filters for date formatting ### Example Base Template Structure ```jinja2 {# templates/base.html #}