Module: src/utils/baseContext.js
What it does: Asynchronously builds the base context object containing site-wide data (navigation links, post menus, site owner info, environment variables, etc.) for rendering views.
Where it fits in the request/response lifecycle: Called before rendering templates to prepare the shared context injected into views (e.g., handlebars templates).
Which files or modules directly depend on it: Route handlers or controllers that render pages requiring the standard site context.
How it communicates with other modules or components: Imports post menu service and utility functions to gather navigation links, format months, filter secure links; reads environment variables and JSON content files.
Data flow involving it: Inputs: isAuthenticated boolean, optional context overrides. Outputs: context object with UI state, navigation, menus, and environment-configured values. Side effects: none beyond reading from file system and environment variables.
Impact on overall application behavior and performance: Centralizes preparation of page context, promoting DRY templates. Performance depends on async post menu retrieval and file system reads, which may add latency per request.
Potential points of failure or bottlenecks:
Security, performance, or architectural concerns:
Suggestions for improvement:
Module: src/utils/BaseRoute.js
What it does: Defines a base class encapsulating an Express Router instance, serving as a foundation for custom route classes.
Where it fits in the request/response lifecycle: Used during route setup to organize route handlers and middleware within modular classes.
Which files or modules directly depend on it: Route classes extending BaseRoute (e.g., ConstructionRoutes) that manage specific route groups.
How it communicates with other modules or components: Exposes the router instance via getRouter() method for mounting into the main Express app.
Data flow involving it: Inputs: none beyond instantiation. Outputs: Express Router object to which route handlers are attached. Side effects: none.
Impact on overall application behavior and performance: Provides structural organization, no direct runtime performance impact.
Potential points of failure or bottlenecks: None inherent; depends on subclasses' implementations.
Security, performance, or architectural concerns: None inherent; promotes modular route design.
Suggestions for improvement: No immediate improvements; minimalistic and functional.
Module: src/utils/baseUrl.js
What it does: Constructs and exports the base URL of the application, considering environment variables and optional overrides.
Where it fits in the request/response lifecycle: Used in context building, link generation, or any module needing the canonical site base URL.
Which files or modules directly depend on it: baseContext.js (for injection into templates), potentially route handlers or API modules needing consistent URL formation.
How it communicates with other modules or components: Reads environment variables; exports a constant baseUrl and a helper function getBaseUrl for dynamic URL construction.
Data flow involving it: Inputs: environment variables or parameters for schema, host, port. Outputs: constructed base URL string.
Impact on overall application behavior and performance: Minor, mostly affects URL consistency and link generation.
Potential points of failure or bottlenecks: None significant; environment misconfiguration could cause incorrect URLs.
Security, performance, or architectural concerns:
Suggestions for improvement:
Module: src/utils/ConstructionRoutes.js
What it does: Extends BaseRoute to provide routes that serve "under construction" placeholder pages for specified paths.
Where it fits in the request/response lifecycle: Handles GET requests for routes that are not yet implemented, responding with a construction page.
Which files or modules directly depend on it: Main route registration logic which mounts ConstructionRoutes instances for placeholder routes.
How it communicates with other modules or components: Uses Express Router from BaseRoute, renders a view template pages/construction.handlebars with a title in context.
Data flow involving it: Inputs: HTTP GET requests on registered paths. Outputs: Rendered HTML response with construction message. Side effects: none.
Impact on overall application behavior and performance: Provides graceful handling for incomplete routes, improving user experience. Low overhead.
Potential points of failure or bottlenecks:
Security, performance, or architectural concerns: Minimal security risk; static content.
Suggestions for improvement:
Module: src/utils/createExcerpt.js
What it does: Generates a plain-text excerpt from markdown content by stripping markdown syntax and truncating to a specified character limit with ellipsis.
Where it fits in the request/response lifecycle: Used during post content processing, likely for previews or summaries in listing pages.
Which files or modules directly depend on it: Post rendering logic, summary generation modules, or UI components requiring brief content previews.
How it communicates with other modules or components: Receives raw markdown strings; returns truncated plain-text strings for consumption by views or APIs.
Data flow involving it: Inputs: markdown content string, optional limit. Outputs: truncated plain text excerpt. Side effects: none.
Impact on overall application behavior and performance: Improves UI by providing concise content previews; minimal performance impact due to simple string operations.
Potential points of failure or bottlenecks: None significant; pure function.
Security, performance, or architectural concerns:
Suggestions for improvement:
Summary: All modules serve distinct roles: adminToken.js for ephemeral admin tokens, baseContext.js for building common rendering context, BaseRoute.js as a route abstraction base class, baseUrl.js for base URL construction, ConstructionRoutes.js for placeholder routing, and createExcerpt.js for content preview generation. Security and performance concerns largely relate to token persistence, caching, and error handling. Integration improvements mainly focus on caching frequently read data, handling errors explicitly, and planning for multi-instance scalability.
utils/diskSpaceMonitor.jsWhat it does: Monitors disk space usage of a specified log directory, tracks available and used disk space, calculates log directory size, and automatically performs cleanup of old log files and session data based on configurable thresholds and retention policies. Provides express middleware and API endpoints for integration with admin interfaces.
Where it fits in the request/response lifecycle: Runs asynchronously and independently of individual request/response cycles. Provides middleware for attaching disk space status to admin requests and API endpoints to report status or trigger manual cleanup on demand.
Which files or modules directly depend on it:
How it communicates with other modules or components:
res.locals.fs module and statvfs for system calls.The data flow involving it (inputs, outputs, side effects):
Its impact on overall application behavior and performance:
Potential points of failure or bottlenecks linked to it:
Any security, performance, or architectural concerns:
statvfs package may limit portability or require native bindings.Suggestions for improving integration, security, or scalability:
utils/emailValidator.jsWhat it does: Validates and sanitizes email strings according to RFC 5321 limits and common email formatting rules. Returns structured validation results with error messages or normalized email strings.
Where it fits in the request/response lifecycle: Used during request processing to validate user-submitted email addresses before storing or using them.
Which files or modules directly depend on it:
How it communicates with other modules or components:
The data flow involving it (inputs, outputs, side effects):
{ valid: boolean, email?: string, message?: string } object indicating validation status and sanitized email if valid.Its impact on overall application behavior and performance:
Potential points of failure or bottlenecks linked to it:
validator package functions correctness and coverage.Any security, performance, or architectural concerns:
Suggestions for improving integration, security, or scalability:
utils/env.jsWhat it does: Exports environment-related constants indicating current runtime mode (development, production).
Where it fits in the request/response lifecycle: Used throughout the application to conditionally adjust behavior, logging, debugging, or configuration based on environment.
Which files or modules directly depend on it:
How it communicates with other modules or components:
The data flow involving it (inputs, outputs, side effects):
process.env.NODE_ENV environment variable.NODE_ENV, isProd, isDev.Its impact on overall application behavior and performance:
Potential points of failure or bottlenecks linked to it:
NODE_ENV is unset or misconfigured, logic depending on it may malfunction.Any security, performance, or architectural concerns:
Suggestions for improving integration, security, or scalability:
NODE_ENV against allowed values explicitly to avoid unexpected states.utils/errorContext.jsWhat it does: Provides mapping from HTTP error codes or known error names (e.g., CSRF token errors) to standardized error titles, messages, and HTTP status codes for consistent error responses.
Where it fits in the request/response lifecycle: Used during error handling middleware or controllers to translate error identifiers into user-friendly and standardized error contexts.
Which files or modules directly depend on it:
How it communicates with other modules or components:
The data flow involving it (inputs, outputs, side effects):
title, message, and statusCode.Its impact on overall application behavior and performance:
Potential points of failure or bottlenecks linked to it:
Any security, performance, or architectural concerns:
Suggestions for improving integration, security, or scalability:
utils/filterSecureLinks.jsWhat it does: Filters navigation links based on user authentication state, hiding links marked as secure when the user is not authenticated. Recursively filters nested submenus.
Where it fits in the request/response lifecycle: Used during rendering of navigation menus, typically during request handling that constructs page data.
Which files or modules directly depend on it:
How it communicates with other modules or components:
The data flow involving it (inputs, outputs, side effects):
secure flags, and boolean isAuthenticated.Its impact on overall application behavior and performance:
Potential points of failure or bottlenecks linked to it:
Any security, performance, or architectural concerns:
Suggestions for improving integration, security, or scalability:
End of documentation sections.
hash functionWhat it does: Generates a SHA-256 cryptographic hash from an input value. The input is JSON-stringified before hashing.
Where it fits in the request/response lifecycle: Used during data processing phases where hashing is required (e.g., caching keys, content validation).
Dependencies: No other modules depend explicitly on this function except those that import it explicitly (e.g., post utilities).
Communication: Receives any serializable input, returns a fixed-length hash string. No side effects.
Data flow: Input: arbitrary serializable object. Output: SHA-256 hash hex string. Side effects: none.
Impact on behavior/performance: Provides consistent content hashing; performance impact is minimal due to fast hashing.
Potential failure points: If input is not JSON-serializable, will throw during JSON.stringify.
Security/performance/architecture concerns: SHA-256 is cryptographically secure; ensure input size is controlled to avoid performance degradation.
Suggestions: Validate or limit input size before hashing; consider streaming input for large data.
registerHelpers function (Handlebars helpers)What it does: Registers two Handlebars helpers: formatMonth (converts month number to full name) and formatDate (formats a Date to YYYY-MM-DD).
Where it fits: Invoked at server initialization to extend the view templating engine's capabilities.
Dependencies: Dependent files are those rendering views with Handlebars templates requiring date/month formatting.
Communication: Input: template parameters (month string or date). Output: formatted string for templates. No side effects.
Data flow: Input from template rendering, output back to template engine for final HTML.
Impact: Improves template readability and presentation.
Potential failure points: Invalid month strings or dates passed to helpers return raw input.
Concerns: No notable security risks; date parsing uses native Date object.
Suggestions: Add validation or default fallback values for edge cases.
HttpError classWhat it does: Custom error class extending Error to represent HTTP errors with status codes and additional metadata.
Where it fits: Used during error handling in route controllers and middleware.
Dependencies: Used by modules needing to throw HTTP-specific errors (routes, controllers).
Communication: Input: error message, status code, metadata. Output: error object thrown/caught.
Data flow: Thrown during request processing; caught by error handling middleware.
Impact: Enables consistent error handling with HTTP status and metadata.
Potential failure points: Misuse or uncaught errors causing unhandled rejections.
Concerns: No direct security concerns; ensure sensitive metadata isn't exposed in responses.
Suggestions: Sanitize metadata before sending error responses.
utils/logging.js (Logging subsystem)What it does: Implements a comprehensive logging system combining Winston with custom daily rotating file logs, session logs, SQLite transport, and console patching. Supports multiple log levels including a custom security level.
Where it fits: Global utility for logging during the full request/response lifecycle and application runtime.
Dependencies: Imported by any module requiring logging.
Communication: Receives log messages (level, message, metadata), writes to files, SQLite DB, console, and session logs.
Data flow: Input: log calls from app modules. Output: persisted logs on disk, database, console output.
Impact: Critical for debugging, monitoring, auditing, and security logging. Impacts I/O and disk usage.
Potential failure points:
Security concerns: Logging sensitive information could leak secrets; must sanitize logs. Custom security level helps segregate sensitive logs.
Suggestions:
Module: src/utils/adminToken.js
What it does: Manages short-lived admin pre-authentication tokens by generating, validating, revoking, and cleaning up tokens stored in-memory with expiration timestamps.
Where it fits in the request/response lifecycle: Used during authentication or authorization phases where admin access needs temporary tokens for verification prior to granting elevated privileges.
Which files or modules directly depend on it: Modules handling admin routes, authentication middleware, or security checks requiring token validation before admin operations.
How it communicates with other modules or components: Provides token lifecycle functions that other modules call synchronously to generate or validate tokens; stores tokens in an internal Map without external persistence.
Data flow involving it: Inputs: calls to generateToken produce tokens; validateToken checks input tokens; revokeToken removes tokens. Outputs: token strings or boolean validation results. Side effects: internal Map updated by adding or removing tokens, cleanup removes expired entries.
Impact on overall application behavior and performance: Critical for temporary admin access control. Uses in-memory storage, which is fast but not persistent across app restarts. Token cleanup is manual and could affect memory if neglected.
Potential points of failure or bottlenecks:
Security, performance, or architectural concerns:
Suggestions for improvement:
src/utils/errorContext.jsWhat it does Provides error page metadata based on HTTP status codes.
Where it fits in the request/response lifecycle Used by src/routes/errorPage.js.
src/utils/formLimiter.jsWhat it does Express middleware implementing rate limiting for form submissions.
Where it fits in the request/response lifecycle Applied to POST /contact.
src/utils/hcaptcha.jsWhat it does Verifies hCaptcha tokens via external API.
Where it fits in the request/response lifecycle Used by contact form POST route.
src/utils/mail.jsWhat it does Sends emails for contact form submissions.
src/utils/postFileUtils.jsWhat it does Reads blog post files and metadata from the filesystem.
src/utils/forensics.jsWhat it does Performs security analysis on form data to detect spam or abuse.
src/utils/linkUtils.jsWhat it does Provides helper functions to identify URLs and email addresses in strings.
Summary complete.
analytics.js)What it does: Logs GET requests that accept HTML to a SQLite3 database table named analytics. It records timestamp, URL, referrer, user agent, and IP addresses (forwarded and direct).
Where it fits: Runs early in the middleware chain on every GET request for HTML pages, before route handlers.
Direct dependencies:
../utils/sqlite3 for database operations.Communication: Writes directly to the database; no other module interaction beyond passing control with next().
Data flow:
analytics table.Impact: Enables collection of usage data for monitoring or analytics. May slightly delay responses due to DB writes but minimal if DB is performant.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
applyProductionSecurity Middleware (applyProductionSecurity.js)What it does: Aggregates multiple security-related middleware for production: disables X-Powered-By, prevents HTTP parameter pollution, sanitizes XSS, blocks localhost hostname access in production, sets HSTS and CSP headers via Helmet.
Where it fits: Runs early in middleware chain, typically after parsing but before routes, to apply security constraints on requests.
Direct dependencies:
helmet for security headers.hpp for HTTP parameter pollution.xssSanitizer for XSS input cleaning.HttpError for error signaling.../constants/securityConstants.Communication: Processes request and response headers and data, passes errors to next error handler middleware if access is forbidden.
Data flow:
Impact: Improves security posture by hardening headers, preventing request pollution and restricting access from certain hostnames.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
xssSanitizer should be carefully maintained to avoid over/under sanitization.Improvement suggestions:
authCheck.js)What it does: Verifies user authentication by calling an external verification service (VERIFY_URL), with caching to reduce calls. Bypasses check for specified safe IP addresses.
Where it fits: Early middleware, before route handlers that require authentication.
Direct dependencies:
node-fetch for HTTP requests.../constants/authConstants.Communication: Calls external auth verification service via HTTP. Sets req.isAuthenticated boolean. Logs status.
Data flow:
cookie, authorization), client IP.req.isAuthenticated property.Impact: Controls access to protected resources by confirming user authentication state. Reduces verification overhead via caching.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
baseContext.js)What it does: Creates a base context object for rendering views, including authentication state and dynamically generated admin login URL. Injects helpers into res for consistent rendering.
Where it fits: Runs before view rendering middleware/routes.
Direct dependencies:
getBaseContext, qualifyLink, generateToken.Communication: Prepares and attaches data to res.locals for use in templates. Extends res with custom render functions.
Data flow:
req.isAuthenticated.res.locals.baseContext, res.renderWithBaseContext, res.renderGenericMessage.Impact: Standardizes rendering context and helper methods, reducing duplication in route handlers and templates.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
controllers.js)What it does: Loads all controller modules dynamically from the controllers directory and attaches them along with models to the request object for route handlers.
Where it fits: Runs early before route handling.
Direct dependencies:
loadControllers.../models.Communication: Injects req.controllers and req.models for downstream middleware and route handlers.
Data flow:
req with controllers and models.Impact: Provides modular, reusable controller logic access uniformly.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
csrfToken.js)What it does: Provides CSRF protection using csurf with cookie-based tokens. Attaches token to res.locals.csrfToken for use in forms.
Where it fits: Middleware before routes that render forms or accept form data.
Direct dependencies:
cookie-parser and csurf middleware.Communication: Sets and verifies CSRF tokens on requests/responses transparently.
Data flow:
Impact: Prevents cross-site request forgery by requiring token validation.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
errorHandler.js)What it does: Handles application errors by logging detailed info, conditionally redirecting unauthenticated users to error pages, and rendering error pages with appropriate context.
Where it fits: Final error-handling middleware in the Express chain.
Direct dependencies:
Communication: Logs errors, sets response status, and renders error views or redirects.
Data flow:
Impact: Provides user-friendly error pages and centralized error logging.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
formatHtml.js)What it does: Beautifies outgoing HTML responses using js-beautify.
Where it fits: After route handlers generate HTML but before response sent.
Direct dependencies:
js-beautify library.Communication:
Modifies outgoing response body if Content-Type is text/html.
Data flow:
Impact: Improves HTML readability for debugging or client inspection.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
logger.js)What it does: Logs basic HTTP request info (method, path, remote IP).
Where it fits: Early in middleware chain for request auditing.
Direct dependencies:
console.log.Communication: Synchronous console logging.
Data flow:
Impact: Basic request logging for diagnostics.
Potential failures/bottlenecks:
Security/performance/architecture concerns:
Improvement suggestions:
utils/*.js)Includes:
getBaseContext.jslogger.js (logging utility)sqlite3.js (SQLite3 wrapper)Function: Utility functions to support middleware and app logic.
Dependencies: Varies, e.g., sqlite3.js wraps SQLite3 database interactions.
Usage: Abstracts repetitive or complex code into reusable functions.
The middleware modules form a coherent Express.js backend security and request processing stack. Core functions include analytics logging, authentication verification with caching, security hardening headers, CSRF protection, error handling, and context preparation for views. Utilities abstract DB operations and logging.
Modules exhibit a separation of concerns:
Each relies on common utilities and environment-configured constants. Improvements focus on error handling, performance under load, and security hardening.
newsletterService.jsWhat it does Manages subscriber emails for a newsletter by validating, saving, and removing emails from a JSON file on disk.
Where it fits in the request/response lifecycle Used in handling newsletter subscription/unsubscription requests. It processes email input, persists the subscriber list, and supports data consistency during concurrent writes.
Which files or modules directly depend on it Likely used by API route handlers/controllers dealing with newsletter subscription endpoints.
How it communicates with other modules or components
validateAndSanitizeEmail utility to ensure valid emails.FILE_PATH).writeLock) to serialize file writes.Data flow (inputs, outputs, side effects)
Impact on overall application behavior and performance Critical for correct subscription state management. Serialized writes prevent data corruption but may cause delays if write operations queue up under high concurrency.
Potential points of failure or bottlenecks
writeLock) can become a bottleneck under high-frequency subscription/unsubscription events.Security, performance, or architectural concerns
Suggestions for improvement
postsMenuService.jsWhat it does Generates a structured menu of blog posts grouped by year and month from all posts available under a base directory.
Where it fits in the request/response lifecycle Used when rendering the blog navigation UI or site menu that lists posts chronologically.
Which files or modules directly depend on it Views or controllers that need to render the posts menu, possibly frontend rendering code or server-side templates.
How it communicates with other modules or components
getAllPosts utility to load all post metadata.qualifyLink utility to normalize or fully qualify post URLs.Data flow (inputs, outputs, side effects)
baseDir path where posts are stored.Impact on overall application behavior and performance Enables user navigation through posts. Performance depends on the efficiency of getAllPosts. Output structure is optimized for grouping and rendering menus.
Potential points of failure or bottlenecks
getAllPosts fails, this service will also fail.Security, performance, or architectural concerns
Suggestions for improvement
rssFeedService.jsWhat it does Generates an RSS feed XML string for all blog posts, including metadata such as title, description, URL, and date.
Where it fits in the request/response lifecycle Used in serving the RSS feed endpoint, responding with XML content representing the blog's RSS.
Which files or modules directly depend on it RSS feed route handler/controller.
How it communicates with other modules or components
getAllPosts to retrieve all post metadata.rss package to build RSS XML.Data flow (inputs, outputs, side effects)
Impact on overall application behavior and performance Allows RSS readers to consume blog content. The feed generation depends on retrieving all posts, which can be costly for large datasets.
Potential points of failure or bottlenecks
Security, performance, or architectural concerns
Suggestions for improvement
sitemapService.jsWhat it does Generates a comprehensive sitemap data structure combining static pages, blog posts, and tags. Provides utilities to flatten sitemap entries and inject dynamic content into static sitemap templates.
Where it fits in the request/response lifecycle Serves the sitemap XML or JSON endpoint, aiding search engines in crawling the site.
Which files or modules directly depend on it Sitemap route handler/controller. Possibly used internally by tag or blog post listing pages.
How it communicates with other modules or components
getAllPosts utility for blog posts.fast-glob to find markdown files for tags extraction.Data flow (inputs, outputs, side effects)
Impact on overall application behavior and performance Critical for SEO and site indexing. Performance depends on number of files scanned and parsed. It consolidates disparate content types into a unified sitemap.
Potential points of failure or bottlenecks
Security, performance, or architectural concerns
Suggestions for improvement
Summary: All services operate primarily on filesystem-stored content, emphasizing careful file IO and parsing. None employ caching, which poses a clear scalability bottleneck. Security risks are mostly data exposure and validation weaknesses. Architectural improvements should include caching layers, database-backed storage where appropriate, and stricter validation.
MarkdownRoutes classWhat it does: Express router extension to serve pages rendered from Markdown files using frontmatter metadata and markdown content converted to HTML.
Where it fits: Used during HTTP GET request handling for static content routes.
Dependencies: Depends on BaseRoute (superclass), filesystem, gray-matter (frontmatter parser), and marked (markdown parser).
Communication: Input: HTTP request path. Output: rendered HTML page via response.
Data flow: Reads markdown file → parses frontmatter and content → converts content to HTML → passes context to template rendering → sends HTML response.
Impact: Enables dynamic serving of markdown-based pages with metadata.
Potential failure points:
Concerns: File I/O during request could be slow; no caching shown. May expose filesystem structure if errors leak paths.
Suggestions:
postFileUtils.js (partial code shown)What it does: Utilities related to post files including parsing frontmatter and content, generating excerpts, hashing posts, and fetching posts with optional filters.
Where it fits: Called during content retrieval or pre-processing phases for posts.
Dependencies: Uses gray-matter for frontmatter, hash function for content hashing, createExcerpt utility.
Communication: Input: base directory, options for post filtering. Output: array of post metadata objects.
Data flow: Reads files from filesystem → parses metadata and content → generates excerpts and hashes → returns structured data.
Impact: Facilitates post management and rendering preparation.
Potential failure points: File read errors, parsing errors, large directory scans causing delays.
Concerns: No explicit caching; performance may degrade with large post collections.
Suggestions:
This documentation strictly limits itself to the explicit code and context provided without speculation.
utils/postFileUtils.jsgetPosts(baseDir, { tags, sortByDate = false } = {})Purpose: Recursively retrieves all markdown (.md) files under a given baseDir, parses each for frontmatter metadata and content, optionally filters by tag, sorts by date, and returns structured post data.
Execution Lifecycle Position: Runs during content fetching for blog post listings or detail views.
Dependencies:
parseMarkdownFile, createExcerpt, hashfs, path, gray-matterData Flow:
.md files recursively from baseDirFor each file:
Filter by tag (if tags specified)
sortByDate === trueOutput:
[
{
slug: 'string',
title: 'string',
date: Date,
tags: ['string'],
excerpt: 'string',
hash: 'string'
},
...
]
Behavior/Performance Impact:
Failure Points:
date field results in incorrect sortSecurity/Architecture Concerns:
Suggestions:
slug, tags, title, and dateparseMarkdownFile(filePath)Purpose: Reads a markdown file from the filesystem, parses it with gray-matter, and returns metadata and content.
Data Flow: Input: Absolute file path Output: { data, content } from frontmatter and body
Failure Points:
Suggestions: Wrap fs.readFileSync with error handling; validate data keys explicitly.
createExcerpt(content)Purpose: Returns a substring from the first 200 characters of the markdown content (used for previews).
Behavior: Cuts off at 200 characters without regard for word boundaries or formatting.
Suggestions: Improve by stripping markdown syntax and cutting at word boundary or sentence break.
This completes the internal audit of all visible logic in the utilities, template helpers, logging, and error handling layers.