跳到正文
DEV Community· Jyothish Nalinakshan·· 4 小時前AI 評分40

Cosmic Postcard:結合 NASA APOD 與 Amazon Bedrock 構建自主 AI 智能體

Cosmic Postcard: Building an Autonomous AI Agent with NASA APOD and Amazon Bedrock

AI 導讀

Cosmic Postcard 結合 NASA APOD、Amazon Bedrock 及 AWS 無伺服器服務,每日自動生成並發布一張以天文發現為靈感的數碼明信片。明信片包含標題、詩意訊息和智能體反思,並連同 NASA 原始圖片及科學説明一併保存。網頁應用程式會展示最新明信片及相關資訊。

正文

What if an AI agent could explore the universe every day and turn NASA's Astronomy Picture of the Day into a creative digital postcard — without anyone needing to press a button?

That idea became Cosmic Postcard, an autonomous creative agent that combines NASA's Astronomy Picture of the Day (APOD), Amazon Bedrock, and AWS serverless services to generate and publish a new cosmic postcard every day.

The agent retrieves the latest astronomical discovery, interprets it creatively using generative AI, and stores the result for a web application to display.

No manual prompts. No daily intervention. Just a new postcard inspired by the universe.

🌠 The Vision

NASA's Astronomy Picture of the Day provides incredible images and scientific explanations about the universe.

I wanted to build something that added a creative layer to that experience.

Cosmic Postcard takes the daily discovery and uses AI to generate three creative elements:

Postcard title — a short, memorable title inspired by the discovery.

Poetic message — a creative interpretation of the astronomical image.

Agent reflection — a short reflection inspired by the discovery and its scientific context.

The original NASA image and scientific description remain available alongside the generated content. The AI-generated postcard complements the original discovery rather than replacing it.

For example, one discovery was titled The Sky Turns Above Paranal. The agent transformed it into a postcard called “Whispers of Paranal,” accompanied by a poetic interpretation and a reflection about Earth's rotation and the night sky.

The goal is simple: create a small digital postcard collection that evolves with NASA's daily discoveries.

🏗️ Architecture Overview

I designed Cosmic Postcard as a lightweight, event-driven serverless application.

   Amazon EventBridge
    (Daily Schedule)
            |
            v
       AWS Lambda
    (Postcard Agent)
            |
    +-------+--------+
    |                |
    v                v
 NASA APOD      Amazon Bedrock

Image + Data Generative AI
| |
+-------+--------+
|
v
Amazon S3
+----------------+
| latest.json |
| latest.jpg |
+----------------+
|
v
Cosmic Postcard
Web App

Each service has a specific responsibility:

Amazon EventBridge schedules the workflow.

AWS Lambda orchestrates the postcard-generation process.

NASA APOD provides the astronomical image and discovery information.

Amazon Bedrock generates the creative content.

Amazon S3 stores the image and generated JSON.

The web frontend displays the latest postcard.

⚙️ How I Built It

  1. Retrieving NASA's Astronomy Picture of the Day

The first step was connecting the application to NASA's APOD data.

The Lambda function retrieves the daily discovery information and downloads the corresponding image.

This provides the factual foundation for each postcard and ensures the AI has real astronomical content to work with.

  1. Generating Creative Content with Amazon Bedrock

Next, I integrated Amazon Bedrock into the workflow.

Instead of using a generic chatbot-style prompt, I structured the model request around the NASA discovery and asked it to produce predictable creative fields:

Title

Postcard message

Reflection

This structure makes it easier to process the generated content and display it consistently in the frontend.

  1. Storing the Postcard in Amazon S3

Once the AI generates the postcard, Lambda combines the generated content with the NASA metadata into a JSON document.

Amazon S3 stores two important outputs:

latest.json
latest.jpg

latest.json contains the postcard content and associated metadata, while latest.jpg stores the downloaded NASA image.

Keeping the outputs in predictable locations makes it straightforward for the frontend to retrieve the latest postcard.

  1. Displaying the Result

