refactor: convert repository to monorepo with npm workspaces
Restructured the repository into a monorepo to better organize application code and maintenance scripts. ## Workspace Structure - web-app: Next.js application (all app code moved from root) - housekeeping: Database backup and maintenance scripts ## Key Changes - Moved all application code to web-app/ using git mv - Moved database scripts to housekeeping/ workspace - Updated Dockerfile for monorepo build process - Updated docker-compose files (volume paths: ./web-app/etc/hosts/) - Updated .gitignore for workspace-level node_modules - Updated documentation (README.md, CLAUDE.md, CHANGELOG.md) ## Migration Impact - Root package.json now manages workspaces - Build commands delegate to web-app workspace - All file history preserved via git mv - Docker build process updated for workspace structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
47
README.md
47
README.md
@@ -17,46 +17,69 @@ Each location record is marked with a user ID.
|
||||
|
||||
All the actions user `withUser` to fetch user ID, which is then used in all the DB operations.
|
||||
|
||||
# Monorepo Structure
|
||||
|
||||
This project is organized as a monorepo with multiple workspaces:
|
||||
|
||||
- **web-app**: The main Next.js application for tracking utility bills
|
||||
- **housekeeping**: Database backup and maintenance scripts
|
||||
|
||||
## Working with Workspaces
|
||||
|
||||
From the monorepo root:
|
||||
|
||||
```bash
|
||||
# Run dev server
|
||||
npm run dev
|
||||
|
||||
# Build the web app
|
||||
npm run build
|
||||
|
||||
# Run database backup (standalone)
|
||||
npm run backup:standalone --workspace=housekeeping
|
||||
```
|
||||
|
||||
# Database Backup & Restore
|
||||
|
||||
The project includes multiple backup strategies for different deployment scenarios and requirements.
|
||||
All backup scripts are located in the `housekeeping/` workspace.
|
||||
|
||||
## Backup Scripts Overview
|
||||
|
||||
### Standalone Docker Deployments
|
||||
|
||||
**Online Backups (No Downtime):**
|
||||
- `db-dump--standalone.sh` - Creates online backup of the 'utility-bills' database using mongodump
|
||||
- `housekeeping/db-dump--standalone.sh` - Creates online backup of the 'utility-bills' database using mongodump
|
||||
- Database stays running during backup
|
||||
- Only backs up the database content, not the full volume
|
||||
- Output: `./mongo-backup/utility-bills-dump-YYYY-MM-DD_HH-MM.tar.gz`
|
||||
- Default retention: 7 backups (configurable via `KEEP` env var)
|
||||
- Usage: `./db-dump--standalone.sh` or `KEEP=10 ./db-dump--standalone.sh`
|
||||
- Usage: `cd housekeeping && ./db-dump--standalone.sh` or `KEEP=10 ./db-dump--standalone.sh`
|
||||
|
||||
- `db-restore-from-dump--standalone.sh` - Restores from mongodump archives
|
||||
- `housekeeping/db-restore-from-dump--standalone.sh` - Restores from mongodump archives
|
||||
- Database stays running during restore
|
||||
- **WARNING**: Drops existing collections before restore
|
||||
- Usage: `./db-restore-from-dump--standalone.sh utility-bills-dump-2025-11-26_14-30.tar.gz`
|
||||
- Usage: `cd housekeeping && ./db-restore-from-dump--standalone.sh utility-bills-dump-2025-11-26_14-30.tar.gz`
|
||||
|
||||
**Offline Backups (With Downtime):**
|
||||
- `db-backup--standalone.sh` - Creates offline backup of the complete mongo-volume directory
|
||||
- `housekeeping/db-backup--standalone.sh` - Creates offline backup of the complete mongo-volume directory
|
||||
- Database container is stopped during backup for consistency
|
||||
- Backs up the entire MongoDB data directory
|
||||
- Output: `./mongo-backup/mongo-volume-backup-YYYY-MM-DD-HH-MM.tar.gz`
|
||||
- Default retention: 7 backups (configurable via `KEEP` env var)
|
||||
- Usage: `./db-backup--standalone.sh` or `KEEP=2 ./db-backup--standalone.sh`
|
||||
- Usage: `cd housekeeping && ./db-backup--standalone.sh` or `KEEP=2 ./db-backup--standalone.sh`
|
||||
|
||||
### Docker Swarm Deployments
|
||||
|
||||
- `db-backup--swarm.sh` - Creates offline backup by scaling down the MongoDB service
|
||||
- `housekeeping/db-backup--swarm.sh` - Creates offline backup by scaling down the MongoDB service
|
||||
- Service is scaled to 0 during backup
|
||||
- Output: `./mongo-backup/mongo-volume-backup-YYYY-MM-DD-HH-MM.tar.gz`
|
||||
- Usage: `./db-backup--swarm.sh`
|
||||
- Usage: `cd housekeeping && ./db-backup--swarm.sh`
|
||||
|
||||
- `db-restore-from-backup--swarm.sh` - Restores volume backup by scaling down the service
|
||||
- `housekeeping/db-restore-from-backup--swarm.sh` - Restores volume backup by scaling down the service
|
||||
- Service is scaled to 0 during restore
|
||||
- Optional `--pre-backup` flag for safety backup before restore
|
||||
- Usage: `./db-restore-from-backup--swarm.sh mongo-volume-backup-2025-11-26-14-30.tar.gz`
|
||||
- Usage: `cd housekeeping && ./db-restore-from-backup--swarm.sh mongo-volume-backup-2025-11-26-14-30.tar.gz`
|
||||
|
||||
## Automated Backup Schedule
|
||||
|
||||
@@ -64,10 +87,10 @@ Backups run automatically via cron at 04:00 every day:
|
||||
|
||||
```cron
|
||||
# Sunday: Full volume backup (offline), keep 2 backups
|
||||
0 4 * * 0 cd /home/knee-cola/web-pro/evidencija-rezija && KEEP=2 ./db-backup--standalone.sh
|
||||
0 4 * * 0 cd /home/knee-cola/web-pro/evidencija-rezija/housekeeping && KEEP=2 ./db-backup--standalone.sh
|
||||
|
||||
# Monday-Saturday: Database dump (online), keep 6 backups
|
||||
0 4 * * 1-6 cd /home/knee-cola/web-pro/evidencija-rezija && KEEP=6 ./db-dump--standalone.sh
|
||||
0 4 * * 1-6 cd /home/knee-cola/web-pro/evidencija-rezija/housekeeping && KEEP=6 ./db-dump--standalone.sh
|
||||
```
|
||||
|
||||
**Backup Strategy:**
|
||||
|
||||
Reference in New Issue
Block a user