Docsy is a hackathon-ready AI document workflow agent built on top of the Markdown Muse editor.
It focuses on one core interaction:
- a user edits a technical document
- Gemini analyzes document context
- the system proposes a structured action or patch
- the user reviews the change before applying it
Technical documentation usually breaks in the same places:
- procedures drift across documents
- updates are applied to one file but not related files
- AI can draft text, but it rarely returns reviewable actions
Docsy is designed to show a different pattern:
- document-aware editing
- review-first AI patch workflow
- Gemini-powered structured output
- a path to multimodal reasoning with editor screenshots
This repository is being prepared for a Gemini hackathon submission.
Current submission priorities:
- GenAI SDK based Gemini integration
- Cloud Run deployment for the AI service
- multimodal request path for editor screenshot + document context
- action-oriented JSON response from Gemini
- one real UI action wired from AI output
- review-first patch workflow demo
- Open multiple technical documents in the editor.
- Update a procedure in one document.
- Send document context and editor state to the AI service.
- Gemini returns a structured action or patch proposal.
- The app opens the patch review flow.
- The user accepts or rejects the change.
Docsy's deployed architecture uses a React + Vite frontend served from Firebase Hosting and a separate Node.js AI backend deployed on Cloud Run. The backend accesses Gemini on Vertex AI through the Google GenAI SDK, stores shared Google Workspace session and state data in Firestore, and brokers Google Docs/Drive plus LaTeX service requests without exposing credentials to the browser.
For hackathon submission, export the diagram below as a PNG and upload it via File Upload.
flowchart LR
U["User in Browser"] --> FE["Docsy Frontend<br/>React + Vite<br/>Firebase Hosting"]
FE -->|"/api"| API["Docsy AI Backend<br/>Node.js<br/>Cloud Run"]
FE -->|"document context<br/>viewport screenshot<br/>UI action request"| API
API -->|"Google GenAI SDK"| GEM["Gemini on Vertex AI"]
GEM -->|"structured JSON action<br/>patch proposal"| API
API -->|"assistant response<br/>patch data"| FE
API -->|"session + workspace state"| DB["Firestore"]
DB -->|"shared state lookup"| API
API -->|"OAuth + Docs/Drive operations"| GW["Google OAuth + Google Docs/Drive"]
GW -->|"auth callback + document data"| API
API -->|"TeX preview / validate / export"| TEX["TeX Service<br/>separate Cloud Run service"]
TEX -->|"job result / PDF / preview"| API
For more detail, see Hackathon Architecture and the GCP deployment guide.
src/ frontend editor, patch review UI, workspace panels
server/ Gemini-backed AI service for structured responses
docs/ engineering notes, plans, and architecture docs
PRD/ product requirement documents for the hackathon direction
public/ static web assets
- multi-document editor with tabs and workspace sidebar
- Markdown, LaTeX, HTML, JSON, and YAML editing
- document AST generation and structured patch handling
- Google Workspace connection, Google Docs import/export, and bound-document save
- AI-assisted summaries, section generation, TOC suggestions, and update proposals
- patch review dialog instead of silent document mutation
- local knowledge indexing and related document workflows
- version history and share/export flows
- Node.js 18+
- npm
npm installnpm run devCreate a local env file:
cp .env.example .env.localPowerShell:
Copy-Item .env.example .env.localSet at least:
GOOGLE_GENAI_USE_VERTEXAI=trueGOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_LOCATIONGEMINI_MODELGEMINI_FALLBACK_MODELAI_SERVER_PORTAI_ALLOWED_ORIGINVITE_AI_API_BASE_URL
Authenticate locally with Application Default Credentials:
gcloud auth application-default loginThen run:
npm run ai:serverThe AI service is prepared for Cloud Run.
Runtime contract:
PORTis provided by Cloud RunGOOGLE_GENAI_USE_VERTEXAI=trueGOOGLE_CLOUD_PROJECTselects the Vertex AI projectGOOGLE_CLOUD_LOCATIONselects the Vertex AI regionGEMINI_MODELselects the primary modelGEMINI_FALLBACK_MODELselects the fallback model used for model/quota failuresAI_ALLOWED_ORIGINcontrols allowed frontend originsAI_ALLOWED_ORIGINmust be an explicit frontend origin outside local development
Build and deploy pipeline:
Cloud Run auth:
- the runtime service account must have Vertex AI permissions
- the local API key path is no longer used for Cloud Run
Frontend deployment:
- when Firebase Hosting rewrites
/api/**to Cloud Run, setVITE_AI_API_BASE_URLto the deployed frontend origin - if you intentionally split frontend and API domains, set
VITE_AI_API_BASE_URLto the deployed API origin - if omitted in a non-localhost environment, the frontend falls back to same-origin
Health check:
GET /api/ai/health- returns configuration-level
configuredstate for the public AI runtime GET /api/internal/ai/healthincludesmodelandfallbackModelwhen called with the diagnostics tokennode scripts/check-ai-runtime-smoke.mjs --origin https://YOUR_HOSTis the runtime readiness check and fails whenPOST /api/ai/agent/turnreturnsagentStatus
Google OAuth production guard:
- set
GOOGLE_OAUTH_PUBLISHING_STATUS=testing|production - set
GOOGLE_WORKSPACE_SCOPE_PROFILE=restricted|reduced - deployed Google Workspace state now defaults to Firestore on Cloud Run so OAuth/session state is shared across instances
- Firebase Hosting rewrites only forward the
__sessioncookie to Cloud Run, so hosted workspace auth must use that cookie name in deployed HTTPS environments - the current deployed auth contract is documented in docs/current-workspace-auth-contract-2026-03-16.md
- run
npm run check:public-deploybefore public deploys to validate custom-domain and OAuth settings
npm run dev- start the Vite dev servernpm run ai:server- start the AI service locallynpm run build- desktop-oriented production buildnpm run build:web- web-oriented production buildnpm run preview- preview the web buildnpm run lint- run ESLintnpm run test- run Vitestnpm run typecheck:server- type-check server code
- Hackathon PRD
- Final submission package
- Hackathon implementation session summary
- Google Docs export session summary
- Google OAuth production migration runbook
- Security credential rotation runbook
- Edge and browser security runbook
- Docs index
- PRD index
- GCP deployment guide
- Vertex AI credentials are never exposed to the browser bundle.
- Gemini calls are routed through the server layer.
- The frontend sends document payloads to the AI service, while credentials stay in the server runtime and service account.
- Workspace state now defaults outside the repository, and
.data/is ignored to prevent token-bearing state from being committed.
This repository is under active hackathon preparation.
The current implementation already contains editor, patch review, and document analysis building blocks. The remaining work is focused on tightening the Gemini demo path: screenshot input, multimodal prompting, action JSON, and one end-to-end UI action.
