|
1 | | -# sv |
| 1 | +# SnapSort |
2 | 2 |
|
3 | | -Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). |
| 3 | +A very opinionated solution for a personal problem of organizing a photos/videos library. SnapSort helps you organize |
| 4 | +media files (images/videos) and edit metadata. |
4 | 5 |
|
5 | | -## Creating a project |
| 6 | +## Features |
6 | 7 |
|
7 | | -If you're seeing this, you've probably already done this step. Congrats! |
| 8 | +### Metadata Management |
8 | 9 |
|
9 | | -```bash |
10 | | -# create a new project in the current directory |
11 | | -npx sv create |
| 10 | +- **Create Keywords**: Create different types of keywords (Album, Location, Person, Animal, Group, or Other) which can |
| 11 | + be used to tag files. |
| 12 | +- **Edit Metadata**: Modify capture date and time, title/descriptions, GPS data, and keywords for your media files. |
| 13 | +- **Batch Editing**: Apply metadata changes to multiple files at once, saving time and ensuring consistency. |
| 14 | +- **View Metadata**: View all metadata associated with your library files. |
| 15 | +- **EXIF Data Export**: Export metadata from your library files for backup or analysis. |
| 16 | + |
| 17 | +### Library Organization |
| 18 | + |
| 19 | +Media library is organized in a "Year / Month / Day" hierarchy. The Day folder may have a `- Keyword` suffix |
| 20 | +depending on whether any of the files within that folder contains a keyword which can be used as a folder label. |
| 21 | + |
| 22 | +The files follow the following naming convention: `TYPE-YYYYMMDD-INDEX` |
12 | 23 |
|
13 | | -# create a new project in my-app |
14 | | -npx sv create my-app |
15 | 24 | ``` |
| 25 | +library/ |
| 26 | + |- 2025/ |
| 27 | + |- 01 - January/ |
| 28 | + |- 01/ |
| 29 | + |- IMG-20250101-000.jpg |
| 30 | + |- VID-20250101-000.mp4 |
| 31 | + |- 02 - Birthday/ |
| 32 | + |- IMG-20250102-000.jpg |
| 33 | + |- IMG-20250102-001.jpg |
| 34 | +``` |
| 35 | + |
| 36 | +## Prerequisites |
| 37 | + |
| 38 | +- [Node.js](https://nodejs.org/) (v18 or later) |
| 39 | +- [PNPM](https://pnpm.io/) package manager |
| 40 | +- [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) (for PostgreSQL database) |
| 41 | +- [ExifTool](https://exiftool.org/) (for metadata manipulation) |
| 42 | +- [FFmpeg](https://ffmpeg.org/) (for video processing) |
| 43 | + |
| 44 | +## Installation |
| 45 | + |
| 46 | +1. Clone the repository: |
| 47 | + |
| 48 | + ```bash |
| 49 | + git clone https://github.com/bhatushar/snap-sort.git |
| 50 | + cd snap-sort |
| 51 | + ``` |
| 52 | + |
| 53 | +2. Install dependencies: |
| 54 | + |
| 55 | + ```bash |
| 56 | + pnpm install |
| 57 | + ``` |
| 58 | + |
| 59 | +3. Create a `.env` file based on the provided `.env.example`: |
| 60 | + |
| 61 | + ```bash |
| 62 | + cp .env.example .env |
| 63 | + ``` |
16 | 64 |
|
17 | | -## Developing |
| 65 | +4. Edit the `.env` file to configure your environment: |
18 | 66 |
|
19 | | -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: |
| 67 | + - Set database credentials |
| 68 | + - Configure paths to ExifTool and FFmpeg |
| 69 | + - Set file storage directories |
| 70 | + |
| 71 | +5. Start the PostgreSQL database using Docker: |
| 72 | + |
| 73 | + ```bash |
| 74 | + pnpm db:start |
| 75 | + ``` |
| 76 | + |
| 77 | +6. Initialize the database: |
| 78 | + ```bash |
| 79 | + pnpm db:push |
| 80 | + ``` |
| 81 | + |
| 82 | +## Running the Application |
| 83 | + |
| 84 | +### Development Mode |
| 85 | + |
| 86 | +Run the application in development mode: |
20 | 87 |
|
21 | 88 | ```bash |
22 | | -npm run dev |
| 89 | +pnpm dev |
| 90 | +``` |
23 | 91 |
|
24 | | -# or start the server and open the app in a new browser tab |
25 | | -npm run dev -- --open |
| 92 | +To make the development server accessible on your local network: |
| 93 | + |
| 94 | +```bash |
| 95 | +pnpm dev-network |
26 | 96 | ``` |
27 | 97 |
|
28 | | -## Building |
| 98 | +### Production Mode |
| 99 | + |
| 100 | +Build the application for production: |
| 101 | + |
| 102 | +```bash |
| 103 | +pnpm build |
| 104 | +``` |
29 | 105 |
|
30 | | -To create a production version of your app: |
| 106 | +Preview the production build: |
31 | 107 |
|
32 | 108 | ```bash |
33 | | -npm run build |
| 109 | +pnpm preview |
| 110 | +``` |
| 111 | + |
| 112 | +Run the production server: |
| 113 | + |
| 114 | +```bash |
| 115 | +node build |
| 116 | +``` |
| 117 | + |
| 118 | +## Database Management |
| 119 | + |
| 120 | +- Push schema changes to the database: |
| 121 | + |
| 122 | + ```bash |
| 123 | + pnpm db:push |
| 124 | + ``` |
| 125 | + |
| 126 | +- Create migrations: |
| 127 | + |
| 128 | + ```bash |
| 129 | + pnpm db:migrate |
| 130 | + ``` |
| 131 | + |
| 132 | +- Open Drizzle Studio to manage database: |
| 133 | + ```bash |
| 134 | + pnpm db:studio |
| 135 | + ``` |
| 136 | + |
| 137 | +## Project Structure |
| 138 | + |
| 139 | +- `/src`: Source code |
| 140 | + - `/lib`: Library code |
| 141 | + - `/server`: Server-side code |
| 142 | + - `/db`: Database models and operations |
| 143 | + - `/routes`: SvelteKit routes |
| 144 | +- `/static`: Static assets |
| 145 | + |
| 146 | +## Configuration |
| 147 | + |
| 148 | +The application requires several environment variables to be set in the `.env` file: |
| 149 | + |
| 150 | +### Database Configuration |
| 151 | + |
| 152 | +``` |
| 153 | +DATABASE_URL=postgresql://root:mysecretpassword@localhost:5432/snapsort |
| 154 | +POSTGRES_USER=root |
| 155 | +POSTGRES_PASSWORD=mysecretpassword |
| 156 | +``` |
| 157 | + |
| 158 | +### External Tools |
| 159 | + |
| 160 | +``` |
| 161 | +EXIFTOOL_PATH="/path/to/exiftool" |
| 162 | +FFMPEG_PATH="/path/to/ffmpeg" |
| 163 | +``` |
| 164 | + |
| 165 | +### File Storage |
| 166 | + |
| 167 | +``` |
| 168 | +FILE_UPLOAD_DIR="/path/to/uploaded-files" |
| 169 | +LIBRARY_ROOT_DIR="/path/to/library" |
34 | 170 | ``` |
35 | 171 |
|
36 | | -You can preview the production build with `npm run preview`. |
| 172 | +## Usage |
37 | 173 |
|
38 | | -> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. |
| 174 | +1. Start the application and navigate to the web interface |
| 175 | +2. Create new keywords |
| 176 | +3. Upload your media files |
| 177 | +4. Edit metadata as needed (date/time, description, GPS data, keywords) |
| 178 | +5. Apply the changes to temporarily modify the queued files |
| 179 | +6. Move files to the library to permanently save files |
| 180 | +7. Export metadata when needed for backup |
0 commit comments