Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

HelloWorldImJoe/ai-writer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Writer

This repository contains two main pieces of the AI Writer project:

  • AI_Writer_Client – a Next.js application that provides the user interface.
  • AI_Writer_Service – a Cloudflare Worker service that hosts the API and business logic.

The client talks to the service via /api routes and the service relies on a single secret (SCREET_KEY) for authorization and other environment configuration.


📁 Repository layout

/ai-writer
  ├── AI_Writer_Client/      # Next.js frontend
  ├── AI_Writer_Service/     # Cloudflare Worker backend
  └── README.md              # (this file)

Both sub‑projects are independent; you can run them side‑by‑side or deploy them separately.


🔧 Prerequisites

  • Node.js (v16+ recommended)
  • npm or yarn
  • Wrangler 3 (for Cloudflare Worker deployment)
  • A Cloudflare account with Workers & KV namespace if you intend to deploy the service

🧩 Configuration & environment variables

Project File Variables Notes
Client .env.local GEMINI_API_KEY Gemini / LLM provider key used by the UI
Service .dev.vars (local) or Worker secrets SCREET_KEY Primary secret used by getSecretKey()

Security: never commit secrets to git. .dev.vars is currently in the repo and should be added to .gitignore immediately; rotate SCREET_KEY and treat it as leaked.

To set a Worker secret with Wrangler:

wrangler secret put SCREET_KEY

Other configuration (e.g. database URL, KV names) lives in AI_Writer_Service/src/env.ts and the accompanying Typescript declarations; update as needed.


🚀 Running locally

Client

cd AI_Writer_Client
npm install
# add your Gemini key to .env.local
npm run dev

The UI will start on http://localhost:3000 by default and proxy /api requests to the Worker if configured accordingly (see next.config.ts).

Service

cd AI_Writer_Service
npm install
# create a local .dev.vars with SCREET_KEY and any other secrets
# example:
#   SCREET_KEY="your_dev_key"
npm run dev           # starts a local Miniflare server

The service will listen on http://localhost:8787 and exposes the same endpoints used by the client.

To run the database migrations (SQLite/D1) use the scripts in migrations/.


📦 Deployment

Client

Typical Next.js deployment (Vercel, Netlify, etc.). Make sure to set GEMINI_API_KEY in the host's environment.

Service

Use Wrangler to publish the Worker, e.g.:

cd AI_Writer_Service
wrangler deploy --env production

Configure KV namespaces and Worker secrets via the wrangler.toml/wrangler.json or through the dashboard.

Make sure to update the client’s next.config.ts API_URL to point at the published Worker.


🛡️ Secrets management

  • Do not commit .dev.vars or `.env.local
  • Rotate SCREET_KEY if it has been exposed.
  • Consider using a vault or CI secret store for production values.
  • Add a git pre‑commit hook or CI check (e.g. git-secrets) to prevent accidental leaks.

✅ Quick start checklist

  1. Clone the repo
  2. Install dependencies in both /AI_Writer_Client and /AI_Writer_Service
  3. Create local environment files
  4. Start the service with npm run dev inside AI_Writer_Service
  5. Start the client with npm run dev inside AI_Writer_Client

📚 Further reading

  • AI_Writer_Client/README.md – client‑specific instructions (UI, design tokens, etc.)
  • AI_Writer_Service/AGENTS.md – architecture notes for the backend agents
  • AI_Writer_Service/migrations – database schema history

🤝 Contributing

Feel free to open issues or pull requests. Ensure any new configuration is documented here and no secrets are checked in.


Generated by GitHub Copilot

About

AI作家

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages