# CryptoEditorial — Local Edition

Aplikasi crypto investment platform dengan AI Analyzer (Gemini 3 Pro), Live Markets, Portfolio Tracker, dan Daily Newsletter — untuk dijalankan di **Windows lokal** (Laragon / VS Code / Docker).

---

## 🚀 Cara Menjalankan (Pilih Salah Satu)

### A. Cara Cepat — Klik 2 kali (Recommended untuk Pemula)
1. Pasang dependency satu kali (lihat **`INSTALL_WINDOWS.md`**)
2. Edit `backend/.env` dan `frontend/.env` (copy dari `.env.example`)
3. Klik 2 kali **`start_all.bat`** → backend + frontend otomatis terbuka, browser akan launch

### B. Pakai Laragon
Lihat **`LARAGON_SETUP.md`** — panduan langkah demi langkah memakai Laragon untuk auto-start backend & frontend sebagai services.

### C. Pakai Docker Desktop
```bash
docker compose up
```
Lihat **`INSTALL_WINDOWS.md`** bagian Docker.

---

## 📁 Struktur Folder

```
crypto-editorial-local/
├── backend/                  # FastAPI backend (Python)
│   ├── server.py             # main app — semua API endpoint
│   ├── requirements.txt      # Python dependencies
│   ├── .env.example          # template environment variables
│   └── start_backend.bat     # launcher backend (auto-create venv & install)
│
├── frontend/                 # React frontend (CRA + Tailwind)
│   ├── src/                  # source code
│   ├── package.json
│   ├── .env.example
│   └── start_frontend.bat    # launcher frontend
│
├── start_all.bat             # Launch keduanya (rekomendasi)
├── stop_all.bat              # Stop semuanya
├── docker-compose.yml        # Alternatif Docker
├── README.md                 # File ini
├── INSTALL_WINDOWS.md        # Panduan instalasi detail
├── LARAGON_SETUP.md          # Setup spesifik Laragon
└── .gitignore
```

---

## ⚙️ Konfigurasi Environment Variables

Sebelum aplikasi jalan, isi file `.env` (copy dari `.env.example`):

### `backend/.env` — wajib diisi:

| Variable | Deskripsi | Cara dapat |
|----------|-----------|------------|
| `JWT_SECRET` | Random string 64 karakter hex | `python -c "import secrets;print(secrets.token_hex(32))"` |
| `EMERGENT_LLM_KEY` | Key untuk Gemini 3 Pro | Dari Profile → Universal Key di [emergent.sh](https://emergent.sh) |
| `RESEND_API_KEY` | Key untuk newsletter | [resend.com](https://resend.com) → API Keys |
| `MONGO_URL` | URL MongoDB | Default `mongodb://localhost:27017` |
| `ADMIN_PASSWORD` | Password admin awal | Bebas (default `Admin123!`) |
| `COINGECKO_API_KEY` | (opsional) Demo key | [coingecko.com/api](https://www.coingecko.com/en/api/pricing) → free Demo plan |

### `frontend/.env`:
Cukup pakai default — sudah set `REACT_APP_BACKEND_URL=http://localhost:8001`.

---

## 🌐 URL setelah running

- **Aplikasi**: http://localhost:3000
- **API Backend**: http://localhost:8001/api
- **Newsletter Preview**: http://localhost:8001/api/newsletter/preview
- **MongoDB**: `localhost:27017` (default port)

### Login admin default:
- Email: `admin@cryptoeditorial.local`
- Password: `Admin123!` (atau yang Anda set di `.env`)

---

## 🐛 Troubleshooting Singkat

| Masalah | Solusi |
|---------|--------|
| `python` tidak dikenali | Install Python 3.11+ dari [python.org](https://python.org), centang "Add to PATH" |
| `yarn` tidak dikenali | `npm install -g yarn` |
| Backend error: `MONGO_URL` | Pastikan MongoDB running. Cek dengan `mongosh` |
| `CORS` error di browser | Pastikan `CORS_ORIGINS=http://localhost:3000` di `backend/.env` |
| `pip install` gagal | Pakai `--extra-index-url https://d33sy5i8bnduwe.cloudfront.net/simple/` (untuk emergentintegrations) |
| Login gagal terus | Pastikan `COOKIE_SECURE=false` dan `COOKIE_SAMESITE=lax` di `backend/.env` |
| CoinGecko rate limit | Daftar Demo key gratis & isi `COINGECKO_API_KEY` |

Detail lengkap di **`INSTALL_WINDOWS.md`** bagian Troubleshooting.

---

## 📜 Lisensi & Disclaimer

Aplikasi ini untuk tujuan edukasi. Bukan nasihat finansial.
Selalu lakukan riset Anda sendiri sebelum berinvestasi crypto.
