# Epic 3: Pre-Deployment, URL Generation & Interlinking ## Epic Goal To validate cloud storage targets, pre-calculate all final content URLs for a batch, and inject the required interlinks into the generated HTML content before deployment. ## Stories ### Story 3.1: Cloud Bucket Validation and Creation **As a developer**, I want a script that can check if a cloud storage bucket exists and create it if it doesn't, so that I can guarantee a valid deployment target before generating final URLs. **Acceptance Criteria** - The script accepts a target bucket name and cloud provider. - It first checks if the bucket already exists and is accessible with our credentials. - If the bucket does not exist, it attempts to create it. - The script returns a success status and the bucket's base URL if the bucket is ready. - The script returns a clear error and halts the process if the bucket name is taken or creation fails. ### Story 3.2: Batch URL Generation and Mapping **As a developer**, I want a module that generates the complete list of final URLs for all new articles in a batch, so that I have a map of all links needed for the interlinking process. **Acceptance Criteria** - The module takes a list of all generated article titles for a project batch. - It generates a predictable filename for each article (e.g., from the title). - Using the validated bucket base URL (from Story 3.1), it constructs the URL path for every new article. - When constructing the final URL, the module MUST first check the fqdn_mappings table. If a mapping exists for the target bucket, the custom FQDN is used as the base URL. Otherwise, the default provider base URL is used. - The module queries the target to find the URL of one random existing article (if any exist). - The module identifies the URL for the bucket's home page (index file). - It returns a complete "link map" object containing all new URLs, the existing article URL, and the home page URL. ### Story 3.3: Content Interlinking Injection **As a User**, I want the system to automatically insert a "wheel" of links into each new article, so that all content in the batch is interconnected for SEO purposes. **Acceptance Criteria** - A script takes the generated HTML content (from Epic 2) and the "link map" (from Story 3.2). - For each article, it correctly injects links to the next and previous articles in the batch, creating a "wheel" (e.g., Article 1 links to 2, 2 links to 1 & 3, 3 links to 2 & 4...). - Each article must also contain a link to the bucket's home page and the randomly selected existing article URL from the link map. - The script produces the final, interlinked HTML content, ready for deployment.