Skip to content

Commit e1f2cbf

Browse files
Docs: Rust backend
1 parent 1966c18 commit e1f2cbf

File tree

11 files changed

+181
-29
lines changed

11 files changed

+181
-29
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# Backend Setup
2-
1+
# Python Backend Setup
32

43
## Setup Directory
4+
55
!!! note "Base Directory"
6-
All commands executed below are with respect to the `backend/` directory
6+
All commands executed below are with respect to the `backend/` directory
77

88
### Installing requirments
99

1010
We suggest setting up a virtual environment and run the following command
11+
1112
```bash
1213
pip install -r requirements.txt
1314
```
@@ -16,8 +17,8 @@ The entry point for backend is `main.py` , since PictoPy is built on top of Fast
1617
`.bat` and `.sh` formats.
1718

1819
!!! note "UNIX Development"
19-
For UNIX based systems, to run in development mode run
20-
```bash
20+
For UNIX based systems, to run in development mode run
21+
`bash
2122
./run.sh --test
22-
```
23+
`
2324
The backend should now be successfully running on port 8000 by default. To change this modify the start-up scripts.

docs/backend/backend_rust/api.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## API Documentation
2+
3+
The Rust backend provides the following commands that can be invoked from the frontend:
4+
5+
### 1. get_folders_with_images
6+
- **Description**: Retrieves folders containing images from a specified directory.
7+
- **Parameters**:
8+
- `directory`: String
9+
- **Returns**: `Vec<PathBuf>`
10+
11+
### 2. get_images_in_folder
12+
- **Description**: Gets all images in a specific folder.
13+
- **Parameters**:
14+
- `folder_path`: String
15+
- **Returns**: `Vec<PathBuf>`
16+
17+
### 3. get_all_images_with_cache
18+
- **Description**: Retrieves all images, organized by year and month, with caching.
19+
- **Parameters**:
20+
- `directory`: String
21+
- **Returns**: `Result<HashMap<u32, HashMap<u32, Vec<String>>>, String>`
22+
23+
### 4. get_all_videos_with_cache
24+
- **Description**: Retrieves all videos, organized by year and month, with caching.
25+
- **Parameters**:
26+
- `directory`: String
27+
- **Returns**: `Result<HashMap<u32, HashMap<u32, Vec<String>>>, String>`
28+
29+
### 5. delete_cache
30+
- **Description**: Deletes all cached data.
31+
- **Parameters**: None
32+
- **Returns**: `bool`
33+
34+
## Usage Example
35+
36+
```javascript
37+
// In your frontend JavaScript/TypeScript code:
38+
import { invoke } from '@tauri-apps/api/tauri';
39+
40+
// Example: Get all images with cache
41+
const imagesData = await invoke('get_all_images_with_cache', { directory: '/path/to/images' });
42+
43+
// Example: Delete cache
44+
const cacheDeleted = await invoke('delete_cache');
45+
```
46+
47+
## Key Components
48+
49+
- **FileService**: Handles file system operations for images and videos.
50+
- **CacheService**: Manages caching of folders, images, and videos.
51+
- **FileRepository**: Interacts directly with the file system to retrieve file information.
52+
- **CacheRepository**: Handles reading from and writing to cache files.
53+
54+
This backend architecture provides efficient file management and caching capabilities, enhancing the performance of image and video retrieval operations in the Tauri application.

