Phase 2 — Running the Application from Source on Arch Linux
What This Post Is
Section titled “What This Post Is”This is the second post in the Homelab to Production series. Phase 1 covered understanding the application architecture. This phase covers getting it running.
The goal was to take the forked source code, set up a native Linux development environment, diagnose and fix the issues found during Phase 1, and commit the working state to a clean GitHub repository with a reviewable diff showing exactly what changed.
The Environment
Section titled “The Environment”All developer work runs on a dedicated Arch Linux VM — dev-box-01 — running on Proxmox in the home lab. Using a dedicated VM rather than a local machine keeps the development environment clean, reproducible, and separate from the workstation.
The full software stack installed on dev-box-01:
- Node.js v22 via
fnm(Fast Node Manager) - PostgreSQL 15
- Redis 7
- Git and GitHub CLI
Everything is installed natively — no containers at this stage. The deliberate choice was to understand exactly what the application needs to run before any abstraction is introduced.
The Two-Repository Pattern
Section titled “The Two-Repository Pattern”Before any code was written, a structural decision was made: keep developer source code and DevOps implementation in separate repositories.
| Repository | Purpose |
|---|---|
sjchristie/humor-memory-game |
Developer source — the application as it runs natively |
sjchristie/humor-memory-game-devops |
DevOps implementation — Docker, Kubernetes, CI/CD |
This mirrors how real engineering teams work. Application code and infrastructure code have different audiences, different change cadences, and different ownership. Mixing them creates noise in both directions.
The Two-Commit Git Strategy
Section titled “The Two-Commit Git Strategy”A deliberate Git workflow was used to create a clean, reviewable record of this phase:
- Commit 1 — Raw source code copied from the forked repository, before any changes
- Commit 2 — Fully working application after all fixes applied
Anyone cloning the repository can run git diff HEAD~1 HEAD to see exactly what had to change to get the application running. This is a practical demonstration of structured thinking — not just a working app, but a documented path to get there.
Issues Found and Fixed
Section titled “Issues Found and Fixed”Three runtime issues were identified and resolved during this phase.
1 — Express Route Collision
Section titled “1 — Express Route Collision”What happened: The /api/game/daily-challenge endpoint returned a 500 error. The backend logs showed invalid input syntax for type uuid: "daily-challenge" — the database was receiving the string "daily-challenge" as a UUID parameter.
Root cause: In Express, routes are matched top to bottom. The dynamic /:gameId route was defined before the static /daily-challenge route, so Express treated "daily-challenge" as a game ID and passed it to the database.
Fix: Reordered the routes so static routes are defined before dynamic routes. Also removed a duplicate /:gameId route definition that was present in the original source.
Why this matters: Route ordering is a subtle but critical aspect of Express API design. Getting it wrong produces failures that are difficult to trace without reading the framework behaviour carefully.
2 — Environment Variable Not Substituted
Section titled “2 — Environment Variable Not Substituted”What happened: The browser showed window.API_BASE_URL = '${API_BASE_URL}' literally — the placeholder was not being replaced with the actual backend URL.
Root cause: The standard npm run build command copies files but does not perform environment variable substitution. The ${API_BASE_URL} placeholder in index.html requires envsubst to be run explicitly.
Fix: Created build-local.sh — a build script that runs envsubst on the HTML output before serving, replacing the placeholder with the correct backend address.
3 — Missing Database Table
Section titled “3 — Missing Database Table”What happened: The daily challenge endpoint was also failing because the daily_challenges table did not exist in the database schema.
Root cause: The original combined-init.sql schema file did not include the daily_challenges table definition, despite the application code referencing it.
Fix: Patched combined-init.sql to include the missing table definition.
What Was Produced
Section titled “What Was Produced”Four documents were produced as the output of this phase, all living in the docs/ folder of the developer repository:
| Document | Purpose |
|---|---|
DEVELOPER_SETUP.md |
Step-by-step setup guide for running the application natively on Arch Linux |
GIT_WORKFLOW.md |
The two-commit Git strategy with full verification steps |
TROUBLESHOOTING.md |
Nine documented issues with root causes, fixes, and prevention guidance |
README.md |
Recruiter-facing project overview with stack, decisions, and documentation links |
What This Phase Demonstrates
Section titled “What This Phase Demonstrates”- Ability to diagnose and resolve runtime issues in an unfamiliar codebase
- Structured Git workflow producing a reviewable before-and-after diff
- Technical documentation written for both developer and recruiter audiences
- Deliberate architectural decisions with clear reasoning
What Is Next
Section titled “What Is Next”Phase 3 covers containerising the application using Docker and Docker Compose — taking the natively running application and packaging it for consistent deployment across environments.
Phase 3 — Docker Containerisation →
Repository: sjchristie/humor-memory-game Full documentation: docs/