100 lines
2.0 KiB
Markdown
100 lines
2.0 KiB
Markdown
# 🐱 CatSave - Go + Next.js Monorepo
|
|
|
|
Single binary application with Go backend + Next.js frontend.
|
|
|
|
## 📦 Structure
|
|
|
|
```
|
|
catsave/
|
|
├── apps/
|
|
│ ├── web/ # Next.js frontend (static export)
|
|
│ └── server-go/ # Go backend + static file server
|
|
├── scripts/ # Build scripts
|
|
└── dist/ # Build output
|
|
```
|
|
|
|
## 🚀 Development
|
|
|
|
### Quick Start
|
|
```bash
|
|
# 1. Install dependencies
|
|
npm install
|
|
|
|
# 2. Option A: Dev Next.js only
|
|
npm run dev:web # http://localhost:3000
|
|
|
|
# 3. Option B: Dev with Go
|
|
npm run build:dev # Build Next.js + sync to Go
|
|
npm run dev:go # Run Go server
|
|
```
|
|
|
|
### Workflow
|
|
|
|
**Frontend Development (Next.js):**
|
|
```bash
|
|
npm run dev:web # Hot reload on :3000
|
|
```
|
|
|
|
**Full Stack Development (Next.js + Go):**
|
|
```bash
|
|
# Terminal 1: Build & sync on changes
|
|
npm run build:dev
|
|
|
|
# Terminal 2: Run Go server
|
|
npm run dev:go # http://localhost:8080
|
|
```
|
|
|
|
**After changing Next.js code:**
|
|
```bash
|
|
npm run build:dev # Re-build and sync
|
|
# Go server will auto-serve new files
|
|
```
|
|
|
|
## 🔨 Build
|
|
|
|
### Development Build (Quick)
|
|
```bash
|
|
npm run build:dev
|
|
# → Builds Next.js + syncs to Go static folder
|
|
```
|
|
|
|
### Production Binary
|
|
```bash
|
|
npm run build
|
|
# → Builds Next.js + Go binary
|
|
# → Output: dist/catsave (single binary)
|
|
```
|
|
|
|
### Available Commands
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `npm run dev:web` | Dev Next.js only (port 3000) |
|
|
| `npm run dev:go` | Run Go server (port 8080) |
|
|
| `npm run build:web` | Build Next.js static export |
|
|
| `npm run sync:static` | Copy Next.js → Go static |
|
|
| `npm run build:dev` | Build + sync (development) |
|
|
| `npm run build` | Full production build |
|
|
|
|
## 🎯 Deploy
|
|
|
|
```bash
|
|
# Just copy the binary
|
|
./dist/catsave
|
|
|
|
# Runs on http://localhost:8080
|
|
```
|
|
|
|
## 🏗️ Architecture
|
|
|
|
- **Go**: API + serve static files (embedded)
|
|
- **Next.js**: Static export (HTML/CSS/JS)
|
|
- **Result**: One binary file (~10-30MB)
|
|
|
|
## 📝 Tech Stack
|
|
|
|
- Go 1.21+
|
|
- Next.js 14
|
|
- TypeScript
|
|
- Tailwind CSS
|
|
|