# Server Monitoring System v2 - Enhanced Architecture

## New Project Structure

```
Server_Monitorizare_v2/
├── app/
│   ├── __init__.py              # Flask app factory
│   ├── models/                  # Database models
│   │   ├── __init__.py
│   │   ├── device.py           # Device model
│   │   ├── log.py              # Log model with message aliases
│   │   └── file.py             # File uploads model
│   ├── api/                     # REST API endpoints
│   │   ├── __init__.py
│   │   ├── logs.py             # Log endpoints
│   │   ├── devices.py          # Device management
│   │   ├── files.py            # File upload handling
│   │   └── ansible.py          # SSH/Ansible endpoints
│   ├── services/                # Business logic layer
│   │   ├── __init__.py
│   │   ├── log_service.py      # Log processing & compression
│   │   ├── device_service.py   # Device management
│   │   ├── ansible_service.py  # SSH/Ansible operations
│   │   └── file_service.py     # File processing
│   ├── web/                     # Web interface
│   │   ├── __init__.py
│   │   ├── main.py             # Main dashboard routes
│   │   ├── devices.py          # Device management UI
│   │   └── ansible.py          # Ansible web interface
│   └── utils/                   # Utility functions
│       ├── __init__.py
│       ├── database.py         # DB utilities
│       ├── ssh_utils.py        # SSH helpers
│       └── compression.py      # Message compression
├── config/
│   ├── config.py               # Configuration management
│   └── database_config.py      # Database settings
├── templates/
│   ├── base.html               # Base template
│   ├── dashboard.html          # Enhanced dashboard
│   ├── ansible/                # Ansible interface templates
│   │   ├── inventory.html
│   │   ├── playbooks.html
│   │   └── execution.html
│   └── devices/                # Device management templates
├── ansible/
│   ├── playbooks/              # Ansible playbooks
│   ├── inventory/              # Dynamic inventory
│   └── roles/                  # Custom roles
├── migrations/                 # Database migrations
├── data/
│   ├── uploads/                # File uploads storage
│   └── backups/                # Database backups
└── main.py                     # Application entry point
```

## Key Improvements

### 1. Better Database Structure
- Normalized database schema with separate tables
- Message aliases and compression
- File upload tracking
- Device metadata storage

### 2. Modular Architecture
- Separation of concerns (API, Web, Services, Models)
- Pluggable components
- Better testability

### 3. Enhanced Message Processing
- Message compression and aliases
- Efficient storage with references
- Client message size reduction

### 4. SSH/Ansible Integration
- Web-based Ansible interface
- Dynamic inventory management
- Playbook execution tracking
- SSH key management