ROM Index Website
ROM Index Website — Technical Specification v0.1
Status: Pre-implementation specification
Implementation target: PHP 8.x on Arch Linux
Frontend: Server-rendered HTML/CSS, minimal vanilla JavaScript where useful
Database: SQLite
External dependencies: Avoid unless there is a compelling reason
Application mode: Read-only web interface
Primary purpose: Index and display files contained in a configurable ROM directory
1. Purpose
The application is a lightweight, read-only web interface for browsing a filesystem containing game files.
The application does not attempt to understand ROM formats.
It does not care whether a file is:
- a Game Boy ROM
- a Switch file
- an ISO
- a ZIP
- a text file
- an unknown/custom format
If a file exists under a platform directory, it is considered an entry and can be displayed.
The platform is determined solely by the direct child directory of the configured ROM root.
Example:
roms/
├── gb/
│ ├── Pokemon Red.gb
│ └── Tetris.gb
├── nes/
│ └── Super Mario Bros.nes
├── switch/
│ ├── Zelda.nsp
│ └── SomeGame.xyz
└── completely-custom/
└── abc.fjzoejfozejf
The website displays:
[GB] Pokemon Red
[GB] Tetris
[NES] Super Mario Bros
[SWITCH] Zelda
[SWITCH] SomeGame
[COMPLETELY-CUSTOM] abc
The application therefore does not need a platform database, ROM extension database, metadata provider, artwork system, hash database, or game-identification system.
This deliberate simplicity is a core design requirement.
2. Design principles
The implementation should follow these principles:
- The filesystem is the source of truth.
- The application does not interpret file formats.
- The direct child directory determines the platform label.
- No hardcoded platform list.
- No hardcoded ROM extensions.
- No game metadata.
- No artwork.
- No hashing.
- No ROM modification.
- No ROM deletion.
- No uploading.
- No downloading through the website unless explicitly added later.
- The web application is read-only.
- Filesystem paths must never be directly controlled by untrusted URL input.
- The application should remain fast even if the collection grows substantially.
3. Filesystem layout
3.1 Default root
The default ROM root is:
./roms
The path is relative to the application’s configured working/application directory, not relative to the HTTP request.
The ROM root must be configurable.
Example configuration:
ROM_ROOT=./roms
Absolute paths should also be supported:
ROM_ROOT=/srv/roms
The application should resolve the configured root to a canonical filesystem path during startup/configuration loading.
4. Platform detection
A platform is determined exclusively by the first directory below the ROM root.
Given:
roms/
├── gb/
├── gbc/
├── switch/
└── ps1/
the platform identifiers are:
GB
GBC
SWITCH
PS1
No interpretation is performed.
Therefore:
roms/GameBoy/
produces:
[GAMEBOY]
while:
roms/gb/
produces:
[GB]
The directory name is converted to uppercase for display.
Example
roms/my-weird-platform/
game.blah
becomes:
[MY-WEIRD-PLATFORM] game
There is no concept of a canonical “Game Boy” name.
5. Nested directories
Nested directories are supported.
For example:
roms/
└── gb/
├── Pokemon/
│ ├── Red.gb
│ └── Blue.gb
└── Zelda/
└── Link.gb
All files are considered part of the GB platform.
The nested directory structure does not alter the platform.
Therefore:
roms/gb/Pokemon/Red.gb
has:
platform = GB
The nested directory may optionally be displayed as part of the file’s location/path information, but it does not affect its primary title.
6. What constitutes an indexed entry?
Every regular file discovered below a platform directory is an entry.
There is intentionally no extension filtering.
For example:
roms/switch/game.nsp
roms/switch/game.xci
roms/switch/game.xyz
roms/switch/readme.txt
are all valid index entries.
The scanner must not ask:
“Is
.xyza valid Switch ROM?”
It simply asks:
“Is this a regular file under the ROM root?”
If yes, it can be indexed.
7. Directories are not entries
Directories themselves are not displayed as games/files.
For:
roms/gb/Pokemon/Red.gb
the indexed object is:
Red.gb
not:
Pokemon
and not:
gb/Pokemon
However, the complete relative path should be retained internally.
8. Filename displayed on the website
The primary displayed filename should be the filename without its final extension.
Examples:
Pokemon Red.gb
becomes:
Pokemon Red
SomeGame.xyz
becomes:
SomeGame
file.with.multiple.extensions.foo
becomes:
file.with.multiple.extensions
Only the final extension is removed.
8.1 Files without extensions
A file such as:
roms/gb/Tetris
is displayed as:
[GB] Tetris
8.2 Dotfiles
A file such as:
roms/gb/.something
requires special handling.
The safest specification is:
- hidden files are ignored by default;
- this behavior should be configurable if necessary later.
This avoids accidentally displaying filesystem metadata such as .DS_Store.
9. Display format
The canonical display format is:
[PLATFORM] FILENAME
where:
PLATFORM = direct child directory name converted to uppercase
FILENAME = filename without final extension
Examples:
[GB] Pokemon Red
[GBC] Pokemon Crystal
[SWITCH] Zelda
[MY-CUSTOM-SYSTEM] Game
The website should not transform the actual filename beyond removing the final extension for the primary display.
For example:
Super Mario Bros. (USA) [!].nes
becomes:
[NES] Super Mario Bros. (USA) [!]
No attempt should be made to interpret (USA) or [!].
10. Archives
Archives are treated exactly like every other file.
For example:
roms/gb/games.zip
is simply:
[GB] games
The application does not:
- open the archive;
- inspect its contents;
- extract it;
- determine whether it contains a ROM;
- display the archive’s internal files.
This avoids requiring archive-specific libraries or system utilities.
11. Database
SQLite should be used as the local index database.
The database is an index/cache of the filesystem, not the authoritative source.
If the database is lost, it must be possible to rebuild it by scanning the ROM directory.
This is important because it prevents the database from becoming an additional source of truth.
12. Suggested database model
The application does not need a complicated relational model.
A single primary table is sufficient for v1.
Conceptually:
files
-----
id
relative_path
platform
filename
display_name
extension
size
modified_time
created/indexed_time
Potentially:
is_missing
if incremental synchronization is implemented.
Important
The database should store the relative path, not depend on storing an arbitrary absolute path supplied by the user.
For example:
gb/Pokemon Red.gb
rather than:
/home/user/project/roms/gb/Pokemon Red.gb
The configured ROM root is prepended internally when filesystem access is required.
13. Why store a database at all?
Even though there may initially be fewer than 100 files, using an index provides a cleaner architecture and future scalability.
It avoids:
HTTP request
↓
recursive filesystem scan
↓
directory traversal
↓
generate page
for every request.
Instead:
filesystem
↓
scanner
↓
SQLite
↓
PHP request
↓
HTML
The website becomes independent from filesystem scanning performance.
This also means that expanding from 100 files to several thousand later does not require redesigning the application.
14. Scanner
The scanner is responsible for synchronizing the filesystem with SQLite.
It should be a separate application component from the HTTP controllers/views.
Conceptually:
Scanner
├── locate ROM root
├── enumerate platform directories
├── recursively enumerate files
├── derive platform
├── derive display filename
├── update database
└── optionally remove stale database entries
The scanner should never modify files inside the ROM root.
15. Scanner behavior
For each immediate directory of the ROM root:
roms/<platform>/
the scanner recursively walks its contents.
For every regular file:
- Determine relative path.
- Determine platform from the first path component.
- Determine filename.
- Determine extension, if present.
- Determine display name.
- Determine file size.
- Determine modification timestamp.
- Insert/update the database entry.
No file contents need to be read.
This means the scanner should be extremely cheap compared with a system that hashes or parses ROMs.
16. No hashing
No MD5, SHA-1, SHA-256, CRC32, or other content hashing is required.
This is intentional.
There is no need to detect:
- duplicate ROMs;
- known ROM databases;
- corrupt ROMs;
- revisions;
- regions.
The application indexes what physically exists.
17. No metadata scraping
The application must not depend on:
- online game databases;
- APIs;
- cover-art APIs;
- ROM databases;
- metadata services.
This means the application remains completely functional offline.
18. Scanner invocation
The scanner should preferably be CLI-based rather than triggered by HTTP.
Recommended conceptual commands:
scan
Perform a normal synchronization.
rebuild
Delete/recreate the index and scan the entire ROM tree.
Potentially later:
status
Display scanner/database information.
The exact CLI syntax is an implementation detail and does not need to be finalized in this specification.
19. Initial synchronization
When the application is installed for the first time:
ROM filesystem
↓
initial scan
↓
SQLite database
↓
website available
The website should not need to scan the filesystem itself.
If the database has not yet been initialized, the application should show an informative setup/error state rather than silently performing a potentially expensive scan during an HTTP request.
20. Incremental synchronization
The scanner should support incremental updates.
The minimum useful comparison is:
relative_path
file_size
modified_time
If these haven’t changed, the scanner does not need to update the database record.
If a new file appears:
filesystem → INSERT
If a file changes:
filesystem → UPDATE
If a file disappears:
database → DELETE
or, preferably, mark it missing temporarily.
Given the simplicity of the application, permanently removing stale entries during synchronization is acceptable.
21. Symlinks
Symlinks should not be followed by default.
This is both a security and correctness measure.
For example:
roms/gb/link -> /etc/
must never cause the scanner to traverse /etc.
The scanner should operate only on the intended filesystem tree.
If symlink support is ever required, it should be an explicit configuration option with strict containment checks.
22. Filesystem security model
This is a critical requirement.
The application must assume that URLs are hostile even though the application is intended for local use.
A request such as:
/../../../etc/passwd
must never be capable of causing the application to access:
/etc/passwd
Likewise:
?file=../../../../etc/passwd
must not result in arbitrary filesystem access.
23. Path traversal protection
The application should follow this fundamental rule:
Never use a user-supplied URL/path directly as a filesystem path.
Instead, the database should identify files using an internal identifier.
For example:
/game/123
where:
123 → database record
The server retrieves:
relative_path = gb/Pokemon Red.gb
from SQLite.
It then constructs the filesystem path itself from:
canonical_rom_root + relative_path
The client never gets to choose an arbitrary filesystem path.
24. Defense-in-depth path validation
Even with database-backed IDs, the implementation should perform containment validation before any filesystem operation.
Conceptually:
configured ROM root
↓
canonicalize
↓
candidate path
↓
canonicalize
↓
verify candidate starts within ROM root
The implementation must account for:
...- absolute paths
- encoded path traversal
- symlinks
- platform-specific path separators
- null bytes where applicable
- malformed paths
The final resolved path must remain inside the configured ROM root.
25. Never expose arbitrary file reads
The website should not implement a generic endpoint such as:
/file?path=...
This would create unnecessary security risk.
If a file needs to be referenced, it should be referenced by an internal database ID.
Even then, v1 does not require a download endpoint.
The safest initial implementation is therefore:
The website displays file information but does not serve ROM files.
26. Read-only permissions
The filesystem permissions should reinforce the application’s design.
The PHP web process should ideally have:
ROM directory:
read + directory traversal
no write
SQLite:
read/write
The web process therefore cannot accidentally:
- delete ROMs;
- rename ROMs;
- overwrite ROMs;
- upload ROMs;
- modify ROM contents.
The scanner also needs only read access to the ROM directory.
27. Web application structure
The site should be server-rendered.
A conceptual request flow:
Browser
↓
Web server
↓
PHP front controller
↓
Router
↓
Controller
↓
SQLite repository
↓
Template
↓
HTML
No SPA is required.
28. Main pages
28.1 Dashboard
The homepage should provide a quick overview.
Potential information:
ROM Library
Total files: 93
Total platforms: 7
Total size: 18.4 GB
Last scan: 2026-10-05 13:10
And a platform listing:
GB 23
GBA 18
GBC 11
NES 15
SNES 12
SWITCH 9
PS1 5
Platform names are the actual directory names converted to uppercase.
29. Platform page
A platform URL could conceptually be:
/platform/gb
and display:
GB
23 files
[ Search ]
Pokemon Red
Pokemon Blue
Tetris
...
The platform identifier comes from the filesystem/database.
There is no predefined list.
If tomorrow:
roms/foobar/
appears, the website automatically gets:
[FOOBAR]
as a platform.
30. All-games/files page
The website should have an overall listing:
/games
or equivalent.
Entries are displayed as:
[GB] Pokemon Red
[GBA] Pokemon Emerald
[NES] Super Mario Bros
[SWITCH] Some Game
Sorting should be deterministic.
Recommended default:
- platform
- display name
- relative path as tie-breaker
This prevents unpredictable ordering when names are identical.
31. Search
A global search should be provided.
Search should operate against the indexed display name and/or filename.
Example:
/search?q=zelda
returns:
[GB] Zelda
[NES] Zelda II
[SWITCH] Zelda Something
The search should not perform a filesystem scan.
It queries SQLite.
32. Search security
Search strings must always be passed to SQLite using parameterized queries.
The application must never construct SQL like:
"... WHERE name LIKE '%" + userInput + "%'"
The exact implementation will use prepared statements.
This protects against SQL injection.
33. Platform filtering
The global listing should allow filtering by platform.
For example:
Platform:
[All]
[GB]
[GBA]
[GBC]
[NES]
[SWITCH]
The list itself is generated dynamically from the database.
34. Pagination
Even though the initial collection is small, pagination should be implemented from the start.
Recommended default:
50 entries per page
with the possibility of configuring it later.
This prevents a future 10,000-entry library from generating one enormous HTML response.
35. Game/file detail page
Because the application does not identify games, the detail page should be called a file detail page internally.
For example:
/file/123
could display:
[GB] Pokemon Red
Filename:
Pokemon Red.gb
Platform:
GB
Path:
gb/Pokemon Red.gb
Size:
1.00 MiB
Modified:
2026-10-01 18:42
The site should not pretend that it knows anything else about the file.
36. What should not be displayed unnecessarily
The website should not clutter the UI with technical information by default.
For example, the main listing should simply show:
[GB] Pokemon Red
rather than:
[GB] Pokemon Red.gb — 1,048,576 bytes — SHA256: ...
Detailed filesystem information belongs on a detail page, if included at all.
37. URL design
URLs should be based on safe identifiers.
Recommended conceptual routes:
/
Dashboard.
/games
All files.
/platform/<platform>
Platform listing.
/game/<id>
File details.
/search
Search.
The actual route naming is not important, but filesystem paths must never be routes.
38. URL parameter rules
Numeric IDs are preferred for database records.
For example:
/game/42
rather than:
/game/../../etc/passwd
The router should reject malformed IDs before any filesystem operation.
If platform slugs are used:
/platform/gb
the value must still be treated as an identifier, not as a filesystem path.
39. HTML escaping
Every filesystem-derived value is untrusted data from the perspective of HTML.
For example, a file can legitimately be named:
<script>alert(1)</script>.gb
The website must display it as text, not execute it.
Therefore all filesystem/database values rendered into HTML must be properly escaped.
This is required even on a private/local server.
40. XSS protection
The application must defend against stored XSS originating from filenames/directories.
Example:
roms/gb/<script>alert(1)</script>.gb
must never result in executable JavaScript.
The same applies to:
- platform names;
- filenames;
- paths;
- query parameters;
- error messages.
A Content Security Policy may optionally be added as defense in depth.
41. HTTP methods
The site should primarily use:
GET
for normal navigation.
There should be no state-changing HTTP endpoints in v1.
Therefore:
POST
PUT
PATCH
DELETE
are unnecessary unless functionality is added later.
This reinforces the read-only nature of the application.
42. CSRF
Since v1 contains no state-changing browser actions, CSRF protection is not necessary for ordinary browsing.
If administrative actions are ever introduced, CSRF protection becomes mandatory.
43. Authentication
Authentication is explicitly outside the application’s scope.
The deployment environment is expected to control access, for example:
Internet
↓
Reverse proxy / VPN / firewall
↓
PHP application
The PHP application itself does not need accounts in v1.
44. Error handling
Errors should never expose sensitive server information.
For example, an error page should not reveal:
/home/user/private/project/roms/...
or PHP stack traces to users.
Detailed errors should go to server/application logs.
The user-facing response should contain a generic message.
45. Logging
The application should log important operational errors, including:
- database failures;
- scanner failures;
- inaccessible files;
- invalid configuration;
- filesystem permission problems;
- unexpected exceptions.
Normal page requests should not generate excessive logs.
46. Configuration
Configuration should be centralized.
Conceptually:
Application configuration
├── ROM root
├── SQLite database path
├── pagination size
├── hidden-file behavior
└── scanner options
The ROM root must not be configurable through HTTP.
It should be controlled by server-side configuration/environment.
47. Dependency policy
The implementation should prefer PHP’s standard library and built-in extensions.
Preferred components:
- PHP filesystem APIs
- PDO
- PDO SQLite
- native JSON functionality if needed
- native date/time handling
- native string functionality
Avoid introducing:
- Composer packages without a concrete need;
- JavaScript frameworks;
- frontend build systems;
- ORM frameworks;
- external database servers;
- archive utilities;
- system commands.
If a dependency becomes necessary, it should be justified independently.
48. Database dependency
SQLite is the only external runtime component beyond PHP itself.
The application should use:
PDO + SQLite
rather than requiring:
- MySQL
- MariaDB
- PostgreSQL
This makes deployment on a normal Arch Linux PHP server very straightforward.
49. Database indexing
Even though the initial collection is tiny, useful indexes should be created.
At minimum:
relative_path
platform
display_name
Potentially a composite index for:
platform + display_name
This keeps platform browsing and sorting efficient.
50. Case handling
Filesystem paths are case-sensitive on Linux.
The application should preserve the original filename exactly.
For example:
Pokemon Red.gb
pokemon red.gb
POKEMON RED.gb
are three distinct filesystem entries.
However, platform display is always uppercase:
gb → GB
Switch → SWITCH
sWiTcH → SWITCH
The underlying platform directory name should remain available internally in its original form if needed.
51. Platform identity
There is a subtle but important distinction:
filesystem identifier:
Switch
display identifier:
SWITCH
The database should preferably retain the original directory name as the canonical platform value.
The uppercase representation should be a presentation transformation.
This avoids losing information unnecessarily.
52. Filename identity
Similarly, the database should retain:
filename = SomeGame.nsp
and derive:
display_name = SomeGame
rather than storing only the transformed value.
This makes the system reversible and avoids information loss.
53. Relative path identity
Each file should have a unique path relative to the ROM root.
Example:
gb/Pokemon Red.gb
should uniquely identify that filesystem entry.
This is preferable to relying exclusively on an auto-incrementing ID.
The database should enforce uniqueness on the relative path.
54. Missing files
The scanner should reconcile the database against the filesystem.
If:
gb/Pokemon Red.gb
exists in SQLite but no longer exists on disk, it should no longer appear in normal website listings.
The cleanest v1 behavior is to remove stale records during synchronization.
Because SQLite can always be rebuilt from the filesystem, there is no need to preserve stale entries indefinitely.
55. Scanner atomicity
The scanner should avoid leaving the database in a half-updated state if an error occurs.
Database transactions should be used for synchronization batches where appropriate.
Conceptually:
BEGIN
scan/update records
COMMIT
If the scan encounters a fatal database error:
ROLLBACK
The exact transaction granularity can be decided during implementation.
56. Concurrent scanner executions
Only one scanner should run at a time.
For example, we should prevent:
scanner#1
scanner#2
scanner#3
from modifying SQLite simultaneously.
A simple application-level lock should be sufficient.
This can be implemented using a filesystem lock or equivalent native mechanism.
57. Website concurrency
The website itself can safely serve multiple read requests simultaneously.
SQLite is well suited to this workload because the application is predominantly:
many reads
few writes
The scanner is the primary writer.
58. Performance goals
The application should be designed so that normal website requests do not depend on the number of files on disk.
A request should roughly be:
HTTP request
↓
SQLite query
↓
render template
↓
HTTP response
rather than:
HTTP request
↓
walk entire filesystem
↓
inspect files
↓
build result
↓
HTTP response
This remains important even though the initial collection is only around 100 files.
59. Caching
No sophisticated cache is required initially.
SQLite queries should be fast enough.
HTTP caching can potentially be added later for static CSS/images.
Dynamic pages do not require an application-level cache in v1.
60. Frontend requirements
The frontend should be intentionally lightweight.
Recommended:
- semantic HTML
- CSS
- responsive layout
- no mandatory JavaScript
- JavaScript only for optional enhancements
The website should remain fully usable if JavaScript is disabled.
61. Suggested visual structure
A simple layout:
┌───────────────────────────────────────────────┐
│ ROM Library Search │
├───────────────────────────────────────────────┤
│ │
│ Dashboard / GB / ... │
│ │
│ [GB] Pokemon Red │
│ [GB] Pokemon Blue │
│ [GB] Tetris │
│ [GB] Zelda │
│ │
└───────────────────────────────────────────────┘
No elaborate frontend framework is necessary.
62. Accessibility
The website should use:
- semantic headings;
- real links;
- accessible form controls;
- sufficient color contrast;
- keyboard navigation;
- meaningful page titles.
This costs very little while producing a better interface.
63. Sorting
Default sorting should be predictable.
For a platform:
A
B
C
...
For the global list:
GB
GBA
GBC
NES
SNES
SWITCH
followed by alphabetical filenames.
Case-insensitive sorting is recommended for display purposes.
The original filename remains untouched.
64. Duplicate filenames
Two files may legitimately have the same filename under different directories:
gb/foo/Game.gb
gb/bar/Game.gb
These are distinct entries.
Their relative paths distinguish them:
gb/foo/Game.gb
gb/bar/Game.gb
The website can display both as:
[GB] Game
[GB] Game
with the detail/path view distinguishing them.
No duplicate detection is required.
65. Special filenames
The implementation must correctly handle filenames containing characters such as:
&
'
"
(
)
[
]
-
_
+
,
.
spaces
and Unicode.
For example:
Pokémon - Édition Rouge.gb
should remain correctly represented.
The filesystem and database should use UTF-8.
66. New platform behavior
No code change should be required when a new directory is created.
For example:
roms/
gb/
nes/
switch/
whatever/
After scanning, whatever automatically appears as:
[WHATEVER]
This is a core feature.
67. Empty platform directories
An empty directory such as:
roms/gb/
can be shown as a platform with:
0 files
or omitted from the platform list.
Recommended behavior:
Only display platforms that contain at least one indexed file.
This prevents accidental empty directories from cluttering the UI.
68. Root-level files
Files directly inside:
roms/
do not have a platform.
The specification should therefore define them as not indexed.
Example:
roms/
README.txt
randomfile
gb/
game.gb
Only:
gb/game.gb
is indexed.
This keeps the platform model unambiguous.
69. Special directories
The scanner should not treat special filesystem objects as files.
It should ignore:
- directories as entries;
- sockets;
- FIFOs;
- devices;
- other non-regular filesystem objects.
Only regular files should become database entries.
70. Security summary
The following are mandatory security requirements:
Filesystem
- Never trust URL paths as filesystem paths.
- Never permit
..traversal. - Never follow symlinks outside the ROM root.
- Keep ROM root server-configured.
- Web process should have no write permission to ROM files.
- Do not expose arbitrary file-reading endpoints.
Database
- Use PDO prepared statements.
- Never interpolate user input into SQL.
- Validate database IDs.
- Treat database contents as untrusted when rendering HTML.
HTML
- Escape all filesystem-derived strings.
- Escape query parameters before output.
- Prevent filename-based stored XSS.
- Do not render filenames as HTML.
Application
- Don’t expose PHP stack traces.
- Don’t expose absolute filesystem paths.
- Log server-side errors.
- Keep scanner and HTTP application responsibilities separate.
71. Threat model
Even though this is local-only, the application should assume a malicious user can send requests such as:
GET /../../../etc/passwd
GET /game/../../etc/passwd
GET /file?path=../../../../etc/passwd
GET /search?q=<script>...</script>
GET /platform/../../...
The expected result is:
400 Bad Request
or:
404 Not Found
and never filesystem access outside the ROM root.
Likewise, malicious filenames should be treated as ordinary text.
72. Explicitly out of scope
The following are not part of v1:
- ROM validation
- ROM format detection
- ROM parsing
- game identification
- game metadata
- region detection
- language detection
- revision detection
- checksum databases
- hashing
- duplicate detection
- artwork
- screenshots
- external APIs
- archive extraction
- archive inspection
- emulator integration
- launching games
- ROM downloads
- ROM uploads
- ROM deletion
- ROM editing
- user accounts
- permissions management
- online authentication
- cloud storage
- multi-user management
This keeps the project extremely focused.
73. Recommended final architecture
The complete architecture can therefore remain remarkably small:
┌────────────────────┐
│ ROM ROOT │
│ │
│ ./roms │
└─────────┬──────────┘
│
│ read
▼
┌────────────────────┐
│ Scanner │
│ │
│ filesystem → index │
└─────────┬──────────┘
│
│ write
▼
┌────────────────────┐
│ SQLite │
│ │
│ filesystem index │
└─────────┬──────────┘
│
│ read
▼
┌────────────────────┐
│ PHP website │
│ │
│ Dashboard │
│ Platforms │
│ Search │
│ Files │
└─────────┬──────────┘
│
▼
Web browser
The important architectural property is that the scanner knows about the filesystem, while the website primarily knows about the database.
74. Example end-to-end behavior
Given:
roms/
├── gb/
│ ├── Pokemon Red.gb
│ ├── Pokemon Blue.gb
│ └── Weird File.whatever
│
├── switch/
│ ├── Zelda.nsp
│ └── TotallyNotARom.asdf
│
├── my-system/
│ └── Something
│
└── README.txt
The scanner produces approximately:
| Platform | Filename | Display name | Relative path |
|---|---|---|---|
gb |
Pokemon Red.gb |
Pokemon Red |
gb/Pokemon Red.gb |
gb |
Pokemon Blue.gb |
Pokemon Blue |
gb/Pokemon Blue.gb |
gb |
Weird File.whatever |
Weird File |
gb/Weird File.whatever |
switch |
Zelda.nsp |
Zelda |
switch/Zelda.nsp |
switch |
TotallyNotARom.asdf |
TotallyNotARom |
switch/TotallyNotARom.asdf |
my-system |
Something |
Something |
my-system/Something |
README.txt is ignored because it is directly under the ROM root.
The website displays:
[GB] Pokemon Blue
[GB] Pokemon Red
[GB] Weird File
[MY-SYSTEM] Something
[SWITCH] TotallyNotARom
[SWITCH] Zelda
No part of the application asks what any of those files actually are.
75. Implementation acceptance criteria
Before considering v1 complete, the implementation should satisfy all of these:
Filesystem
- Default ROM root is
./roms. - ROM root can be configured.
- Platform is the immediate child directory.
- Nested directories are supported.
- No file-extension allowlist exists.
- Any regular file below a platform directory is indexable.
- Root-level files are ignored.
- Symlinks are not followed by default.
- Hidden files are ignored by default.
- Original filename/path information is preserved.
Index
- SQLite is used.
- Database can be rebuilt entirely from filesystem contents.
- Relative paths uniquely identify files.
- No hashes are calculated.
- No file contents need to be read.
- Incremental synchronization is possible.
- Stale files disappear from normal listings.
Website
- Dashboard exists.
- Platform listing exists.
- Global file listing exists.
- Platform filtering exists.
- Search exists.
- Pagination exists.
- File detail view exists.
- Platform names are displayed uppercase.
- Extensions are omitted from primary display names.
- Website is read-only.
Security
- No arbitrary filesystem paths can be supplied through URLs.
- Database IDs are validated.
- SQL uses prepared statements.
- All filesystem-derived strings are HTML escaped.
- Filename-based XSS is prevented.
- Path traversal cannot escape the ROM root.
- Symlinks cannot be used to escape the ROM root.
- Absolute server paths are not exposed.
- ROM files cannot be modified through the website.
- ROM files are not downloadable through v1.
Deployment
- Works with standard PHP on Arch Linux.
- No external database server required.
- No frontend build process required.
- No unnecessary third-party libraries required.
- Scanner can be run independently of the web server.
76. One architectural clarification I’d lock in
There is one terminology change I’d recommend before implementation:
Don’t call database objects “games.” Call them “files” or “entries.”
The application has no idea whether:
Pokemon Red.gb
is actually a game, a dump, a patch, a backup, or something else.
Its only guaranteed knowledge is:
There is a file named
Pokemon Red.gbunder thegbplatform directory.
That distinction will keep the implementation honest and makes your “accept literally anything” requirement very clean.
So the conceptual model becomes:
ROM root
└── Platform directory
└── Files
rather than:
ROM root
└── Platforms
└── Games
└── ROMs