Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Jul 28, 2025

  • added CDN for large assets with fallback to static assets
  • remove video assets from docs

Description

add cdn for large video assets with fallback to static assets, serves assets much faster in email templates and docs and is cheaper as well

Type of change

  • Performance improvement

How Has This Been Tested?

Tested manually to ensure we can read assets from public blob.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

Additional Information:

  Main app (apps/sim/public/):
  - demo.gif: 35MB
  - Social media images: ~5MB
  - Subtotal: ~40MB

  Docs app (apps/docs/public/):
  - 20 MP4 documentation videos: ~300MB
  - Subtotal: ~300MB

  Total savings: ~340MB

  Current repository sizes:
  - apps/sim/public/: 4.5MB (down from ~44.5MB)
  - apps/docs/public/: 4.0MB (down from ~304MB)

@vercel
Copy link

vercel bot commented Jul 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 7:10pm
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 7:10pm

@@ -1,5 +1,5 @@
<p align="center">
<img src="apps/sim/public/static/sim.png" alt="Sim Studio Logo" width="500"/>
<img src="https://nwkhgj772h6t23m2.public.blob.vercel-storage.com/static/sim.png" alt="Sim Studio Logo" width="500"/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meant to be public, just incl our assets and generic images/videos

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR implements a comprehensive CDN solution for large static assets to improve performance and reduce repository size. The changes introduce a new getAssetUrl utility function that provides intelligent asset delivery with fallback capabilities - assets are served from Vercel Blob Storage CDN when the NEXT_PUBLIC_BLOB_BASE_URL environment variable is configured, otherwise falling back to local static assets.

The implementation spans multiple areas of the codebase:

  1. Environment Configuration: Added NEXT_PUBLIC_BLOB_BASE_URL to the environment variables in apps/sim/lib/env.ts with proper validation and runtime environment mapping

  2. Security Configuration: Updated Content Security Policy (CSP) in apps/sim/lib/security/csp.ts to allow image loading from https://*.public.blob.vercel-storage.com

  3. Utility Functions: Created getAssetUrl functions in both apps/sim/lib/utils.ts and apps/docs/lib/utils.ts that handle CDN URL construction with fallback logic

  4. Email Templates: Updated all email components (OTP verification, workspace invitation, reset password, invitation) to use the new CDN system for logos and images

  5. Landing Page Components: Modified testimonials and blog sections to serve social media images and avatars through the CDN

  6. Application Layout: Updated the main app layout's social media metadata images to use CDN URLs

  7. Documentation: Updated README.md to directly reference CDN URLs for the logo and demo.gif

The solution achieves significant repository size reduction - from ~44.5MB to 4.5MB for the main app and ~304MB to 4MB for docs, totaling ~340MB savings. The architecture maintains backward compatibility through fallback mechanisms, ensuring the application continues to work in environments where CDN isn't configured.

Confidence score: 3/5

• This PR introduces significant infrastructure changes that could impact asset loading across the entire application
• The score reflects concerns about incomplete implementation in some areas and potential runtime errors if environment variables aren't properly configured
• Files requiring more attention: apps/sim/components/emails/workspace-invitation.tsx and all email templates for potential runtime issues if CDN configuration fails

13 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 510ce4b into staging Jul 28, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/CDN branch July 29, 2025 00:06
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…tic assets (simstudioai#809)

* added CDN for large assets with fallback to static assets

* remove video assets from docs

---------

Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants