Skip to content

About

Mini – minimal algo – algorithmic trading tron – techy / modular / monorepo-ish vibe (like electron, monotron) ify – implies transformation or automation licious – because of course 😎

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

36 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

totally. here’s the clean mental model + the exact steps so you don’t lose the thread.

1) Local dev: Docker vs plain npm run dev

You have two good modes:

Mode A — Plain local (fast feedback; minimal moving parts)

Use this when you’re iterating on UI/logic.

  • Terminal 1 (backend):

    cd apps/backend
    python -m venv .venv && source .venv/bin/activate  # first time only
    pip install -r requirements.txt
    # make sure your app listens on localhost:8000 and CORS allows http://localhost:3003
    uvicorn main:app --host 0.0.0.0 --port 8000 --reload
  • Terminal 2 (frontend):

    cd apps/ui
    npm install   # or pnpm install
    # .env.local (frontend):
    # NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
    npm run dev -- -p 3003
    # open http://localhost:3003

Notes:

  • No Docker here. Faster boot; easier debugging.
  • You don’t need BACKEND_INTERNAL_URL locally unless some SSR code uses it; if it does, set it to the same URL: http://localhost:8000.

Mode B — Docker compose (prod-ish parity)

Use this to test the exact container setup you’ll deploy.

make fresh
# frontend → http://localhost:3003
# backend  → http://localhost:5000 (host), health at /health

Notes:

  • Compose wires the UI to the backend container name internally; you already have healthchecks and ports set.
  • Slightly slower to rebuild but matches deployment closer.

👉 For day-to-day speed, go with Mode A. Flip to Mode B before pushing / debugging infra issues.


2) Deploy to Render (free tier)

You’ll create two services on Render, both pointing at your GitHub repo (monorepo-aware):

  • Backend: FastAPI → Render “Web Service” (Python)
  • Frontend: Next.js → Render “Web Service” (Node) (Use Web Service, not Static Site, because you’ve got SSR/env vars.)

Preflight (tiny code tweaks)

  • Ensure your backend binds to Render’s port:

    # Start command (Render):
    uvicorn main:app --host 0.0.0.0 --port $PORT
  • Ensure your frontend production start uses $PORT and 0.0.0.0:

    // apps/ui/package.json
    {
      "scripts": {
        "build": "next build",
        "start": "next start -H 0.0.0.0 -p ${PORT:-3000}"
      }
    }

    (Dev script doesn’t matter for Render.)

A) Backend service (Python Web Service)

  1. In Render dashboard → New → Web Service → pick your repo.

  2. Root Directory: apps/backend

  3. Runtime: Python

  4. Build Command: pip install -r requirements.txt

  5. Start Command: uvicorn main:app --host 0.0.0.0 --port $PORT

  6. Environment: set these (you can tweak later):

    • FRONTEND_ORIGINS → set to your frontend URL (temporarily leave blank; we’ll fill after frontend URL exists)
    • CORS_ALLOW_METHODS → GET,POST,PUT,PATCH,DELETE,OPTIONS
  7. (Optional) Health Check Path: /health (so Render knows it’s healthy)

  8. Click Create Web Service. Note the URL: https://your-backend.onrender.com.

B) Frontend service (Node Web Service)

  1. New → Web Service

  2. Root Directory: apps/ui

  3. Runtime: Node

  4. Build Command: npm ci && npm run build

  5. Start Command: npm run start

  6. Environment:

    • NODE_ENV=production
    • NEXT_PUBLIC_BACKEND_URL=https://your-backend.onrender.com
    • (If SSR/server code uses it) BACKEND_INTERNAL_URL=https://your-backend.onrender.com
  7. Create it. Note the URL: https://your-frontend.onrender.com.

C) Circle back to backend CORS

Update backend env:

  • FRONTEND_ORIGINS=https://your-frontend.onrender.com
  • Redeploy backend from Render dashboard.

D) WebSockets?

  • If you use WS from the browser, your NEXT_PUBLIC_BACKEND_URL must be paired with wss:// for WS endpoints (or derive WS URL in code).
  • Render free supports WS; just be sure you’re using wss://your-backend.onrender.com/ws in prod.

E) Free plan quirks (so you’re not surprised)

  • Sleep after ~15 minutes of inactivity; requests “cold start” your services.
  • Monthly free time is capped; watch quotas.
  • Build time also counts toward free quota.
  • Custom domains work (you add in Settings), but keep using the onrender.com URL in env until DNS is set.

Monorepo gotchas + nice-to-haves

  • Render’s “Root Directory” must point to apps/backend and apps/ui respectively.

  • If you use pnpm locally, Render’s Node builder defaults to npm. Either keep using npm or add:

    // apps/ui/package.json
    "packageManager": "pnpm@9"

    and set Build Command to pnpm i --frozen-lockfile && pnpm build. (Sticking to npm is simpler on free.)

  • Make sure your Next build doesn’t rely on dev-only packages or process.env values missing in Render.

  • Don’t forget to set any NEXT_PUBLIC_ vars (only those will be exposed to the browser).


TL;DR — commands you’ll actually run

Local (plain):

# backend
cd apps/backend && uvicorn main:app --host 0.0.0.0 --port 8000 --reload
# frontend
cd apps/ui && npm install && echo NEXT_PUBLIC_BACKEND_URL=http://localhost:8000 > .env.local
npm run dev -- -p 3003

Local (docker):

make fresh

Render:

  • Backend Web Service → root apps/backend, start uvicorn ... --port $PORT

  • Frontend Web Service → root apps/ui, build npm ci && npm run build, start npm run start

  • Env:

    • Frontend: NEXT_PUBLIC_BACKEND_URL=https://<backend>.onrender.com
    • Backend: FRONTEND_ORIGINS=https://<frontend>.onrender.com
  • Redeploy backend after frontend URL is known.

If you want, paste your apps/ui/package.json scripts, and I’ll give you the exact strings for Render (build/start) tailored to your setup.

About

Mini – minimal algo – algorithmic trading tron – techy / modular / monorepo-ish vibe (like electron, monotron) ify – implies transformation or automation licious – because of course 😎

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages