This file provides guidance for Codex Cloud (an agent in the cloud) on how to correctly build, run, and preview this Python/React application.
- packages/pybackend/: Python backend (FastAPI)
- packages/frontend/: NodeJS frontend (React + Vite)
These rules overwrite all other rules, even in case of conflict with the experts:
- Follow KISS principle - do not overengineer. Simplicity stays and wins!
- Follow DRY principle - do not repeat yourself and structure code modularly
- Always test the main or user-facing functionality: keep tests simple, high-value, and maintainable — prefer acceptance/system tests over microtests, avoid overtesting, and follow the Testing Pyramid and KISS principles
These are rules which should guide you, but can be overwritten by experts or programming language specifics:
- Write markdown file stem names in capital letters like README.md or MY_EXPLANATION.md
- Whenever you can not test because of technical reasons, review much deeper instead by performing additional web searches for getting latest specifications and examples until the solution meets state-of-the-art and common understanding
- Make web apps experienceable by running them (e.g.
npm run devoruv run ...)
This guide outlines the minimal test levels absolutely required for Python FastAPI backend and React frontend. Follow this mandatory guideline even if not instructed. Focus on lightweight, fast feedback — only essential tests are included.
- If CI runs
python -m pytest packages/pybackend/tests/unitdirectly, install backend dependencies first (e.g.,cd packages/pybackend && uv syncorpython -m pip install -e packages/pybackend) to avoid missing-import collection errors. - If CI runs
python -m pytestoutside theuvenvironment, dependencies likefastapican be missing. Prefer running tests withuv run(for example:uv run --project packages/pybackend python -m pytest packages/pybackend/tests/unit) or activate the.venvcreated byuv syncbefore executing pytest.
- Unit Tests — Cover core React components and utilities.
- Integration Tests — Check that essential API calls work.
- System Tests — Test main user flows with Playwright
- Smoke Tests — Confirm app starts
Note: Use these tests only if you plan to containerize the application with Docker.
- Component Tests — Ensure each container builds and starts without errors.
- Smoke Tests — Run full stack with
docker-compose up --build -d. - Smoke Tests — Verify containers are healthy (
docker psordocker-compose ps). - Smoke Tests — Check main endpoints respond (
curl http://localhost:3000/health). - Smoke Tests — Stop stack cleanly with
docker-compose down.
- Use Python 3.12 or newer for the backend.
- Use Node.js 18 or newer for the frontend.
- Run
npm installto install frontend dependencies. - Run
cd packages/pybackend && uv syncto install backend dependencies. - Ensure the environment variable
PORTis respected (default:3000). - The app must listen on
0.0.0.0(notlocalhost) to enable public preview. - The vite configuration has to be set up for allowing following remote hosts for previews (allowedHosts): .ngrok-free.dev, .ngrok.io, .ngrok.app
-
Install dependencies
# Frontend dependencies npm install # Backend dependencies cd packages/pybackend && uv sync
-
Start the servers
# Start both services (recommended) make run # Or start individually: # Backend: cd packages/pybackend && uv run uvicorn app:app --host 0.0.0.0 --port 3000 # Frontend: npm run dev:frontend
-
Confirm the servers are ready The backend should log:
INFO: Uvicorn running on http://0.0.0.0:3000The frontend should log:
Local: http://localhost:5173/This signals that the preview is ready to be exposed.
- The preview must expose port 3000.
- Wait for the app to start successfully before generating the preview link.
- If preview generation fails, print logs to diagnose issues (e.g., build errors or port conflicts).
- Ensure Python 3.12+ is installed for the backend.
- Ensure Node.js dependencies are properly declared in
packages/frontend/package.json. - Ensure Python dependencies are properly declared in
packages/pybackend/pyproject.toml. - Avoid interactive prompts during startup commands.
- For Python backend issues, check that
uvis installed andpackages/pybackend/.venvexists. - For frontend production mode:
npm run build:frontend && npm run preview:frontend
- Codex Cloud sandboxes may time out; ensure startup completes promptly.
- Keep build output small and dependencies clean to reduce setup time.
- Always test locally before expecting preview success.