The frontend is a lightweight application built with HTML, CSS, and JavaScript.

It retrieves latest.json and dynamically renders the latest postcard alongside the associated image and scientific information.

The result is a public-facing application that presents the latest AI-generated cosmic postcard without requiring users to run the project locally.

☁️ AWS Services Used

Service

Responsibility

AWS Lambda

Executes the postcard-generation workflow

Amazon EventBridge

Triggers the workflow daily

Amazon Bedrock

Generates the creative postcard content

Amazon S3

Stores latest.json and latest.jpg

AWS IAM

Controls permissions for AWS resources

Amazon CloudWatch

Provides execution logs and debugging information

NASA APOD API

Supplies astronomical images and discovery metadata

HTML, CSS, JavaScript

Power the frontend interface

🧩 Challenges and Debugging

Building the application required more than connecting an AI model to an API.

I encountered several integration challenges involving Lambda execution permissions, S3 access, browser CORS behavior, Function URL configuration, and the EventBridge trigger.

One particularly useful debugging experience occurred when the backend was successfully generating postcards and saving them to S3, but the frontend could not retrieve the expected data.

Instead of assuming the entire application was broken, I investigated the browser console, Lambda responses, S3 access configuration, and CloudWatch logs.

This helped me isolate the issue to the data-access configuration rather than the generation workflow itself.

That experience reinforced an important lesson: observability is essential when building applications from multiple cloud services.

Each component may work independently while the complete application still fails because of the connection between components.

🧠 What I Learned

This project helped me understand the complete lifecycle of an autonomous AI workflow:

Trigger → Data Retrieval → Processing → AI Generation → Storage → Delivery → Monitoring

My main takeaways were:

Designing event-driven serverless applications with AWS Lambda and EventBridge.

Integrating generative AI into a practical application using Amazon Bedrock.

Retrieving external data and combining it with AI-generated content.

Persisting images and structured data in Amazon S3.

Debugging access permissions, CORS, and service integration issues.

Using CloudWatch logs to understand execution behavior.

Separating the frontend from the backend to simplify deployment.

Most importantly, this project changed how I think about autonomous applications.

An AI agent does not necessarily need to be a complicated system. Even a relatively small workflow can operate autonomously when it can receive a trigger, retrieve information, generate content, persist the result, and continue running without manual intervention.

🚀 What's Next?

There are several ways I could extend Cosmic Postcard:

Historical archive: Build a collection of previously generated postcards.

Discovery explorer: Allow users to browse earlier NASA APOD images.

Creative styles: Generate different interpretations of the same discovery.

Email delivery: Send the daily postcard to subscribers.

Social sharing: Make postcards easier to share.

Improved content delivery: Explore Amazon CloudFront for a more production-ready delivery architecture.

Multiple interpretations: Let users explore different creative perspectives on the same astronomical discovery.

For this project, however, the original goal was simple: build something that wakes up every day, looks at the universe, and writes a postcard about what it finds.

And now it does.

🌌 Try Cosmic Postcard

Explore the live application and source code:

Live Demo: Cosmic Postcard — the public application displaying the latest generated postcard.

GitHub: The project repository contains the frontend and project documentation.

🏁 Final Thoughts

Cosmic Postcard started with an idea: combine the wonder of NASA's daily astronomical discoveries with the creativity of generative AI.

By connecting NASA APOD, Amazon Bedrock, AWS Lambda, Amazon EventBridge, and Amazon S3, I built an autonomous workflow that transforms astronomical discoveries into creative digital postcards.

The project demonstrates that AI applications do not always need to wait for a user interaction. With the right event-driven architecture, they can work in the background and prepare something new to discover every day.

The universe provides the inspiration. NASA provides the discovery. AWS provides the automation. Generative AI adds the creative perspective.

And every day, Cosmic Postcard finds something new to share.

Inspired by @benfowleraws for creating the Weekend Challenge and encouraging builders to turn their summer projects into something worth sharing.

來源:DEV Community · dev.to