# SAIpp - Barcode Scanner & MariaDB Connector Android application developed in Kotlin using Jetpack Compose that scans barcodes and saves them directly to a self-hosted MariaDB database. ## 🚀 Features - **Instant Scan**: The camera opens automatically upon application startup. - **Connection Status**: Real-time indicator at the top showing if the app can reach the MariaDB server. - **Visual Overlay**: Centered scanning guide with a red line to help align barcodes. - **ML Kit Integration**: High-performance barcode detection (HD 720p analysis). - **Confirmation Flow**: Scanned results are shown in a popup dialog before saving. - **MariaDB Connectivity**: Direct connection to a remote database via JDBC. - **Localization**: All app strings are managed in `strings.xml` for easy translation. - **Modern UI**: Built with Jetpack Compose and Material 3. - **Permission Handling**: Automatic runtime camera permission requests. ## 🛠️ Requirements - Android device with API 34+ (Android 14+). - MariaDB Server accessible from the mobile device network on port 3306. - Camera hardware. ## 📱 User Interface The app features a professional scanning interface: 1. **Connection Bar**: A status pill at the top (Green: Connected, Red: Error, Gray: Checking). 2. **Scanner Guide**: A white square frame indicates the target area with a red alignment line. 3. **Detection Popup**: When a code is read, a dialog appears with the value. 4. **Database Actions**: Buttons to "Guardar" (Save) or "Cerrar" (Dismiss). ## ⚙️ Configuration ### 1. Database Setup Ensure your MariaDB database has a table named `scans`. You can use the following SQL: ```sql CREATE TABLE scans ( id INT AUTO_INCREMENT PRIMARY KEY, barcode VARCHAR(255) NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP ); ``` ### 2. App Credentials Update your database connection details in: `app/src/main/java/com/example/saipp/data/MariaDbConnection.kt` > [!IMPORTANT] > Use the raw domain or IP for the `HOST`. **Do NOT include `https://`**. ```kotlin private const val HOST = "mariadb.peta9.com" // Example: "192.168.1.50" private const val PORT = "3306" private const val DATABASE = "sais_db" private const val USER = "sais_dba" private const val PASSWORD = "your_password" ``` ### 3. Network Access - Ensure the MariaDB port (default **3306**) is open. - Your MariaDB user must allow remote connections: ```sql GRANT ALL PRIVILEGES ON sais_db.* TO 'sais_dba'@'%' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES; ``` ## 📦 Dependencies - **CameraX**: For camera preview and high-resolution frame capture. - **ML Kit Barcode Scanning**: For processing all barcode formats. - **MariaDB Java Client**: JDBC driver for database communication. - **Coroutines**: For asynchronous database and connection checks. ## ⚠️ Security Warning > [!CAUTION] > This project uses a **direct JDBC connection**. This is suitable for personal projects or internal tools, but is **not recommended for production apps** as it requires storing credentials in the code and exposing database ports. ## 📄 License This project is for educational/personal use.