# Register App Architecture

## Purpose

This document explains what each directory is for and identifies cleanup candidates that are empty or redundant.

## Runtime Path

Active request flow uses these directories:

1. app
2. public
3. php
4. sql
5. docs
6. var

## Directory Map

| Directory | Purpose | Current status | Recommendation |
| --- | --- | --- | --- |
| app | Core backend logic: bootstrap, config, DB, auth, middleware, helpers | Active | Keep |
| public | Primary web entry pages and public admin pages | Active | Keep |
| php | Alternate route surface sharing app bootstrap | Active | Keep if dual-surface support is intentional |
| sql | Schema and SQL reference files | Active | Keep |
| docs | Operational and security documentation | Active | Keep |
| var | Writable runtime data, especially sessions | Active | Keep |
| scripts | Automation scripts | Empty | Keep only if scripts are planned soon |
| tests | Automated tests | Empty | Keep only if test rollout is near-term |
| tools | Local helper tools | Empty | Remove if unused |
| tmp | Temporary files | Empty | Remove from repo; recreate when needed |
| templates | Reusable templates | Empty | Remove if no template rollout is planned |
| admin | Extra admin folder at repo root | Empty | Remove unless a second admin module is planned |
| audit | Audit pipeline artifacts | Empty | Remove until auditing is implemented |
| config | Alternate config root | Empty | Remove; app/config.php is authoritative |
| css | Local CSS assets | Contains empty themes folder | Remove if CDN assets remain standard |
| data | Data staging and storage placeholders | Contains empty subfolders | Remove until an actual data pipeline exists |
| img | Local images | Empty | Remove if images are not locally shipped |
| js | Local JavaScript assets | Empty | Remove if scripts stay inline or CDN-based |
| pages | Alternate page root | Empty | Remove to avoid confusion with public and php |
| src | Alternate code layout placeholders | Empty subfolders | Remove now or migrate fully to src later |
| ai | AI artifacts folder | Empty subfolders | Keep only if AI outputs/prompts are committed |

## File Cleanup Recommendations

1. Move Orig files to one backups directory to reduce clutter.
2. Remove snapshot files when no longer needed: new.tree.txt and old.tree.txt.
3. Keep testdb diagnostic files only if they are still used in troubleshooting.

## Suggested Target Structure

1. app
2. public
3. php
4. sql
5. docs
6. var
7. tests
8. scripts
9. backups

## Safe Cleanup Sequence

1. Delete empty top-level candidates first: admin, audit, config, img, js, pages, tools, tmp, templates.
2. Delete empty nested placeholders under data, css, src, and ai.
3. Move all Orig files to backups while preserving filenames.
4. Re-run smoke tests on public and php routes after cleanup.

## Why Cleanup Is Needed

1. Reduces confusion about which directories are authoritative.
2. Prevents duplicate implementations across parallel folder structures.
3. Simplifies onboarding and maintenance.
4. Keeps upgrade review cleaner by isolating backup artifacts.
