🦄 Project Log: Upgrading My Unicorn Text Project (April 2025)
🚀 Overview
This project connects a Pimoroni Galactic Unicorn Pico W to a Google Cloud Platform (GCP) serverless API that controls the scrolling text remotely.
- Backend: Node.js, Express.js, Firestore (GCP)
- Frontend: Simple HTML/JS (eventually!)
- Deployment: Cloud Run with Cloud Build
- Security: Bearer Token Authorization + Secret Manager
- Storage: Firestore Database
🛠️ Main Changes and Improvements
1. Local Pico W Development Setup
- Installed
mpremote
for flashing and file management. - Created a
deploy.sh
script to easily push code to the Pico. - Setup
.env
secrets for WiFi credentials and server URLs. - Used Micropython firmware.
- Created a pretty console output when deploying.
- MicroPython Docs
2. Backend (Cloud Run API) Improvements
- Split project into
app.js
(Express app) andserver.js
(listener). - Why split app.js and server.js?
- Proper CORS setup to allow frontend to talk to backend.
- Centralized Firebase Admin SDK initialization (
utils/firebase.js
).
3. Firestore Data Improvements
- Structured Firestore documents to include:
text
(display text)updatedAt
(server-side timestamp)updatedBy
(who set the text)
- Logged every update into a Firestore subcollection
history
.
4. Secrets Management (Security)
- Switched from environment variables to GCP Secret Manager.
- Fixed service account permissions for secrets access.
- GCP Secret Manager Docs
5. Frontend Changes (WIP)
- Created a basic frontend for text updates.
- Handled CORS properly.
- Added Bearer Token headers to secure API requests.
📋 Final Tech Stack Overview
- Hardware: Pico W (Galactic Unicorn)
- Firmware: MicroPython
- Local Dev Tools: mpremote, VS Code
- Backend: Node.js, Express, Firestore
- Authentication: Bearer Tokens
- Secrets: GCP Secret Manager
- Hosting: Cloud Run (serverless)
- Database: Firestore (NoSQL)
- Frontend: Basic HTML/JS
📚 Key Links for Future Reference
- Micropython Docs
- Express Middleware Basics
- Understanding CORS
- Google Cloud Run Docs
- Google Secret Manager Docs
- Firestore Subcollections Guide
🧠Lessons Learned
- CORS must be handled before mounting routes.
- Always explicitly initialize Firebase Admin SDK.
- Structured Firestore data makes future features easier.
- Logging to console and audit trails are essential for debugging.
🚀 Future Ideas
- Add
/history
API endpoint to view full update logs. - Prettify the frontend to show timestamps and usernames.
- Setup OAuth login instead of bearer token for future users.
- Deploy frontend separately (Netlify, Firebase Hosting).
- GitHub Actions for auto-deploy on commit.
🦄 Final Thoughts
This is no longer just a toy project — it's a scalable, secure, audit-logged cloud-connected Unicorn 🦄 system! With a real API, real secret management, history tracking, and easy extensibility — Ready for next steps whenever I pick it back up again!