# GEMINI.md ## Project Overview This project is a Python-based web application designed to manage a home media server. It provides a web interface to interact with various services, including Samba file shares, video duplicate identification, and comics management. The backend is built with the **FastAPI** framework and uses **SQLAlchemy** for database interactions. The application is structured with a clear separation of concerns, using FastAPI routers to define API endpoints for different services. ### Key Features: - **Samba File Share Management:** Provides full access to Samba shares, allowing users to list, upload, download, delete, and rename files. - **Video Duplicate Identification:** Scans video files and identifies potential duplicates based on attributes like duration, visual similarity (using image hashing), file size, and file name. - **Comics Management:** Organizes comic book archives by converting `.zip` files to `.cbz` format and sorting them into appropriately named folders. ## Building and Running This project is a Python application. To run it, you'll need to have Python and the required dependencies installed. ### Dependencies The project's dependencies are listed in `backend/requirements.txt`. You can install them using pip: ```bash pip install -r backend/requirements.txt ``` ### Running the Application The application is run using `uvicorn`, a fast ASGI server. ```bash # TODO: Confirm the exact command to run the application. # The following is a common command for FastAPI applications. cd backend/ uvicorn app.main:app --reload ``` This will start the development server. You can then access the API at `http://127.0.0.1:8000`. ## Development Conventions The project follows standard conventions for FastAPI applications. ### Project Structure - `main.py`: The main entry point for the FastAPI application. - `database.py`: Contains the SQLAlchemy setup and database connection logic. - `models.py`: Defines the SQLAlchemy models (database schemas). - `routers/`: Contains the API endpoints for different services (Samba, comics, duplicates). - `samba_manager.py`, `comics_manager.py`, `duplicates_manager.py`: These files contain the business logic for each service. - `config.py`: Manages application settings using `pydantic-settings`. ### API Endpoints The API is organized into the following routers: - **/samba**: Endpoints for Samba file share management. - **/comics**: Endpoints for organizing comics. - **/duplicates**: Endpoints for scanning and finding video duplicates. ### Database The application uses SQLAlchemy for database interactions. The database models are defined in `models.py`, and the database connection is managed in `database.py`. A database session is made available to the application using a FastAPI dependency (`get_db` in `main.py`).