The Tech Stack for a Read-Heavy Gallery

Reza Nosrat, running the small studio RENOX, recently launched a side project: a bilingual (English/Persian) gallery of AI image prompts. This gallery, designed for tools like ChatGPT, Sora, and Midjourney, is available for free browsing at rnosrat.com/prompts. The core of the project's success lies in its deliberate and cost-effective technology choices, prioritizing speed and simplicity for a read-heavy application.

The backend is powered by PHP 8 coupled with SQLite, hosted on shared LiteSpeed infrastructure. This combination eliminates the need for a complex build step, keeps hosting costs low, and provides sufficient performance for a gallery that primarily serves content to users rather than handling heavy transactional loads. For the frontend, Nosrat opted for Vanilla JavaScript, focusing on light progressive enhancement rather than a full-blown framework. This approach ensures a lean, fast user experience without the overhead associated with larger JavaScript libraries or frameworks.

A key feature is its Progressive Web App (PWA) capabilities. By incorporating a web manifest and a service worker, the gallery can be installed directly onto users' devices, offering an app-like experience. Crucially, this PWA architecture enables offline access to the prompts, a significant advantage for users who may have intermittent internet connectivity or wish to browse the curated collection without being online.

Screenshot of the bilingual AI image prompt gallery homepage

Why SQLite Was the Right Choice

The decision to use SQLite for a catalog of several hundred AI image prompts was a strategic one. Unlike more complex database systems, SQLite is a self-contained, serverless, transactional SQL database engine. For a read-heavy application like a prompt gallery, where the primary operation is retrieving data rather than frequent writes or complex joins, SQLite offers several advantages:

  • Simplicity and Zero Configuration: SQLite databases are stored as a single file, making them incredibly easy to manage and deploy, especially on shared hosting environments where installing and configuring full database servers might be restricted or impractical.
  • Performance for Read Operations: For straightforward queries to fetch prompt details, SQLite is remarkably fast. Its architecture is optimized for single-user access or scenarios with low concurrency, which perfectly matches the usage pattern of a public gallery.
  • Cost-Effectiveness: Utilizing SQLite on shared hosting significantly reduces infrastructure costs compared to running dedicated database servers or managed database services. This aligns with Nosrat's goal of a low-cost, sustainable side project.
  • No Build Step Required: As mentioned in the stack, the PHP 8 + SQLite combination means there's no complex build pipeline. This simplifies deployment and maintenance, allowing for direct file uploads to the server for updates.

Nosrat emphasized that for a catalog of this size and nature, the overhead of a full-fledged database like PostgreSQL or MySQL would be unnecessary. SQLite provides all the necessary relational database functionality without the added complexity, resource requirements, and cost.

Progressive Web App: Offline Access and Installability

The PWA implementation is central to the gallery's user experience. By leveraging a web manifest and a service worker, the application transcends the traditional limitations of web browsing.

  • Web Manifest: This JSON file provides metadata about the application, such as its name, icons, and display mode. It allows the browser to offer users the option to "Add to Home Screen" or "Install" the app, making it feel more like a native application.
  • Service Worker: This is a JavaScript file that runs in the background, separate from the web page. It acts as a programmable network proxy. For this gallery, the service worker intercepts network requests and enables caching of assets (like prompt data, images, and CSS/JS files). This caching is what allows users to access the prompt gallery even when they are offline. When a user first visits the site while online, the service worker caches the necessary resources. Subsequent visits, even without an internet connection, can serve these cached resources, providing a seamless offline browsing experience.

This PWA approach significantly enhances user engagement. It provides a more integrated experience on mobile devices, akin to native apps, while ensuring that the core functionality—browsing prompts—remains accessible regardless of network conditions. This is particularly valuable for users who might be on the go or in areas with unreliable internet.

Bilingual Support: Enhancing Accessibility

The bilingual nature of the gallery, supporting both English and Persian, is a deliberate choice to broaden its accessibility and utility. This wasn't achieved through complex internationalization (i18n) libraries but through a straightforward method suitable for the project's scale.

For a gallery of a few hundred prompts, managing translations directly within the data source (SQLite) is efficient. Each prompt entry can store both its English and Persian descriptions, keywords, and the prompt text itself. The frontend JavaScript then dynamically displays the appropriate language based on the user's browser settings or an explicit language switcher. This avoids the overhead of complex i18n frameworks, keeping the codebase lean and maintainable. The choice of Persian is likely due to the developer's background or a specific target audience, making the resource more relevant and useful to that community.

This thoughtful implementation of bilingual support ensures that users from different linguistic backgrounds can effectively utilize the prompt gallery, democratizing access to AI art generation tools and techniques.

Lessons Learned and Future Considerations

Nosrat's approach demonstrates that powerful, user-friendly web applications don't always require massive, complex stacks. The project highlights several key takeaways:

  • Right Tool for the Job: Choosing technologies that match the application's needs—in this case, a read-heavy, content-focused gallery—is crucial for efficiency and cost-effectiveness. PHP and SQLite on shared hosting are perfectly adequate here.
  • Value of PWAs: Even simple websites can benefit immensely from PWA features like offline access and installability, enhancing user experience and engagement.
  • Simplicity in i18n: For smaller projects, direct data management of translations can be more practical than adopting heavy internationalization libraries.

The project serves as a practical example for other developers looking to build similar content-focused applications or tools. It proves that with careful planning and judicious technology selection, one can create valuable, performant, and accessible web experiences without significant investment in complex infrastructure.