Created dedicated workspace for Docker deployment configurations and scripts. Improves organization by grouping all deployment-related files together. ## New Structure - docker-stack/: Docker Compose files and deployment scripts - docker-compose-standalone.yaml - docker-compose-swarm.yml - docker-compose-debug.yml - deploy-standalone.sh - deploy-swarm.sh - README.md (deployment documentation) - package.json ## Changes - Moved all docker-compose YAML files to docker-stack/ - Moved deploy scripts to docker-stack/ - Updated VS Code workspace to include docker-stack - Updated documentation (README, CLAUDE.md) ## Deployment Workflow 1. Build: `cd web-app && ./build.sh 2.20.0` 2. Deploy: `cd docker-stack && ./deploy-standalone.sh 2.20.0` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4.2 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Repository Structure
This is a multi-project repository containing:
- web-app/: Next.js 14 utility bills tracking application
- docker-stack/: Docker Compose configurations and deployment scripts
- housekeeping/: Database backup and maintenance scripts
Each project is self-contained with its own dependencies.
Development Commands
All commands should be run from within the respective project directory.
Web App (cd web-app):
npm install- Install dependenciesnpm run dev- Start development servernpm run build- Build production versionnpm start- Start production servernpm run prettier- Format codenpm run seed- Seed database with initial data
Housekeeping (cd housekeeping):
./db-backup--standalone.sh- Run standalone database backup./db-backup--swarm.sh- Run swarm database backup./db-dump--standalone.sh- Run standalone database dump- See housekeeping/README.md for more details
Deployment Commands
Building Docker Image (cd web-app):
./build.sh <version>- Build Docker image
Deploying (cd docker-stack):
./deploy-standalone.sh <version>- Deploy with docker-compose (standalone)./deploy-swarm.sh <version>- Deploy with Docker Swarm
Architecture Overview
This is a Next.js 14 utility bills tracking application ("Evidencija Režija") with the following key components:
Tech Stack
- Framework: Next.js 14 with App Router and standalone output for Docker
- Authentication: NextAuth v5 with Google OAuth
- Database: MongoDB with connection pooling
- Internationalization: next-intl (Croatian/English)
- Styling: Tailwind CSS with DaisyUI components
- Deployment: Docker with MongoDB 4.4.27 (AVX compatibility)
Core Architecture Patterns
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 web-app/app/lib/actions/ and follow the pattern:
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 web-app/messages/ directory. The middleware handles both auth and i18n routing.
Key Files & Responsibilities
web-app/middleware.ts- Handles authentication and i18n routing, defines public pagesweb-app/app/lib/auth.ts- NextAuth configuration,withUserHOF for user contextweb-app/app/lib/dbClient.ts- MongoDB connection with development/production handlingweb-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 withserverActions.allowedOriginsfor Docker deploymenthousekeeping/- Database backup and maintenance scripts
Database Schema
- Collections: Locations, Bills, Months (year-month periods)
- User Association: All documents include
userIdfield for multi-tenant isolation - Database Name: "utility-bills"
Docker Deployment Notes
- Uses standalone Next.js build for Docker optimization
- MongoDB 4.4.27 required for older CPU compatibility (no AVX instructions)
HOSTNAME=0.0.0.0withserverActions.allowedOriginsconfig to handle reverse proxy headers- Environment variables:
MONGODB_URI,GOOGLE_ID,GOOGLE_SECRET,AUTH_SECRET
Barcode/QR Code Feature
- Uses
@zxing/libraryand@zxing/browserfor PDF document scanning - Heavy barcode decoding operations should be moved to background threads if performance issues arise
- PDF processing with
pdfjs-distfor utility bill scanning
Testing & Code Quality
- ESLint with Next.js and Prettier configurations
- No specific test framework configured - check with user before assuming testing approach