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:
Knee Cola
2025-12-25 12:13:04 +01:00
parent 321267a848
commit 57dcebd640
170 changed files with 9027 additions and 137 deletions

View File

@@ -2,15 +2,33 @@
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Monorepo Structure
This is a monorepo with the following workspaces:
- **web-app**: Next.js 14 utility bills tracking application
- **housekeeping**: Database backup and maintenance scripts
## Development Commands
- `npm run dev` - Start development server (Next.js)
- `npm run build` - Build production version
From the monorepo root:
- `npm run dev` - Start development server (runs web-app workspace)
- `npm run build` - Build production version (builds web-app workspace)
- `npm start` - Start production server (runs web-app workspace)
- `npm run prettier` - Format code with Prettier (entire monorepo)
- `npm run prettier:check` - Check code formatting (entire monorepo)
From the web-app workspace (`cd web-app`):
- `npm run dev` - Start development server
- `npm run build` - Build production version
- `npm start` - Start production server
- `npm run prettier` - Format code with Prettier
- `npm run prettier:check` - Check code formatting
- `npm run seed` - Seed database with initial data
From the housekeeping workspace (`cd housekeeping`):
- `npm run backup:standalone` - Run standalone database backup
- `npm run backup:swarm` - Run swarm database backup
- `npm run dump:standalone` - Run standalone database dump
- See housekeeping/README.md for more details
## Deployment Commands
- `./build.sh` - Build Docker image for deployment
@@ -31,25 +49,26 @@ This is a Next.js 14 utility bills tracking application ("Evidencija Režija") w
### Core Architecture Patterns
**Multi-user Data Isolation**: All database operations use the `withUser` higher-order function from `app/lib/auth.ts:102` to automatically inject authenticated user ID into queries, ensuring data isolation between users.
**Multi-user Data Isolation**: All database operations use the `withUser` higher-order function from `web-app/app/lib/auth.ts:102` to automatically inject authenticated user ID into queries, ensuring data isolation between users.
**Server Actions Pattern**: Form handling uses Next.js Server Actions with Zod validation. Actions are defined in `app/lib/actions/` and follow the pattern:
**Server Actions Pattern**: Form handling uses Next.js Server Actions with Zod validation. Actions are defined in `web-app/app/lib/actions/` and follow the pattern:
```typescript
export const actionName = withUser(async (user: AuthenticatedUser, ...args) => {
// Server action implementation with automatic user context
});
```
**Internationalization**: Uses next-intl with locale-based routing. Messages are in `messages/` directory. The middleware handles both auth and i18n routing.
**Internationalization**: Uses next-intl with locale-based routing. Messages are in `web-app/messages/` directory. The middleware handles both auth and i18n routing.
### Key Files & Responsibilities
- `middleware.ts` - Handles authentication and i18n routing, defines public pages
- `app/lib/auth.ts` - NextAuth configuration, `withUser` HOF for user context
- `app/lib/dbClient.ts` - MongoDB connection with development/production handling
- `app/lib/actions/` - Server actions for data mutations (locations, bills, months)
- `app/i18n.ts` - Internationalization configuration (Croatian default)
- `next.config.js` - Standalone build config with `serverActions.allowedOrigins` for Docker deployment
- `web-app/middleware.ts` - Handles authentication and i18n routing, defines public pages
- `web-app/app/lib/auth.ts` - NextAuth configuration, `withUser` HOF for user context
- `web-app/app/lib/dbClient.ts` - MongoDB connection with development/production handling
- `web-app/app/lib/actions/` - Server actions for data mutations (locations, bills, months)
- `web-app/app/i18n.ts` - Internationalization configuration (Croatian default)
- `web-app/next.config.js` - Standalone build config with `serverActions.allowedOrigins` for Docker deployment
- `housekeeping/` - Database backup and maintenance scripts
### Database Schema
- **Collections**: Locations, Bills, Months (year-month periods)