|
| 1 | +# Getting Started |
| 2 | + |
| 3 | +This guide takes you from a fresh clone to a running dev server. Two paths are covered: |
| 4 | + |
| 5 | +1. **Devcontainer** (recommended) - everything installs automatically |
| 6 | +2. **Local machine** - you install Java, Leiningen, and Datomic yourself |
| 7 | + |
| 8 | +Both paths end at the same place: Datomic running, backend serving on port 8890, and Figwheel hot-reloading the frontend. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Path 1: Devcontainer |
| 13 | + |
| 14 | +Requires [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers), or [GitHub Codespaces](https://github.com/features/codespaces). |
| 15 | + |
| 16 | +### 1. Open in container |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/orcpub/orcpub.git |
| 20 | +cd orcpub |
| 21 | +code . |
| 22 | +``` |
| 23 | + |
| 24 | +When VS Code prompts **"Reopen in Container"**, click it. The container installs Java 21, Leiningen, and Datomic Pro automatically. |
| 25 | + |
| 26 | +### 2. Run first-time setup |
| 27 | + |
| 28 | +Once the container is built, open a terminal inside VS Code: |
| 29 | + |
| 30 | +```bash |
| 31 | +./scripts/dev-setup.sh |
| 32 | +``` |
| 33 | + |
| 34 | +This will: |
| 35 | +- Download project dependencies (`lein deps`) |
| 36 | +- Start the Datomic transactor |
| 37 | +- Initialize the database schema |
| 38 | +- Create a test user: **test** / **test@test.com** / **testpass** |
| 39 | + |
| 40 | +### 3. Start services |
| 41 | + |
| 42 | +```bash |
| 43 | +./menu |
| 44 | +``` |
| 45 | + |
| 46 | +The interactive menu shows service status and lets you start/stop with single keystrokes. Or start individually: |
| 47 | + |
| 48 | +```bash |
| 49 | +./menu start server # Backend on port 8890 |
| 50 | +./menu start figwheel # Frontend hot-reload on port 3449 |
| 51 | +``` |
| 52 | + |
| 53 | +### 4. Open the app |
| 54 | + |
| 55 | +Navigate to `http://localhost:8890` (or the Codespaces forwarded URL). Log in with **test@test.com** / **testpass**. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Path 2: Local Machine |
| 60 | + |
| 61 | +### 1. Prerequisites |
| 62 | + |
| 63 | +| Tool | Version | Install | |
| 64 | +|------|---------|---------| |
| 65 | +| Java | 21+ (OpenJDK) | [Adoptium](https://adoptium.net/) | |
| 66 | +| Leiningen | 2.9+ | [leiningen.org](https://leiningen.org/#install) | |
| 67 | +| Datomic Pro | 1.0.7482 | See below | |
| 68 | + |
| 69 | +**Datomic Pro** is free (Apache 2.0 license). The devcontainer installer handles this automatically, but on a local machine you need to install it manually: |
| 70 | + |
| 71 | +```bash |
| 72 | +# The install script downloads and extracts Datomic Pro |
| 73 | +./.devcontainer/post-create.sh |
| 74 | +``` |
| 75 | + |
| 76 | +Or follow the manual steps in [docs/migration/datomic-pro.md](migration/datomic-pro.md). Datomic should end up at `lib/com/datomic/datomic-pro/1.0.7482/`. |
| 77 | + |
| 78 | +### 2. Configure environment |
| 79 | + |
| 80 | +```bash |
| 81 | +cp .env.example .env |
| 82 | +``` |
| 83 | + |
| 84 | +Edit `.env` if needed. The defaults work for local development. The most important variable is `SIGNATURE` (JWT secret) -a dev default is provided automatically via `.lein-env`, so this step is optional for local dev. |
| 85 | + |
| 86 | +See [ENVIRONMENT.md](ENVIRONMENT.md) for the full variable list. |
| 87 | + |
| 88 | +### 3. Download dependencies |
| 89 | + |
| 90 | +```bash |
| 91 | +lein deps |
| 92 | +``` |
| 93 | + |
| 94 | +### 4. Start Datomic |
| 95 | + |
| 96 | +```bash |
| 97 | +./scripts/start.sh datomic |
| 98 | +``` |
| 99 | + |
| 100 | +Wait for "Datomic is ready" before continuing. The transactor listens on port 4334. |
| 101 | + |
| 102 | +### 5. Initialize the database |
| 103 | + |
| 104 | +First time only -creates the schema and applies seed data: |
| 105 | + |
| 106 | +```bash |
| 107 | +./scripts/start.sh init-db |
| 108 | +``` |
| 109 | + |
| 110 | +### 6. Create a test user |
| 111 | + |
| 112 | +```bash |
| 113 | +./menu add test testpass |
| 114 | +``` |
| 115 | + |
| 116 | +This creates **test@test.com** with password **testpass**, already verified. |
| 117 | + |
| 118 | +### 7. Start the backend |
| 119 | + |
| 120 | +```bash |
| 121 | +./scripts/start.sh server |
| 122 | +``` |
| 123 | + |
| 124 | +The server starts on port 8890 with an nREPL port for editor connections. |
| 125 | + |
| 126 | +### 8. Start Figwheel (frontend hot-reload) |
| 127 | + |
| 128 | +In a separate terminal: |
| 129 | + |
| 130 | +```bash |
| 131 | +./scripts/start.sh figwheel |
| 132 | +``` |
| 133 | + |
| 134 | +Figwheel compiles ClojureScript and serves it on port 3449. Changes to `.cljs` files are pushed to the browser automatically. |
| 135 | + |
| 136 | +### 9. Open the app |
| 137 | + |
| 138 | +Navigate to `http://localhost:8890`. Log in with **test@test.com** / **testpass**. |
| 139 | + |
| 140 | +--- |
| 141 | + |
| 142 | +## Using the REPL directly |
| 143 | + |
| 144 | +If you prefer `lein repl` over the shell scripts: |
| 145 | + |
| 146 | +```bash |
| 147 | +lein repl |
| 148 | +``` |
| 149 | + |
| 150 | +The `user` namespace loads automatically with helpers: |
| 151 | + |
| 152 | +```clojure |
| 153 | +(start-server) ; Start web server on port 8890 |
| 154 | +(stop-server) ; Stop web server |
| 155 | +(init-database) ; Initialize DB schema (first time) |
| 156 | +(fig-start) ; Start Figwheel from the REPL |
| 157 | +(cljs-repl) ; Connect to ClojureScript REPL (after fig-start) |
| 158 | +``` |
| 159 | + |
| 160 | +The `:dev` profile provides a dev `SIGNATURE` via `.lein-env`, so auth works without extra setup. If you need to override with your `.env` values: |
| 161 | + |
| 162 | +```bash |
| 163 | +source .env && lein repl |
| 164 | +``` |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +## Verification |
| 169 | + |
| 170 | +After starting services, confirm everything is working: |
| 171 | + |
| 172 | +| Check | Expected | |
| 173 | +|-------|----------| |
| 174 | +| `http://localhost:8890` loads | Splash page appears | |
| 175 | +| Log in with test@test.com / testpass | Character list page | |
| 176 | +| Create a new character | Builder loads with race/class options | |
| 177 | +| Edit and wait 7.5 seconds | Autosave (check Network tab for POST) | |
| 178 | +| Upload a `.orcbrew` file (My Content page) | Homebrew options appear in builder | |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +## Troubleshooting |
| 183 | + |
| 184 | +**Server returns 500 on login or API calls** |
| 185 | + |
| 186 | +The `SIGNATURE` env var is missing. If using `./menu` or `./scripts/start.sh`, check that `.env` exists and has `SIGNATURE` set. If using `lein repl`, the dev profile provides a default -but if you've overridden it with an empty value, auth will fail. |
| 187 | + |
| 188 | +**Datomic won't start** |
| 189 | + |
| 190 | +- Check that port 4334 isn't already in use: `lsof -i :4334` |
| 191 | +- Verify Datomic is installed: `ls lib/com/datomic/datomic-pro/1.0.7482/bin/transactor` |
| 192 | +- Check logs: `cat logs/datomic.log` |
| 193 | + |
| 194 | +**Figwheel compilation errors** |
| 195 | + |
| 196 | +- Run `lein fig:build` for a one-shot compile to see all errors |
| 197 | +- First compilation can be slow (1-2 minutes) as it downloads ClojureScript dependencies |
| 198 | + |
| 199 | +**Port already in use** |
| 200 | + |
| 201 | +```bash |
| 202 | +./scripts/stop.sh # Stop all services |
| 203 | +./scripts/stop.sh server # Stop just the server |
| 204 | +``` |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## What's next |
| 209 | + |
| 210 | +- [Architecture overview](../README.md#architecture) -how entities, templates, and modifiers work |
| 211 | +- [Dev tooling guide](migration/dev-tooling.md) -Leiningen profiles, REPL helpers, build commands |
| 212 | +- [Environment variables](ENVIRONMENT.md) -full config reference |
| 213 | +- [Stack migration context](MIGRATION-INDEX.md) -why Java 21, Datomic Pro, React 18, etc. |
0 commit comments