# Project Structure and Deployment Layout Design

**Date:** 2026-09-13

## Goal

Separate the Node.js backend runtime from the compiled frontend distribution so future deployment, maintenance, and GitHub changes use clear boundaries without changing production database data.

## Current State

- The repository currently has backend source directories and compiled frontend assets at the project root.
- The runtime entry point is `finance.js`; `app.js` is referenced by existing scripts but is not present.
- The project has an initial Git baseline commit, with secrets, local archives, logs, and uploaded runtime data excluded.
- Database scripts, migrations, and SQL files are maintained as deployment/database assets rather than backend runtime modules.

## Target Layout

```text
accounting-system/
├─ backend/
│  ├─ Config/
│  ├─ controllers/
│  ├─ Model/
│  ├─ middlewares/
│  ├─ routes/
│  ├─ services/
│  ├─ utils/
│  ├─ scripts/
│  ├─ seeders/
│  ├─ finance.js
│  └─ package.json
├─ dist/
│  ├─ index.html
│  ├─ assets/
│  └─ compiled frontend assets
├─ database/
├─ migrations/
├─ sql/
├─ tests/
├─ .gitignore
├─ README.md
└─ package-lock.json
```

## Rules

1. Move backend runtime directories and entry scripts together so their internal relative imports remain valid.
2. Move only compiled frontend files (`index.html`, `index_.html`, `assets/`, and related static root assets) into `dist/`.
3. Keep database definitions and migrations outside `backend/` so they are easy to run independently against a cloned production-data copy.
4. Update root and backend package scripts, `start-server.js`, and `pkg` asset paths to use `backend/finance.js`.
5. Do not move, edit, or connect to the production database as part of this structural change.
6. Do not add `.env`, archives, logs, `Uploads/`, `node_modules/`, or generated duplicate build directories to Git.
7. Verify module loading, test discovery, package scripts, and clean Git status before pushing.

## Verification

- Confirm every moved source file has no broken relative import.
- Run the repository test command and report its actual result.
- Run a backend module-load smoke check without opening a database connection where possible.
- Confirm `git ls-files` contains no excluded secrets or runtime data.
- Push the structural commit to `main` only after local verification.
