How aduboue/img-studio works
Main Components
• Frontend – The “app” directory contains page components, layouts, and UI components. There is a clear separation into “studio” pages (and their subdirectories for editing, generation, and library views) that provide the interactive user interface.
• API Endpoints – The “app/api” folder holds endpoints for various functionalities such as cloud storage actions, editing utilities, and third-party integrations (Google-auth, Imagen, Gemini, Vertex segmentation, Firestore actions, etc.). These endpoints serve as the bridge between the UI and backend services.
• Business Logic / Context – The “app/context” directory (with app-context.tsx) manages global state and likely supports communication between UI components and API routes.
• External Cloud Services:
• Cloud Build: Driven by “cloudbuild.yaml”, this component builds container images, triggered manually or on releases.
• Cloud Run: Hosts the containerized Next.js application. The README details deployment instructions for a Cloud Run service.
• Cloud Storage Buckets: Three buckets are used (for raw output content, shared library content, and configuration files).
• Firestore: Used as the database for storing application metadata with dedicated security rules.
• Identity-Aware Proxy (IAP) & OAuth: Provides secure access management to the deployed application.
• Load Balancer and Cloud DNS: Manage incoming traffic and SSL termination for the public facing endpoints.
• Artifact Registry: Hosts container images built via Cloud Build.
Out the Relationships and Interactions
• User Request Flow:
• A user’s web browser makes an HTTPS request.
• The request first goes through a Load Balancer (with SSL certification) and then via Cloud DNS.
• IAP intercepts the request to perform authentication before routing it to the Cloud Run service.
• Cloud Run Service:
• Once authenticated, the Cloud Run container (which runs the Next.js app) renders pages from the “studio” directory and serves API endpoints.
• The API endpoints invoke business logic (e.g., image editing or generation actions) and communicate with external services.
• External Communication:
• API endpoints call Google Cloud Storage for saving or retrieving generated images and configuration files.
• Integration with Vertex AI (Imagen, Gemini, and Vertex segmentation models) is triggered via the API endpoints to perform AI-based image processing.
• Firestore is queried for metadata storage and retrieval.
• Build Pipeline:
• Cloud Build is set up to monitor the GitHub repository and build the container image.
• Once built, the artifact is deployed to Cloud Run for serving the application.
Architectural Patterns and Technologies
• Separation of Concerns – The Next.js project cleanly separates UI components, API endpoints, and global context.
• Serverless Architecture – Cloud Run provides a managed container environment that scales based on traffic without requiring full infrastructure management.
• Microservices-like API Routing – The “app/api” folder organizes various API actions as individual endpoints which are then called by UI components.
• Integration with GCP Services – The design uses several GCP components (Cloud Build, Cloud Run, Firestore, Cloud Storage, IAP) coordinated to provide secure and scalable application services.
• CI/CD Pipeline – Cloud Build and related configuration files (Dockerfile, cloudbuild.yaml) suggest an automated build and deployment process.
Detail
• Your labels are specific – include role names and service names where appropriate (like the Cloud Run service, service accounts, etc.).
• Use annotations to indicate why certain components (like IAP or the Load Balancer) are configured in a particular way as per the infrastructure setup guide.