File size: 18,696 Bytes
a3c5bda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
#!/bin/bash

# Legal Dashboard - One-Click Deployment Script
# =============================================
# This script handles everything: validation, optimization, and deployment

set -e  # Exit on any error

# Colors for beautiful output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
NC='\033[0m'

# ASCII Art Banner
print_banner() {
    echo -e "${PURPLE}"
    echo "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ"
    echo "β–ˆ                                                                              β–ˆ"
    echo "β–ˆ  πŸ›οΈ  LEGAL DASHBOARD - ONE-CLICK DEPLOYMENT                                 β–ˆ"
    echo "β–ˆ                                                                              β–ˆ"
    echo "β–ˆ      Comprehensive Legal Document Management System                          β–ˆ"
    echo "β–ˆ      Ready for HF Spaces β€’ Docker β€’ Local Deployment                        β–ˆ"
    echo "β–ˆ                                                                              β–ˆ"
    echo "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ"
    echo -e "${NC}"
}

# Utility functions
print_success() { echo -e "${GREEN}βœ… $1${NC}"; }
print_error() { echo -e "${RED}❌ $1${NC}"; }
print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
print_step() { echo -e "${CYAN}πŸ”§ $1${NC}"; }

# Progress indicator
show_progress() {
    local duration=$1
    local message=$2
    
    echo -n -e "${YELLOW}⏳ ${message}${NC}"
    for ((i=0; i<duration; i++)); do
        echo -n "."
        sleep 1
    done
    echo -e " ${GREEN}Done!${NC}"
}

# Check if command exists
command_exists() {
    command -v "$1" >/dev/null 2>&1
}

# Detect operating system
detect_os() {
    if [[ "$OSTYPE" == "linux-gnu"* ]]; then
        echo "linux"
    elif [[ "$OSTYPE" == "darwin"* ]]; then
        echo "macos"
    elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
        echo "windows"
    else
        echo "unknown"
    fi
}

# Main deployment function
main() {
    local deployment_type=""
    local project_ready=false
    
    print_banner
    echo ""
    print_info "Legal Dashboard Deployment Assistant"
    print_info "Detected OS: $(detect_os)"
    echo ""
    
    # Check if we're in the right directory
    if [[ ! -f "app.py" && ! -f "run.py" ]]; then
        print_error "This doesn't appear to be the Legal Dashboard directory."
        print_info "Please run this script from the project root directory."
        exit 1
    fi
    
    print_success "Project directory confirmed"
    
    # Deployment type selection
    echo ""
    print_step "Select Deployment Type:"
    echo ""
    echo -e "  ${GREEN}1)${NC} πŸ€— Hugging Face Spaces (Recommended for Demo)"
    echo -e "  ${BLUE}2)${NC} 🐳 Docker Deployment (Recommended for Production)"
    echo -e "  ${PURPLE}3)${NC} πŸ’» Local Development"
    echo -e "  ${CYAN}4)${NC} πŸ§ͺ Run Tests Only"
    echo -e "  ${YELLOW}5)${NC} πŸ“‹ Show Project Status"
    echo ""
    
    read -p "Enter your choice (1-5): " choice
    
    case $choice in
        1)
            deployment_type="huggingface"
            deploy_to_huggingface
            ;;
        2)
            deployment_type="docker"
            deploy_with_docker
            ;;
        3)
            deployment_type="local"
            setup_local_development
            ;;
        4)
            run_comprehensive_tests
            ;;
        5)
            show_project_status
            ;;
        *)
            print_error "Invalid choice. Please run the script again."
            exit 1
            ;;
    esac
}

