I am building an **Electron desktop app** using **React, Vite, ShadCN, Jotai, React Query, and SQLite** for state and data management. The app is a **high school library management system** used exclusively by the **school director**. The app will manage **books, students, loans, archives**, and offer **statistics** to show the necessary data in an easy-to-understand format. Below is a detailed breakdown of the project's requirements and architecture:

### **Project Details:**
1. **Authentication**:
   - The app should have a **login page** to authenticate users, only allowing access to the school director.
   - There should also be a **welcome page** for first-time users that helps register the first account.
   - Passwords should be securely hashed using **bcrypt**.

2. **Main Pages**:
   - **Main Page (Dashboard)**: This should display **statistics** related to the system (total books, students, active loans, etc.).
   - **Books Page**: 
     - This page allows for **adding, editing, deleting** books.
     - Books should be organized by **school year** (the system needs to manage different school years).
   - **Students Page**:
     - Add, edit, delete students.
     - Add students via **Excel import** (use the `xlsx` library for this feature).
   - **Loans Page**:
     - Show both **open** and **completed loans** with their statuses.
     - Ability to **add or delete loans**.
     - Loans should only be created for students who have a **library card**.
   - **Archive Page**:
     - A simple table displaying archived items.
     - Add, edit, and delete archive items.
   - **Statistics Page**:
     - Display key data points in a visually appealing format (use **charts** to represent loan statuses, number of books, etc.).

3. **School Year Management**:
   - Each dataset (books, students, loans) should be associated with a **school year**.
   - Users should be able to select a school year and add/edit/delete the data for that specific year.
   - When switching between school years, all data should update accordingly.

4. **SQLite Database**:
   - Use **SQLite** as the local database to store all data (books, students, loans, archives, users).
   - Each table in the database should include a **school year field** to track which data belongs to which year.
   - Ensure **CRUD operations** for books, students, loans, and archives work properly.

5. **General Requirements**:
   - The app should be **fast** and **lightweight** (use Vite for fast builds).
   - **Electron** should handle the **main process** (window management, database access) and securely pass information to the **React frontend** using **IPC (Inter-Process Communication)**.
   - **Preload scripts** should be used to securely expose APIs for React to interact with the SQLite database.
   - Use **Jotai** for global state management (for user sessions, school year selection, etc.).
   - Use **React Query** to handle data fetching and caching between the frontend and backend.
   - The UI should be styled with **ShadCN** components to ensure a clean, professional interface.

### **Tech Stack**:
1. **Electron**: To build the desktop app and manage local file systems.
2. **React (with Vite)**: For the frontend and faster builds.
3. **ShadCN**: To ensure a modern and clean UI.
4. **Jotai**: To manage global state (such as authentication and school year selection).
5. **React Query**: To handle API fetching and caching for efficient communication with the backend.
6. **SQLite**: For the local database to store and manage books, students, loans, and archives.
7. **bcrypt**: For password hashing and user authentication.
8. **xlsx**: To allow importing student data from Excel files.

### **Detailed Requirements**:
- Explain how to implement **state management** using **Jotai** for user authentication and global school year management.
- Walk through the process of connecting the **SQLite database** to **Electron** and how to set up **IPC** to handle communication between the **main process** (Electron) and the **renderer process** (React).
- Provide instructions for setting up **React Query** to handle data fetching for books, students, and loans.
- Describe how to create **custom hooks** in the React app for various CRUD operations using the Electron API.
- Provide guidance on using **ShadCN** to build reusable components for forms, tables, and charts.