This project delivers a minimal end-to-end vocabulary lookup experience: an Expo React Native client fetches definitions from a Node.js + Express API that in turn queries a MySQL database. The repository contains both the mobile/web client and the backend so you can bootstrap the whole stack locally with a single command.
lexical-expo-app/- Expo (React Native + web) application created with
create-expo-app. app/index.tsxrenders the search UI.constants/backend.tsresolves the backend base URL fromEXPO_PUBLIC_API_URLor the Expo host IP.
- Expo (React Native + web) application created with
backend/- Express server defined in
server.jswith MySQL connectivity viamysql2/promise. .env(ignored by git) holds local database credentials..env.exampleshould be copied into.envand populated before running.
- Express server defined in
scripts/- Cross-platform automation helpers for installing dependencies and launching both services together (
setup_and_run.shandsetup_and_run.ps1).
- Cross-platform automation helpers for installing dependencies and launching both services together (
docs/- Architectural notes and longer-term plans (
TECHNICAL_ROADMAP.md).
- Architectural notes and longer-term plans (
| Tool | Version | Notes |
|---|---|---|
| Node.js | 18.x or newer | Required for both backend and Expo. |
| npm | 9.x or newer | Bundled with Node.js; used for installs. |
| MySQL | 8.x (remote or local) | Provide credentials via backend/.env. |
| Expo Go (Android/iOS) | Latest | Optional, for testing on devices. |
| PowerShell 5+ / Bash | Platform-specific | Required for the automation scripts. |
Database access: Update
backend/.envwith valid MySQL host, port, username, password, and database before starting the backend.
cd backend
cp .env.example .env
# edit .env with your DB credentialsmacOS/Linux:
bash scripts/setup_and_run.shWindows (PowerShell):
powershell -ExecutionPolicy Bypass -File scripts/setup_and_run.ps1What the script does:
- Installs
backendandlexical-expo-appdependencies (skip with--skip-install/-SkipInstall). - Starts the backend on port
3001by default and waits for/api/health. - Launches the Expo dev server on port
8083, injectingEXPO_PUBLIC_API_URLso the app talks to the backend.
Once Expo starts, open the Web UI at http://localhost:8083, or scan the QR code in Expo Go to test on a device.
bash scripts/setup_and_run.sh [options]| Option | Description |
|---|---|
--api <url> |
Override the backend URL shared with Expo (defaults to http://localhost:<backend-port> when backend runs locally). |
--expo-port <port> |
Set Expo dev server port (default 8083). |
--backend-port <port> |
Set backend port (default 3001). |
--backend-wait <seconds> |
Seconds to wait for backend health check (default 60). |
--skip-install |
Skip npm install for both projects. |
--install-only |
Install dependencies and exit without starting servers. |
--backend-only |
Run only the backend in the foreground. |
--expo-only |
Run only the Expo dev server (assumes backend is reachable). |
powershell -ExecutionPolicy Bypass -File scripts/setup_and_run.ps1 [options]| Option | Description |
|---|---|
-ApiUrl <url> |
Override API base URL sent to Expo. |
-ExpoPort <port> |
Expo dev server port (default 8083). |
-BackendPort <port> |
Backend port (default 3001). |
-BackendWaitSeconds <seconds> |
Health check timeout (default 60). |
-SkipInstall |
Skip dependency installation. |
-InstallOnly |
Install dependencies and exit. |
-BackendOnly |
Start only the backend in the foreground. |
-ExpoOnly |
Start only Expo (backend must already be running). |
The scripts verify that node, npm, npx, and (where applicable) curl are available before proceeding. When the backend runs in the background, logs are written to backend.log at the repository root.
-
Start the backend
cd backend npm install # skip if already installed PORT=3001 node server.js
-
Start Expo
cd lexical-expo-app npm install # skip if already installed EXPO_PUBLIC_API_URL=http://<your_machine_ip>:3001 npx expo start --port 8083
-
Test the API directly
curl http://<your_machine_ip>:3001/api/health curl "http://<your_machine_ip>:3001/api/search?word=example"
Use --tunnel with npx expo start or a service such as ngrok if your device cannot reach the backend over the local network.
backend/.envDB_HOST,DB_PORT,DB_USER,DB_PASS,DB_NAME,PORT- Do not commit real credentials. The provided
.envis for local demos only.
EXPO_PUBLIC_API_URL- Set this environment variable when launching Expo so the client can hit the correct backend URL. The automation scripts handle this automatically.
- CORS is enabled broadly for development. Restrict it before deploying to production.
- Expo app cannot reach backend
- Ensure both devices are on the same Wi-Fi.
- Confirm the backend health endpoint responds:
curl http://<ip>:3001/api/health. - Use the
--api/-ApiUrlflag to point Expo at a tunnel or remote host.
- Port already in use
- Pass
--backend-port/-BackendPortor--expo-port/-ExpoPortto change ports.
- Pass
- Dependency installation fails
- Make sure Node.js 18+ is installed and you have an up-to-date npm.
- Delete
node_modulesand re-run the script if needed.
- MySQL authentication errors
- Double-check
backend/.envand confirm that the user has READ access to the target schema.
- Double-check
- Long-form technical plan: see
docs/TECHNICAL_ROADMAP.mdfor architecture, testing, deployment, and roadmap guidance. - Future enhancements may include automated tests, CI workflows, richer dictionary data, and production deployment scripts.
- Keep
.envfiles out of source control; rotate credentials used for demos. - Review backend logs in
backend.logfor connection issues when using the automation scripts. - When preparing for git, add a top-level
.gitignore(if you have not already) to ignorenode_modules,.env, Expo caches, and build artifacts.
Happy hacking! Open an issue or reach out if you need help extending the project.