# Hugging Face Spaces deployment
deploy_to_huggingface() {
    print_step "Preparing for Hugging Face Spaces Deployment"
    echo ""
    
    # Check if git is available
    if ! command_exists git; then
        print_error "Git is required for HF Spaces deployment"
        exit 1
    fi
    
    # Run pre-deployment tests
    print_info "Running pre-deployment validation..."
    if python3 final_test.py --quick; then
        print_success "All critical tests passed"
    else
        print_warning "Some tests failed, but continuing with deployment"
    fi
    
    # Create HF Spaces optimized requirements
    print_step "Creating HF Spaces optimized requirements..."
    cp requirements-hf-spaces.txt requirements.txt
    print_success "Requirements optimized for HF Spaces"
    
    # Prepare files for HF Spaces
    print_step "Preparing files for Hugging Face Spaces..."
    
    # Create deployment checklist
    cat > HF_SPACES_SETUP.md << EOF
# πŸ€— Hugging Face Spaces Setup Instructions

## πŸ“‹ Quick Setup Steps:

1. **Create New Space:**
   - Go to https://huggingface.co/new-space
   - Choose "Gradio" as SDK
   - Set Python version to 3.10

2. **Upload Files:**
   - Upload all files from this directory to your Space
   - The main entry point is \`app.py\`

3. **Set Environment Variables in Space Settings:**
   \`\`\`
   JWT_SECRET_KEY=your-unique-secret-key-here-$(date +%s)
   DATABASE_DIR=/tmp/legal_dashboard/data
   LOG_LEVEL=INFO
   ENVIRONMENT=production
   \`\`\`

4. **Default Login Credentials:**
   - Username: \`admin\`
   - Password: \`admin123\`
   - **⚠️ CHANGE IMMEDIATELY AFTER FIRST LOGIN!**

## πŸš€ Features Available in HF Spaces:
- βœ… Document upload and processing
- βœ… Authentication system
- βœ… Persian/English interface
- βœ… Basic OCR capabilities
- βœ… Document management
- βœ… Responsive design

## πŸ“ž Support:
- Check Space logs for any issues
- Health check available at your-space-url/health
- Report issues via GitHub

**Your Legal Dashboard is ready for HF Spaces! πŸŽ‰**
EOF
    
    print_success "HF Spaces setup guide created: HF_SPACES_SETUP.md"
    
    echo ""
    print_success "πŸŽ‰ Hugging Face Spaces deployment package ready!"
    echo ""
    print_info "Next steps:"
    echo "  1. πŸ“ Read HF_SPACES_SETUP.md for detailed instructions"
    echo "  2. 🌐 Create a new Space at https://huggingface.co/new-space"
    echo "  3. πŸ“ Upload all files from this directory"
    echo "  4. βš™οΈ Set environment variables as shown in the guide"
    echo "  5. πŸš€ Your Space will automatically build and deploy!"
    echo ""
    print_warning "Remember to change the default admin password after deployment!"
}

# Docker deployment
deploy_with_docker() {
    print_step "Setting up Docker Deployment"
    echo ""
    
    # Check Docker availability
    if ! command_exists docker; then
        print_error "Docker is not installed. Please install Docker first."
        echo "  πŸ“₯ Download from: https://www.docker.com/get-started"
        exit 1
    fi
    
    if ! command_exists docker-compose; then
        print_warning "Docker Compose not found. Using docker compose instead."
    fi
    
    # Check if Docker is running
    if ! docker info >/dev/null 2>&1; then
        print_error "Docker is not running. Please start Docker first."
        exit 1
    fi
    
    print_success "Docker is available and running"
    
    # Run pre-deployment tests
    print_info "Running pre-deployment validation..."
    if python3 final_test.py --quick; then
        print_success "All critical tests passed"
    else
        print_error "Critical tests failed. Please fix issues before deploying."
        exit 1
    fi
    
    # Create optimized requirements for Docker
    print_step "Preparing Docker environment..."
    cp requirements-docker.txt requirements.txt
    
    # Ensure .env file exists
    if [[ ! -f ".env" ]]; then
        print_step "Creating .env file..."
        cat > .env << EOF
# Legal Dashboard Environment Configuration
JWT_SECRET_KEY=super-secret-jwt-key-change-in-production-$(date +%s)
DATABASE_DIR=/app/data
LOG_LEVEL=INFO
ENVIRONMENT=production
WORKERS=4
PORT=8000
PYTHONPATH=/app
PYTHONUNBUFFERED=1
EOF
        print_success ".env file created"
    fi
    
    # Build and start containers
    print_step "Building Docker containers..."
    show_progress 5 "Building images"
    
    if command_exists docker-compose; then
        docker-compose build --no-cache
        print_success "Docker containers built successfully"
        
        print_step "Starting Legal Dashboard..."
        docker-compose up -d
        
        # Wait for services to be ready
        print_info "Waiting for services to start..."
        sleep 15
        
        # Check if services are running
        if docker-compose ps | grep -q "Up"; then
            print_success "πŸŽ‰ Legal Dashboard is running!"
            echo ""
            print_info "🌐 Access your Legal Dashboard:"
            echo "  β€’ Dashboard: http://localhost:8000"
            echo "  β€’ API Docs: http://localhost:8000/docs"
            echo "  β€’ Health Check: http://localhost:8000/api/health"
            echo ""
            print_info "πŸ“Š Default Login:"
            echo "  β€’ Username: admin"
            echo "  β€’ Password: admin123"
            echo ""
            print_warning "⚠️ Change the default password immediately!"
            
            # Test health endpoint
            echo ""
            print_step "Testing deployment..."
            sleep 5
            if curl -f http://localhost:8000/api/health >/dev/null 2>&1; then
                print_success "Health check passed - deployment successful!"
            else
                print_warning "Health check failed - check container logs"
                echo "  πŸ” Debug: docker-compose logs"
            fi
            
        else
            print_error "Failed to start services"
            echo "  πŸ” Check logs: docker-compose logs"
            exit 1
        fi
        
    else
        # Use docker build and run
        docker build -t legal-dashboard .
        print_success "Docker image built successfully"
        
        print_step "Starting Legal Dashboard container..."
        docker run -d \
            --name legal-dashboard \
            -p 8000:8000 \
            -v $(pwd)/data:/app/data \
            -v $(pwd)/logs:/app/logs \
            --env-file .env \
            legal-dashboard
        
        print_success "πŸŽ‰ Legal Dashboard container started!"
        echo ""
        print_info "🌐 Access: http://localhost:8000"
        print_info "πŸ” Logs: docker logs legal-dashboard"
        print_info "πŸ›‘ Stop: docker stop legal-dashboard"
    fi
}

# Local development setup
setup_local_development() {
    print_step "Setting up Local Development Environment"
    echo ""
    
    # Check Python version
    if ! command_exists python3; then
        print_error "Python 3 is required but not installed"
        exit 1
    fi
    
    local python_version=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1-2)
    print_info "Python version: $python_version"
    
    # Check if virtual environment exists
    if [[ ! -d "venv" ]]; then
        print_step "Creating virtual environment..."
        python3 -m venv venv
        print_success "Virtual environment created"
    fi
    
    # Activate virtual environment
    print_step "Activating virtual environment..."
    source venv/bin/activate 2>/dev/null || source venv/Scripts/activate 2>/dev/null
    
    # Install dependencies
    print_step "Installing dependencies..."
    show_progress 3 "Installing packages"
    pip install --upgrade pip
    pip install -r requirements-dev.txt
    print_success "Dependencies installed"
    
    # Create .env file if it doesn't exist
    if [[ ! -f ".env" ]]; then
        print_step "Creating development .env file..."
        cat > .env << EOF
# Legal Dashboard Development Configuration
JWT_SECRET_KEY=dev-secret-key-$(date +%s)
DATABASE_DIR=./data
LOG_LEVEL=DEBUG
ENVIRONMENT=development
WORKERS=1
PORT=8000
PYTHONPATH=.
PYTHONUNBUFFERED=1
EOF
        print_success ".env file created for development"
    fi
    
    # Run tests
    print_step "Running comprehensive tests..."
    if python final_test.py; then
        print_success "All tests passed!"
    else
        print_warning "Some tests failed, but you can still run the development server"
    fi
    
    # Create development startup script
    cat > start_dev.sh << 'EOF'
#!/bin/bash
echo "πŸš€ Starting Legal Dashboard Development Server..."
echo ""

# Activate virtual environment
source venv/bin/activate 2>/dev/null || source venv/Scripts/activate 2>/dev/null

# Set development environment
export ENVIRONMENT=development
export LOG_LEVEL=DEBUG

# Start the application
echo "🌐 Development server will be available at:"
echo "  β€’ FastAPI: http://localhost:8000"
echo "  β€’ Gradio: http://localhost:7860 (if running app.py)"
echo ""
echo "πŸ“Š Default Login: admin / admin123"
echo "πŸ›‘ Press Ctrl+C to stop"
echo ""

python run.py
EOF
    
    chmod +x start_dev.sh
    
    print_success "πŸŽ‰ Local development environment ready!"
    echo ""
    print_info "πŸ“ Development files created:"
    echo "  β€’ venv/ - Virtual environment"
    echo "  β€’ .env - Development configuration"
    echo "  β€’ start_dev.sh - Development server launcher"
    echo ""
    print_info "πŸš€ To start development:"
    echo "  ./start_dev.sh"
    echo ""
    print_info "πŸ§ͺ To run tests:"
    echo "  python final_test.py"
    echo ""
    print_warning "⚠️ Remember to activate the virtual environment:"
    echo "  source venv/bin/activate"
}

# Run comprehensive tests
run_comprehensive_tests() {
    print_step "Running Comprehensive Test Suite"
    echo ""
    
    # Check if Python is available
    if ! command_exists python3; then
        print_error "Python 3 is required for testing"
        exit 1
    fi
    
    # Run the test suite
    print_info "Starting comprehensive validation..."
    echo ""
    
    if python3 final_test.py; then
        echo ""
        print_success "πŸŽ‰ All tests passed! Your Legal Dashboard is ready for deployment."
        echo ""
        print_info "πŸ“‹ You can now:"
        echo "  1. Deploy to Hugging Face Spaces"
        echo "  2. Deploy with Docker"
        echo "  3. Run locally for development"
        echo ""
        print_info "πŸ“ž Need help? Check README_FINAL.md"
    else
        echo ""
        print_warning "⚠️ Some tests failed. Please review the issues above."
        echo ""
        print_info "πŸ”§ Common fixes:"
        echo "  β€’ Install missing dependencies: pip install -r requirements.txt"
        echo "  β€’ Check file permissions"
        echo "  β€’ Ensure you're in the project directory"
        echo ""
        print_info "πŸ“ž For detailed troubleshooting, see DEPLOYMENT_CHECKLIST.md"
    fi
}

# Show project status
show_project_status() {
    print_step "Legal Dashboard Project Status"
    echo ""
    
    # Check project structure
    local files_present=0
    local total_files=0
    
    declare -a required_files=(
        "app.py:Gradio interface"
        "run.py:Universal runner"
        "config.py:Configuration manager"
        "final_test.py:Test suite"
        "requirements.txt:Dependencies"
        "Dockerfile:Container config"
        "docker-compose.yml:Multi-service setup"
        ".env:Environment variables"
        "app/main.py:FastAPI application"
        "frontend/index.html:Web dashboard"
    )
    
    print_info "πŸ“ Project Structure:"
    for file_info in "${required_files[@]}"; do
        local file=$(echo $file_info | cut -d':' -f1)
        local desc=$(echo $file_info | cut -d':' -f2)
        total_files=$((total_files + 1))
        
        if [[ -f "$file" ]]; then
            print_success "$file - $desc"
            files_present=$((files_present + 1))
        else
            print_error "$file - $desc (MISSING)"
        fi
    done
    
    echo ""
    local completeness=$((files_present * 100 / total_files))
    print_info "πŸ“Š Project Completeness: $completeness% ($files_present/$total_files files)"
    
    # Check dependencies
    echo ""
    print_info "πŸ”§ System Dependencies:"
    
    if command_exists python3; then
        local python_version=$(python3 --version)
        print_success "Python: $python_version"
    else
        print_error "Python 3: Not installed"
    fi
    
    if command_exists docker; then
        local docker_version=$(docker --version | cut -d' ' -f3 | cut -d',' -f1)
        print_success "Docker: $docker_version"
    else
        print_warning "Docker: Not installed (optional)"
    fi
    
    if command_exists git; then
        local git_version=$(git --version | cut -d' ' -f3)
        print_success "Git: $git_version"
    else
        print_warning "Git: Not installed (needed for HF Spaces)"
    fi
    
    # Deployment readiness
    echo ""
    if [[ $completeness -eq 100 ]]; then
        print_success "πŸŽ‰ Project Status: READY FOR DEPLOYMENT"
        echo ""
        print_info "πŸš€ Available deployment options:"
        echo "  1. Hugging Face Spaces (demo/sharing)"
        echo "  2. Docker (production)"
        echo "  3. Local development"
        echo ""
        print_info "Run ./deploy_now.sh again to start deployment!"
    else
        print_warning "⚠️ Project Status: INCOMPLETE"
        echo ""
        print_info "πŸ”§ Missing files need to be restored or created"
        print_info "Please ensure all required files are present"
    fi
    
    # Show environment info
    echo ""
    print_info "🌍 Environment Information:"
    echo "  β€’ OS: $(detect_os)"
    echo "  β€’ Shell: $SHELL"
    echo "  β€’ Working Directory: $(pwd)"
    echo "  β€’ User: $(whoami)"
    
    # Quick health check
    echo ""
    print_step "Running quick health check..."
    if python3 -c "
import sys
try:
    from config import config
    print('βœ… Configuration system: OK')
    print(f'βœ… Environment detected: {config.environment}')
    print('βœ… Import test: PASSED')
except Exception as e:
    print(f'❌ Import test failed: {e}')
    sys.exit(1)
"; then
        print_success "Quick health check passed"
    else
        print_warning "Quick health check failed - some modules may be missing"
    fi
}

# Run main function
main "$@"

echo ""
print_info "Legal Dashboard Deployment Assistant - Complete"
print_info "For support, check README_FINAL.md or DEPLOYMENT_CHECKLIST.md"
echo ""