How benjanavarro/portfolio-fresh works
Project Type and Purpose
• This is a Fresh-based web application running on the Deno runtime.
• The app is essentially a personal/portfolio website featuring multiple interactive “islands” (components that hydrate on the client).
• It uses server-side rendering for initial page loads and client hydration for specific interactive parts. There is a small API route (/api/joke) but no heavy back-end service or external database.
File Structure Analysis
Top-level:
• main.ts – entry point where the Fresh server is started.
• fresh.config.ts & deno.json – configuration for Fresh and Deno tasks.
• routes/ – page definitions and API endpoints.
• islands/ – interactive UI components that hydrate on the client.
• context/, hooks/, utils/, types.d.ts – application logic, state management (languageContext), validation, dictionaries.
• static/ – static assets (CSS, PDF resume).
• tailwind.config.ts – styling framework configuration.
• CI/CD: .github/workflows/deploy.yml defines automated deploy.
Key Architectural Insights
• Fresh on Deno provides built-in routing, server-side rendering (SSR), and island-based hydration.
• Separation of concerns:
– Server layer: routing, SSR, API endpoints.
– Presentation layer: routes for full-page rendering, components for pure UI, islands for client interactivity.
– Shared logic: context, hooks, utils covering internationalization, event handling, validation.
• Deployment is likely to an edge environment (Deno Deploy or similar) using GitHub Actions.
a. Main Components
1. Deno Runtime & Fresh Framework
2. Router & SSR Engine (routes/ folder)
3. Page Components (e.g. routes/index.tsx, _app.tsx, _404.tsx)
4. Island Components (interactive parts in islands/)
5. Shared Component Library (components/)
6. Context & Hooks (context/, hooks/)
7. Utilities (utils/, types.d.ts)
8. Static Assets (static/)
9. API Endpoint (routes/api/joke.ts)
10. Tailwind/Styling layer
b. Relationships and Data Flow
• Client Browser → HTTP Request → Deno/Fresh Router
– Router matches path → SSR renders Page Component tree (pulling in components, utils, context).
– Islands are marked for client hydration but rendered server side first.
• Deno → sends HTML + CSS link + client JS bundle → Browser
• Browser → hydrates specified Island Components asynchronously
• Island Components can call back to API Endpoint (/api/joke) or use hooks/contexts for state
• Static Assets served directly by Fresh under /static/
c. Architectural Patterns
• Island Architecture: SSR with selective hydration
• Component-based UI library (React-style / Preact)
• Context API for global state (language selection)
• Utility modules for JSON dictionaries, form validation, skill data
d. Key Technologies/Frameworks
• Deno (runtime)
• Fresh (framework)
• Preact (underlying UI)
• TailwindCSS (styling)
• TypeScript
• GitHub Actions (CI/CD)