feat: Add comprehensive installation script for PunimTag Web
This commit introduces an `install.sh` script that automates the installation of system dependencies, Python packages, and frontend dependencies for the PunimTag Web application. The script checks for required software versions, installs PostgreSQL and Redis on Ubuntu/Debian systems, sets up databases, creates a Python virtual environment, and installs necessary dependencies. Additionally, the README.md is updated to include installation instructions and prerequisites, highlighting the new automated installation option. This enhancement simplifies the setup process for users.
This commit is contained in:
@@ -29,12 +29,42 @@ A fast, simple, and modern web application for organizing and tagging photos usi
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Python 3.12 or higher
|
||||
- Node.js 18+ and npm
|
||||
- Virtual environment (recommended)
|
||||
- **Python 3.12 or higher** (with pip)
|
||||
- **Node.js 18+ and npm**
|
||||
- **PostgreSQL** (for production, optional for development with SQLite)
|
||||
- **Redis** (for background job processing)
|
||||
|
||||
**Note:** The automated installation script (`./install.sh`) will install PostgreSQL and Redis automatically on Ubuntu/Debian systems.
|
||||
|
||||
### Installation
|
||||
|
||||
#### Option 1: Automated Installation (Recommended for Linux/Ubuntu/Debian)
|
||||
|
||||
The automated installation script will install all system dependencies, Python packages, frontend dependencies, and set up databases:
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone <repository-url>
|
||||
cd punimtag
|
||||
|
||||
# Run the installation script
|
||||
./install.sh
|
||||
```
|
||||
|
||||
The script will:
|
||||
- ✅ Check prerequisites (Python 3.12+, Node.js 18+)
|
||||
- ✅ Install system dependencies (PostgreSQL, Redis) on Ubuntu/Debian
|
||||
- ✅ Set up PostgreSQL databases (main + auth)
|
||||
- ✅ Create Python virtual environment
|
||||
- ✅ Install all Python dependencies
|
||||
- ✅ Install all frontend dependencies
|
||||
- ✅ Create `.env` configuration files
|
||||
- ✅ Create necessary data directories
|
||||
|
||||
**Note:** On macOS or other systems, the script will skip system dependency installation. You'll need to install PostgreSQL and Redis manually.
|
||||
|
||||
#### Option 2: Manual Installation
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone <repository-url>
|
||||
@@ -56,7 +86,11 @@ cd ..
|
||||
### Database Setup
|
||||
|
||||
**PostgreSQL (Default - Network Database):**
|
||||
The application is configured to use PostgreSQL by default. The database connection is configured via the `.env` file.
|
||||
The application is configured to use PostgreSQL by default. The application requires **two separate databases**:
|
||||
1. **Main database** (`punimtag`) - Stores photos, faces, people, tags, and backend user accounts
|
||||
2. **Auth database** (`punimtag_auth`) - Stores frontend website user accounts and moderation data
|
||||
|
||||
Both database connections are configured via the `.env` file.
|
||||
|
||||
**Install PostgreSQL (if not installed):**
|
||||
```bash
|
||||
@@ -69,13 +103,21 @@ sudo systemctl enable postgresql
|
||||
./scripts/setup_postgresql.sh
|
||||
```
|
||||
|
||||
**Create Database and User:**
|
||||
**Create Main Database and User:**
|
||||
```bash
|
||||
sudo -u postgres psql -c "CREATE USER punimtag WITH PASSWORD 'punimtag_password';"
|
||||
sudo -u postgres psql -c "CREATE DATABASE punimtag OWNER punimtag;"
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE punimtag TO punimtag;"
|
||||
```
|
||||
|
||||
**Create Auth Database (for frontend website user accounts):**
|
||||
```bash
|
||||
sudo -u postgres psql -c "CREATE DATABASE punimtag_auth OWNER punimtag;"
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE punimtag_auth TO punimtag;"
|
||||
```
|
||||
|
||||
**Note:** The auth database (`punimtag_auth`) stores user accounts for the frontend website, separate from the main application database. Both databases are required for full functionality.
|
||||
|
||||
**Grant DELETE Permissions on Auth Database Tables:**
|
||||
If you encounter permission errors when trying to delete records from the auth database (e.g., when using "Clear database" in the admin panel), grant DELETE permissions:
|
||||
|
||||
@@ -98,9 +140,13 @@ Alternatively, use the automated script (requires sudo password):
|
||||
```
|
||||
|
||||
**Configuration:**
|
||||
The `.env` file contains the database connection string:
|
||||
The `.env` file contains both database connection strings:
|
||||
```bash
|
||||
# Main application database
|
||||
DATABASE_URL=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag
|
||||
|
||||
# Auth database (for frontend website users)
|
||||
DATABASE_URL_AUTH=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag_auth
|
||||
```
|
||||
|
||||
**Automatic Initialization:**
|
||||
@@ -128,12 +174,22 @@ DATABASE_URL=sqlite:///data/punimtag.db
|
||||
|
||||
**Database Schema:**
|
||||
The web version uses the **exact same schema** as the desktop version for full compatibility:
|
||||
- `photos` - Photo metadata (path, filename, date_taken, processed)
|
||||
- `photos` - Photo metadata (path, filename, date_taken, processed, media_type)
|
||||
- `people` - Person records (first_name, last_name, middle_name, maiden_name, date_of_birth)
|
||||
- `faces` - Face detections (encoding, location, quality_score, face_confidence, exif_orientation)
|
||||
- `faces` - Face detections (encoding, location, quality_score, face_confidence, exif_orientation, excluded)
|
||||
- `person_encodings` - Person face encodings for matching
|
||||
- `tags` - Tag definitions
|
||||
- `phototaglinkage` - Photo-tag relationships (with linkage_type)
|
||||
- `users` - Backend user accounts (with password hashing, roles, permissions)
|
||||
- `photo_person_linkage` - Direct photo-person associations (for videos)
|
||||
- `role_permissions` - Role-based permission matrix
|
||||
|
||||
**Auth Database Schema:**
|
||||
The separate auth database (`punimtag_auth`) stores frontend website user accounts:
|
||||
- `users` - Frontend website user accounts (email, password_hash, is_active)
|
||||
- `pending_photos` - Photos pending moderation
|
||||
- `pending_identifications` - Face identifications pending approval
|
||||
- `inappropriate_photo_reports` - Reported photos for review
|
||||
|
||||
### Running the Application
|
||||
|
||||
@@ -429,7 +485,11 @@ punimtag/
|
||||
**PostgreSQL (Default - Network Database):**
|
||||
The application uses PostgreSQL by default, configured via the `.env` file:
|
||||
```bash
|
||||
# Main application database
|
||||
DATABASE_URL=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag
|
||||
|
||||
# Auth database (for frontend website users)
|
||||
DATABASE_URL_AUTH=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag_auth
|
||||
```
|
||||
|
||||
**SQLite (Alternative - Local Database):**
|
||||
@@ -438,6 +498,8 @@ To use SQLite instead, comment out or remove the `DATABASE_URL` line in `.env`,
|
||||
DATABASE_URL=sqlite:///data/punimtag.db
|
||||
```
|
||||
|
||||
**Note:** When using SQLite, the auth database (`DATABASE_URL_AUTH`) should still be configured as PostgreSQL if you need frontend website user authentication features. The auth database is optional but required for full multi-user functionality.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Configuration is managed via the `.env` file in the project root. A `.env.example` template is provided.
|
||||
@@ -447,6 +509,9 @@ Configuration is managed via the `.env` file in the project root. A `.env.exampl
|
||||
# Database (PostgreSQL by default)
|
||||
DATABASE_URL=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag
|
||||
|
||||
# Auth Database (for frontend website user accounts - separate from main database)
|
||||
DATABASE_URL_AUTH=postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag_auth
|
||||
|
||||
# JWT Secrets (change in production!)
|
||||
SECRET_KEY=dev-secret-key-change-in-production
|
||||
|
||||
@@ -458,6 +523,13 @@ ADMIN_PASSWORD=admin
|
||||
PHOTO_STORAGE_DIR=data/uploads
|
||||
```
|
||||
|
||||
**Frontend Configuration:**
|
||||
Create a `.env` file in the `frontend/` directory:
|
||||
```bash
|
||||
# Backend API URL (must be accessible from browsers)
|
||||
VITE_API_URL=http://127.0.0.1:8000
|
||||
```
|
||||
|
||||
**Note:** The `.env` file is automatically loaded by the application using `python-dotenv`. Environment variables can also be set directly in your shell if preferred.
|
||||
|
||||
---
|
||||
@@ -507,8 +579,16 @@ PHOTO_STORAGE_DIR=data/uploads
|
||||
- `python-jose[cryptography]==3.3.0`
|
||||
- `redis==5.0.8`
|
||||
- `rq==1.16.2`
|
||||
- `psycopg2-binary==2.9.9` (PostgreSQL driver)
|
||||
- `python-multipart==0.0.9` (file uploads)
|
||||
- `python-dotenv==1.0.0` (environment variables)
|
||||
- `bcrypt==4.1.2` (password hashing)
|
||||
- `deepface>=0.0.79`
|
||||
- `tensorflow>=2.13.0`
|
||||
- `opencv-python>=4.8.0`
|
||||
- `retina-face>=0.0.13`
|
||||
- `numpy>=1.21.0`
|
||||
- `pillow>=8.0.0`
|
||||
|
||||
**Frontend:**
|
||||
- `react==18.2.0`
|
||||
@@ -522,10 +602,11 @@ PHOTO_STORAGE_DIR=data/uploads
|
||||
## 🔒 Security
|
||||
|
||||
- JWT-based authentication with refresh tokens
|
||||
- Password hashing (to be implemented in production)
|
||||
- Password hashing with bcrypt
|
||||
- CORS configured for development (restrict in production)
|
||||
- SQL injection prevention via SQLAlchemy ORM
|
||||
- Input validation via Pydantic schemas
|
||||
- Separate auth database for frontend website user accounts
|
||||
|
||||
**⚠️ Note**: Default credentials (`admin`/`admin`) are for development only. Change in production!
|
||||
|
||||
@@ -533,9 +614,8 @@ PHOTO_STORAGE_DIR=data/uploads
|
||||
|
||||
## 🐛 Known Limitations
|
||||
|
||||
- Single-user mode only (multi-user support planned)
|
||||
- Multi-user support with role-based permissions (single-user mode deprecated)
|
||||
- SQLite for development (PostgreSQL recommended for production)
|
||||
- No password hashing yet (plain text comparison - fix before production)
|
||||
- GPU acceleration not yet implemented (CPU-only for now)
|
||||
- Large databases (>50K photos) may require optimization
|
||||
- DeepFace model downloads on first use (can take 5-10 minutes, ~100MB)
|
||||
|
||||
Reference in New Issue
Block a user