Files
roa2web-service-auto/start-data-entry-dev.sh
Marius Mutu 1a6e9b17d2 feat: Add shared components, refactor stores, improve data-entry workflow
Shared Components:
- Add CompanySelector.vue and PeriodSelector.vue components
- Add AppHeader.vue and SlideMenu.vue layout components
- Add shared stores factories (companies.js, accountingPeriod.js)
- Add shared routes factories (companies.py, calendar.py)
- Add shared models (company.py, calendar.py)
- Add shared layout styles (header.css, navigation.css)

Data Entry App:
- Update CLAUDE.md with prod/test server documentation
- Improve nomenclature sync service with better error handling
- Update receipts router and CRUD operations
- Add company/period stores using shared factories
- Update App.vue layout with shared components
- Fix OCRUploadZone file handling

Reports App:
- Refactor stores to use shared factories
- Update App.vue to use shared layout components

Infrastructure:
- Replace start-data-entry.sh with separate dev/test scripts
- Add .claude/rules for authentication, backend patterns, etc.
- Add implementation plan for OCR receipt improvements
- Clean up old documentation files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 15:00:45 +02:00

225 lines
7.1 KiB
Bash

#!/bin/bash
# Data Entry App - PRODUCTION Starter Script
# Oracle Server: 10.0.20.36 (via ssh_tunnel.sh)
# Database: receipts_prod.db
# Schema test: ROMFAST (company_id=114)
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
NC='\033[0m'
print_message() { echo -e "${BLUE}[DATA-ENTRY-PROD]${NC} $1"; }
print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
check_port() {
local port=$1
lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1
}
cleanup() {
print_message "Stopping services..."
[[ -n $BACKEND_PID ]] && kill $BACKEND_PID 2>/dev/null || true
[[ -n $FRONTEND_PID ]] && kill $FRONTEND_PID 2>/dev/null || true
./ssh_tunnel.sh stop 2>/dev/null || true
print_success "All services stopped."
exit 0
}
stop_services() {
print_message "Stopping all Data Entry PRODUCTION services..."
if check_port 8003; then
lsof -ti:8003 | xargs kill -TERM 2>/dev/null || true
sleep 2
lsof -ti:8003 | xargs kill -KILL 2>/dev/null || true
print_success "Backend stopped"
fi
if check_port 3010; then
lsof -ti:3010 | xargs kill -TERM 2>/dev/null || true
sleep 2
lsof -ti:3010 | xargs kill -KILL 2>/dev/null || true
print_success "Frontend stopped"
fi
./ssh_tunnel.sh stop 2>/dev/null || true
pkill -f "uvicorn.*data-entry" 2>/dev/null || true
pkill -f "vite.*3010" 2>/dev/null || true
print_success "All Data Entry PRODUCTION services stopped!"
exit 0
}
show_status() {
echo -e "${MAGENTA}═══════════════════════════════════════════${NC}"
echo -e "${MAGENTA} Data Entry App - PRODUCTION Status${NC}"
echo -e "${MAGENTA}═══════════════════════════════════════════${NC}"
echo
if pgrep -f "ssh.*1526.*10.0.20.36" > /dev/null 2>&1 || ./ssh_tunnel.sh status 2>&1 | grep -q "10.0.20.36"; then
echo -e " SSH Tunnel: ${GREEN}✓ PRODUCTION (10.0.20.36)${NC}"
elif pgrep -f "ssh.*1526" > /dev/null 2>&1; then
echo -e " SSH Tunnel: ${YELLOW}⚠ Running (check which server)${NC}"
else
echo -e " SSH Tunnel: ${RED}✗ Stopped${NC}"
fi
if check_port 8003; then
echo -e " Backend: ${GREEN}✓ Running${NC} (http://localhost:8003)"
else
echo -e " Backend: ${RED}✗ Stopped${NC}"
fi
if check_port 3010; then
echo -e " Frontend: ${GREEN}✓ Running${NC} (http://localhost:3010)"
else
echo -e " Frontend: ${RED}✗ Stopped${NC}"
fi
echo
echo -e " Database: ${BLUE}receipts_prod.db${NC}"
echo -e " Oracle: ${BLUE}10.0.20.36 (PRODUCTION)${NC}"
echo -e " Test Schema: ${BLUE}ROMFAST (company_id=114)${NC}"
echo
}
show_usage() {
echo -e "${MAGENTA}Data Entry App - PRODUCTION Starter${NC}"
echo
echo "Usage:"
echo " ./start-data-entry-dev.sh Start all services"
echo " ./start-data-entry-dev.sh stop Stop all services"
echo " ./start-data-entry-dev.sh status Show status"
echo
echo "Environment:"
echo " Oracle Server: 10.0.20.36 (PRODUCTION)"
echo " SSH Tunnel: ./ssh_tunnel.sh"
echo " Config: .env.prod"
echo " Database: receipts_prod.db"
echo
}
# Parse arguments
case $1 in
stop) stop_services ;;
status) show_status; exit 0 ;;
help|--help|-h) show_usage; exit 0 ;;
"") ;; # Continue to start
*) print_error "Unknown: $1"; show_usage; exit 1 ;;
esac
trap cleanup SIGINT SIGTERM
echo -e "${MAGENTA}═══════════════════════════════════════════${NC}"
echo -e "${MAGENTA} Data Entry App - PRODUCTION Environment${NC}"
echo -e "${MAGENTA} Oracle: 10.0.20.36 | DB: receipts_prod.db${NC}"
echo -e "${MAGENTA}═══════════════════════════════════════════${NC}"
echo
# Step 1: Stop any TEST tunnel and start PRODUCTION tunnel
print_message "1. Setting up SSH Tunnel (PRODUCTION)..."
./ssh-tunnel-test.sh stop 2>/dev/null || true
sleep 1
if ./ssh_tunnel.sh start; then
print_success "SSH Tunnel to PRODUCTION (10.0.20.36) started"
else
print_error "Failed to start SSH tunnel"
exit 1
fi
sleep 2
# Step 2: Copy PRODUCTION .env
print_message "2. Loading PRODUCTION environment..."
cp data-entry-app/backend/.env.prod data-entry-app/backend/.env
print_success "Loaded .env.prod (receipts_prod.db)"
# Step 3: Start Frontend
print_message "3. Starting Frontend (Vue.js)..."
cd data-entry-app/frontend/
if [ ! -d "node_modules" ] || [ -f "node_modules/.bin/vite.cmd" ]; then
print_message "Installing frontend dependencies..."
rm -rf node_modules package-lock.json 2>/dev/null
npm install
fi
npm run dev -- --port 3010 > /tmp/data_entry_frontend.log 2>&1 &
FRONTEND_PID=$!
for i in {1..15}; do
if check_port 3010; then
print_success "Frontend started on http://localhost:3010"
break
fi
[ $i -eq 15 ] && { print_error "Frontend failed"; cat /tmp/data_entry_frontend.log; cleanup; }
sleep 1
done
# Step 4: Start Backend
print_message "4. Starting Backend (FastAPI)..."
cd ../backend/
if [ ! -d "venv" ]; then
print_message "Creating virtual environment..."
python3 -m venv venv
fi
source venv/bin/activate
if ! python -c "import fastapi, uvicorn, sqlmodel" 2>/dev/null; then
print_message "Installing backend dependencies..."
pip install --upgrade pip > /dev/null 2>&1
pip install -r requirements.txt
fi
mkdir -p data/uploads
print_message "Running migrations..."
alembic upgrade head 2>/dev/null || print_warning "Migrations may already be applied"
uvicorn app.main:app --host 0.0.0.0 --port 8003 --reload > /tmp/data_entry_backend.log 2>&1 &
BACKEND_PID=$!
for i in {1..20}; do
if check_port 8003; then
print_success "Backend started on http://localhost:8003"
break
fi
[ $i -eq 20 ] && { print_error "Backend failed"; cat /tmp/data_entry_backend.log; cleanup; }
sleep 1
done
# Summary
echo
echo -e "${GREEN}═══════════════════════════════════════════${NC}"
echo -e "${GREEN} Data Entry PRODUCTION Environment Ready!${NC}"
echo -e "${GREEN}═══════════════════════════════════════════${NC}"
echo
echo -e "${BLUE}Services:${NC}"
echo " • SSH Tunnel: 10.0.20.36 (PRODUCTION)"
echo " • Backend: http://localhost:8003"
echo " • Frontend: http://localhost:3010"
echo " • API Docs: http://localhost:8003/docs"
echo
echo -e "${BLUE}Database:${NC}"
echo " • SQLite: data/receipts_prod.db"
echo " • Test Company: ROMFAST (company_id=114)"
echo
echo -e "${YELLOW}Press Ctrl+C to stop all services${NC}"
echo
wait