Architecture
Secret Republic is a classic server-rendered PHP application built on FuelPHP 1.9, an HMVC framework.
FuelPHP itself (fuel/core, fuel/packages/email, fuel/packages/parser) and all libraries are
installed by Composer. Only the game code is in the repository.
Directory layout
Section titled “Directory layout”public_html/ web root: index.php front controller, .htaccess, assets (css/js/img)fuel/├─ app/│ ├─ bootstrap.php sets FUEL_ENV, boots the framework│ ├─ config/ config.php, routes.php, email.php, db.php (generated), crypt.php (generated)│ ├─ classes/│ │ ├─ controller/ one class per URL segment: welcome, quests, skills, cardinal, setup, cron, …│ │ └─ model/ game logic: missions, quests, skills, knowledge, rewards, setup, …│ ├─ views/ PHP templates, grouped by controller│ ├─ voice/{mp3,ogg}/ AI voice clips│ ├─ db.sql schema + starter content, imported by /setup│ ├─ cache/ logs/ tmp/ runtime, must be writable (tmp holds per-run SQLite mission DBs)├─ packages/│ ├─ hacker/ authentication & player state (Hacker::check(), ::get(), ::can(), …)│ ├─ messages/ flash messages, modals and voice cues stored in the session│ ├─ globaljs/ collects inline JS from views and prints it in the footer│ ├─ email/ parser/ FuelPHP packages (Composer-managed, git-ignored)├─ core/ vendor/ FuelPHP core and Composer libraries (git-ignored)docker/ entrypoint, php.ini, env-driven db.php and crypt.phptests/ PHPUnit unit tests and the end-to-end smoke testscripts/ release packagingdocs/ this documentation site (Astro + Starlight)Request flow
Section titled “Request flow”- Apache rewrites every non-file request to
public_html/index.php. fuel/app/bootstrap.phpsets the environment (FUEL_ENVfrom the server,$_ENVorgetenv) and initializes Fuel withconfig/config.php, which always loads thehacker,messages,globaljsandemailpackages.- The router maps
/<controller>/<action>/<params…>toController_<Name>::action_<action>().routes.phpsends/towelcome/index. - Controllers call static models (
\Model\Missions,\Model\Quests, …) and the query builder (\DB), then render views withView::forge(). Most views includeglobal/headerandglobal/footer. Controller_Welcomeredirects to/setupuntil the database is installed (\Model\Setup::needs_setup()).
Key models
Section titled “Key models”| Model | Responsibility |
|---|---|
Missions |
Mission runtime: preparing a run, commands, objective checks, shortcodes |
Quests |
Mission catalogue, availability, completion bookkeeping |
Task |
Timed actions (missions, cracking, training, learning) stored in task |
DbMock |
SQLite sandbox for CQL database services |
Cardinal |
Mission designer helpers and objective type list |
Skills, Knowledge, Train, Rewards, Achievements |
Progression systems |
Setup |
Installer: input validation, SQL import, config writing |
Database
Section titled “Database”fuel/app/db.sql creates 23 InnoDB tables (utf8mb4) and seeds quotes, the tutorial storyline and
training content. The main groups are:
- players:
user,reward,task,user_mission,conversation,feedback,analytics - missions:
quest_group,quest,quest_objective,quest_server,quest_server_service,quest_service_user,quest_user_entity - misc:
email_queue,hacker_quote,hacker_group,tutorial_step, plus a few legacy tables
Each connection runs SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION' (see
Configuration).
Error handling
Section titled “Error handling”FuelPHP converts PHP warnings and notices into exceptions. In production the player sees a generic
“Oops” page and the details go to fuel/app/logs. PHP deprecations are configured as non-fatal
(errors.continue_on), so newer PHP versions can’t take the game down over a deprecation notice.
