- Add .NET 8 backend with Clean Architecture - Add React + Vite + TypeScript frontend - Implement authentication with JWT - Implement Azure Blob Storage client - Implement OCR integration - Implement supplier matching service - Implement voucher generation - Implement Fortnox provider - Add unit and integration tests - Add Docker Compose configuration
183 lines
4.8 KiB
Bash
183 lines
4.8 KiB
Bash
#!/bin/bash
|
|
|
|
# Fortnox Invoice Integration - Project Setup Script
|
|
# This script initializes the project for local development
|
|
|
|
set -e
|
|
|
|
echo "🚀 Setting up Fortnox Invoice Integration project..."
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check prerequisites
|
|
echo "📋 Checking prerequisites..."
|
|
|
|
# Check Python
|
|
if ! command -v python3 &> /dev/null; then
|
|
echo "${RED}❌ Python 3 is not installed${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
|
|
REQUIRED_VERSION="3.11"
|
|
|
|
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
|
|
echo "${RED}❌ Python 3.11+ is required (found $PYTHON_VERSION)${NC}"
|
|
exit 1
|
|
fi
|
|
echo "${GREEN}✓ Python $PYTHON_VERSION${NC}"
|
|
|
|
# Check Node.js
|
|
if ! command -v node &> /dev/null; then
|
|
echo "${RED}❌ Node.js is not installed${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
NODE_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
|
|
if [ "$NODE_VERSION" -lt 18 ]; then
|
|
echo "${RED}❌ Node.js 18+ is required${NC}"
|
|
exit 1
|
|
fi
|
|
echo "${GREEN}✓ Node.js $(node --version)${NC}"
|
|
|
|
# Check Docker
|
|
if ! command -v docker &> /dev/null; then
|
|
echo "${YELLOW}⚠️ Docker is not installed (optional for local development)${NC}"
|
|
else
|
|
echo "${GREEN}✓ Docker $(docker --version | cut -d' ' -f3 | cut -d',' -f1)${NC}"
|
|
fi
|
|
|
|
# Get project root
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
echo ""
|
|
echo "📦 Setting up backend..."
|
|
|
|
# Setup backend
|
|
cd "$PROJECT_ROOT/backend"
|
|
|
|
# Create virtual environment if it doesn't exist
|
|
if [ ! -d "venv" ]; then
|
|
echo "Creating Python virtual environment..."
|
|
python3 -m venv venv
|
|
fi
|
|
|
|
# Activate virtual environment
|
|
source venv/bin/activate
|
|
|
|
# Upgrade pip
|
|
pip install --upgrade pip
|
|
|
|
# Install dependencies
|
|
if [ -f "requirements-dev.txt" ]; then
|
|
echo "Installing development dependencies..."
|
|
pip install -r requirements-dev.txt
|
|
else
|
|
echo "Installing production dependencies..."
|
|
pip install -r requirements.txt
|
|
fi
|
|
|
|
# Create .env if it doesn't exist
|
|
if [ ! -f ".env" ]; then
|
|
echo "Creating .env file from example..."
|
|
cp .env.example .env
|
|
echo "${YELLOW}⚠️ Please edit backend/.env with your configuration${NC}"
|
|
fi
|
|
|
|
echo "${GREEN}✓ Backend setup complete${NC}"
|
|
|
|
echo ""
|
|
echo "📦 Setting up frontend..."
|
|
|
|
# Setup frontend
|
|
cd "$PROJECT_ROOT/frontend"
|
|
|
|
# Install dependencies
|
|
if [ -f "package-lock.json" ]; then
|
|
echo "Installing npm dependencies (using package-lock.json)..."
|
|
npm ci
|
|
else
|
|
echo "Installing npm dependencies..."
|
|
npm install
|
|
fi
|
|
|
|
# Create .env.local if it doesn't exist
|
|
if [ ! -f ".env.local" ]; then
|
|
echo "Creating .env.local file from example..."
|
|
cp .env.example .env.local
|
|
echo "${YELLOW}⚠️ Please edit frontend/.env.local with your configuration${NC}"
|
|
fi
|
|
|
|
echo "${GREEN}✓ Frontend setup complete${NC}"
|
|
|
|
echo ""
|
|
echo "🐳 Setting up Docker environment..."
|
|
|
|
# Setup Docker
|
|
cd "$PROJECT_ROOT"
|
|
|
|
if [ -f "docker-compose.yml" ]; then
|
|
echo "Starting Docker services (PostgreSQL, Redis)..."
|
|
docker-compose up -d postgres redis
|
|
|
|
# Wait for PostgreSQL to be ready
|
|
echo "Waiting for PostgreSQL to be ready..."
|
|
sleep 5
|
|
|
|
until docker-compose exec -T postgres pg_isready -U postgres > /dev/null 2>&1; do
|
|
echo "PostgreSQL is not ready yet, waiting..."
|
|
sleep 2
|
|
done
|
|
|
|
echo "${GREEN}✓ Docker services are ready${NC}"
|
|
else
|
|
echo "${YELLOW}⚠️ docker-compose.yml not found, skipping Docker setup${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo "🗄️ Setting up database..."
|
|
|
|
# Run database migrations
|
|
cd "$PROJECT_ROOT/backend"
|
|
|
|
if command -v alembic &> /dev/null; then
|
|
echo "Running database migrations..."
|
|
alembic upgrade head || echo "${YELLOW}⚠️ Migration failed, please check your database configuration${NC}"
|
|
else
|
|
echo "${YELLOW}⚠️ Alembic not found, skipping migrations${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo "✅ Setup complete!"
|
|
echo ""
|
|
echo "📝 Next steps:"
|
|
echo ""
|
|
echo "1. Configure environment variables:"
|
|
echo " - Edit backend/.env"
|
|
echo " - Edit frontend/.env.local"
|
|
echo ""
|
|
echo "2. Start the development servers:"
|
|
echo " Backend: cd backend && source venv/bin/activate && uvicorn app.main:app --reload"
|
|
echo " Frontend: cd frontend && npm run dev"
|
|
echo ""
|
|
echo "3. Or use Docker Compose:"
|
|
echo " docker-compose up"
|
|
echo ""
|
|
echo "4. Access the application:"
|
|
echo " Frontend: http://localhost:5173"
|
|
echo " Backend: http://localhost:8000"
|
|
echo " API Docs: http://localhost:8000/docs"
|
|
echo ""
|
|
echo "📚 Documentation:"
|
|
echo " - Architecture: ./ARCHITECTURE.md"
|
|
echo " - API Design: ./API_DESIGN.md"
|
|
echo " - Database: ./DATABASE_SCHEMA.md"
|
|
echo " - Development: ./DEVELOPMENT_PLAN.md"
|
|
echo " - Deployment: ./DEPLOYMENT_GUIDE.md"
|
|
echo ""
|