docs/backend/backend_rust/setup.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Rust Backend Setup
2+
3+
## Prerequisites
4+
5+
Before setting up the frontend, ensure you have the following installed:
6+
7+
- [Node.js](https://nodejs.org/) (LTS version recommended)
8+
- npm (comes with Node.js)
9+
- [Rust](https://www.rust-lang.org/tools/install) (latest stable version)
10+
- [Tauri CLI](https://v2.tauri.app/start/prerequisites/)
11+
12+
For a comprehensive guide on prerequisites, refer to the [Tauri Prerequisites](https://v2.tauri.app/start/prerequisites/) documentation.
13+
14+
## Setup Directory
15+
16+
!!! note "Base Directory"
17+
All commands executed below are with respect to the `frontend/` directory
18+
19+
### Installing Dependencies
20+
21+
1. Navigate to the frontend directory:
22+
```bash
23+
cd frontend
24+
```
25+
26+
2. Install the project dependencies:
27+
```bash
28+
npm install
29+
```
30+
31+
For more information on npm commands, see the [npm documentation](https://docs.npmjs.com/).
32+
33+
## Running the Application
34+
35+
To start the Tauri application in development mode, run:
36+
37+
```bash
38+
npm run tauri dev
39+
```
40+
41+
This command will:
42+
- Start the [Vite](https://vitejs.dev/) development server for the frontend
43+
- Compile the Rust backend
44+
- Launch the Tauri application window
45+
46+
For more details on Tauri commands, check the [Tauri CLI documentation](https://tauri.app/v1/api/cli).
47+
48+
!!! note "First Run"
49+
The first run might take longer as it needs to compile the Rust code.

docs/index.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ PictoPy is a modern desktop app designed to transform the handling of digital ph
77
<img src="assets/AOSSIE-logo.png" alt="AOSSIE Logo" style="display:flex; margin:0 auto; justify-content: center;">
88
</div>
99

10-
This project was announced by [AOSSIE](https://aossie.org/), an umbrella organization and was to be implemented from scratch. It provides features such as object detection and face similarity,
11-
offering smart tagging capabilities for photos based on objects, faces.
10+
This project was announced by [AOSSIE](https://aossie.org/), an umbrella organization and was to be implemented from scratch. It provides features such as object detection and face similarity, offering smart tagging capabilities for photos based on objects, faces.
1211

1312
<div style="display:flex; margin:0 auto; justify-content: center;">
14-
<div style="width:33%">
13+
<div style="width:25%">
1514
<h2>Overview</h2>
1615
<ul>
1716
<li><a href='./overview/features'>
@@ -24,37 +23,52 @@ offering smart tagging capabilities for photos based on objects, faces.
2423
</li>
2524
</ul>
2625
</div>
27-
<div style="width:33%">
28-
<h2>Backend</h2>
26+
<div style="width:25%">
27+
<h2>Backend Python</h2>
2928
<ul>
3029
<li>
31-
<a href="./backend/setup">
30+
<a href="./backend/backend_python/setup">
3231
Setup
3332
</a>
3433
</li>
3534
<li>
36-
<a href="./backend/database">
35+
<a href="./backend/backend_python/database">
3736
Database
3837
</a>
3938
</li>
4039
<li>
41-
<a href="./backend/directory-structure">
40+
<a href="./backend/backend_python/directory-structure">
4241
Directory Structure
4342
</a>
4443
</li>
4544
<li>
46-
<a href="./backend/api">
45+
<a href="./backend/backend_python/api">
4746
API
4847
</a>
4948
</li>
5049
<li>
51-
<a href="./backend/image-processing">
50+
<a href="./backend/backend_python/image-processing">
5251
Image Processing
5352
</a>
5453
</li>
5554
</ul>
5655
</div>
57-
<div style="width:33%">
56+
<div style="width:25%">
57+
<h2>Backend Rust</h2>
58+
<ul>
59+
<li>
60+
<a href="./backend/backend_rust/setup">
61+
Setup
62+
</a>
63+
</li>
64+
<li>
65+
<a href="./backend/backend_rust/api">
66+
API
67+
</a>
68+
</li>
69+
</ul>
70+
</div>
71+
<div style="width:25%">
5872
<h2>Frontend</h2>
5973
<ul>
6074
<li>
@@ -79,4 +93,4 @@ offering smart tagging capabilities for photos based on objects, faces.
7993
</li>
8094
</ul>
8195
</div>
82-
</div>
96+
</div>

docs/overview/architecture.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# Architecture
2+
23
## Frontend
34

4-
## Backend
5+
For the frontend of our application, we use Tauri in combination with React. This allows us to create a desktop application with a web-based user interface. React handles the UI components and user interactions, while Tauri provides the bridge between our web-based frontend and Rust-based backend.
6+
7+
Key points:
8+
9+
- Tauri: Enables building the desktop application
10+
- React: Used for creating the user interface
11+
- Rust: Powers the backend, which the frontend communicates with through Tauri's API
12+
13+
This combination allows us to leverage web technologies for the UI while benefiting from Rust's performance and security for core functionalities.
14+
15+
## Backend Python
16+
517
<div style="text-align: center;">
618
<img src="../../assets/backend-architecture.jpeg" alt="Backend Architecture" style="width: 80%; max-width: 600px; height: auto; display: block; margin: 0 auto;">
719
</div>
@@ -11,10 +23,17 @@ For the backend, we rely on several techstack, our database is served on sqlite
1123
with FastAPI. Our models are from various sources, we use YOLO models for object and face detection while we use FaceNet for generating the embeddings
1224
of the faces detected. All these models are run on ONNX runtime to avoid heavy dependancies, keeping the application light weight.
1325

14-
1526
We use DBSCAN algorithm to perform clustering for face embeddings generated. All of our database is in SQL (sqlite) and our API calls rely
1627
on queries from the backend.
1728

1829
!!! note "Note"
19-
We discuss all of the features and configuration of our application in further sections of the documentation. They can be used for both developers
20-
as well as users who want to use the app. A postman collection has also been added which can be found in our API section.
30+
We discuss all of the features and configuration of our application in further sections of the documentation. They can be used for both developers
31+
as well as users who want to use the app. A postman collection has also been added which can be found in our API section.
32+
<br>
33+
<br>
34+
35+
## Backend rust (via Tauri)
36+
37+
The Rust backend, integrated through Tauri, is a core component of our application. It leverages Rust's performance and safety features to handle file system operations, provide a secure bridge between the frontend and the local system, and manage OS-level interactions. This backend efficiently manages tasks such as reading and writing image files, extracting metadata, and ensuring secure access to system resources. It communicates with the React frontend through an IPC mechanism, allowing for seamless integration of low-level functionalities with the user interface. This architecture enables high-performance, secure operations on the local system while maintaining a smooth user experience.
38+
39+

docs/overview/features.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@
3030

3131
| Component | Technology |
3232
| --------- | ---------- |
33-
| Backend | Python |
33+
| Frontend | React |
34+
| Desktop Framework | Tauri |
35+
| Rust Backend | Rust |
36+
| Python Backend | Python |
3437
| Database | SQLite |
3538
| Image Processing | OpenCV, ONNX Runtime |
3639
| Object Detection | YOLOv8 |
3740
| Face Recognition | FaceNet |
3841
| API Framework | FastAPI |
42+
| State Management | React Hooks |
43+
| Styling | Tailwind CSS |
44+
| Routing | React Router |
45+
| UI Components | Radix UI |
46+
| Build Tool | Vite |
47+
| Type Checking | TypeScript |

0 commit comments

Comments
 (0)