Skip to content

Commit 68aaabc

Browse files
committed
feat(deploy): Add Windows scripts and overhaul documentation
This commit standardizes the project's deployment strategy across platforms. - Adds .bat scripts for Windows (start_production, start_development, stop_production) to mirror the existing .sh scripts. - Completely rewrites the README.md with detailed, step-by-step setup instructions for both macOS/Linux and Windows. - Removes the PyInstaller GitHub Actions workflow to focus on a single, robust 'run from source' deployment method.
1 parent d1421f5 commit 68aaabc

File tree

5 files changed

+198
-112
lines changed

5 files changed

+198
-112
lines changed

.github/workflows/release_builder.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

README.md

Lines changed: 143 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Sherlock v2.0: Inventory & Lending Management System
22

3-
![Python Version](https://img.shields.io/badge/python-3.11-blue.svg)
4-
![Django Version](https://img.shields.io/badge/django-5.1-green.svg)
3+
![Python Version](https://img.shields.io/badge/python-3.11+-blue.svg)
4+
![Django Version](https://img.shields.io/badge/django-5.x-green.svg)
55
![License](https://img.shields.io/badge/License-Apache_2.0-yellow.svg)
6-
![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)
76

8-
**Sherlock is a comprehensive, self-hosted inventory and lending management system designed for school labs, makerspaces, and workshops.**
7+
**Sherlock is a comprehensive, self-hosted inventory and lending management system designed for school labs, makerspaces, and workshops.** It provides a powerful, data-driven platform to track assets, manage student loans, and gain insight into your lab's operations, all accessible from any device on your network.
98

10-
This project is a complete, ground-up rewrite and significant feature expansion of the original [Sherlock v1.0](https://github.com/Atal-Lab-DPSBS/Sherlock). It transforms the application from a simple inventory list into a powerful, data-driven lab management platform built on a modern and robust Python/Django backend.
9+
This project is a complete, ground-up rewrite of the original [Sherlock v1.0](https://github.com/Atal-Lab-DPSBS/Sherlock), built on a modern and secure Python/Django backend.
1110

1211
---
1312

@@ -17,79 +16,178 @@ This project is a complete, ground-up rewrite and significant feature expansion
1716
| :---: | :---: |
1817
| ![Dashboard Screenshot](.github/assets/dashboard.png) | ![Checkout Terminal Screenshot](.github/assets/checkout-terminal.png) |
1918
| **Item Detail & Audit Trails** | **On Loan Reporting** |
20-
| ![Item Detail Screenshot](.github/assets/item-detail.png) | ![On Loan Report Screenshot](.github/assets/on-loan-report.png) |
19+
| ![Item Detail Screenshot](.github/assets/item-detail.png) | ![On Loan Reporting](.github/assets/on-loan-report.png) |
2120

2221
---
2322

2423
## Table of Contents
2524
- [Mission](#-mission)
2625
- [Core Features](#-core-features)
27-
- [Deployment](#-deployment)
28-
- [For Developers: Running from Source](#-for-developers-running-from-source)
26+
- [Getting Started: A Step-by-Step Guide](#-getting-started-a-step-by-step-guide)
27+
- [Step 1: Get the Code](#step-1-get-the-code)
28+
- [Step 2: Install Python Dependencies](#step-2-install-python-dependencies)
29+
- [Step 3: Install Caddy Webserver](#step-3-install-caddy-webserver)
30+
- [Step 4: Run the Application](#step-4-run-the-application)
2931
- [Technology Stack](#️-technology-stack)
32+
- [Contributing & Development](#-contributing--development)
3033
- [License](#️-license)
3134

3235
## 🌟 Mission
3336

34-
The goal of Sherlock v2.0 is to provide a powerful, easy-to-deploy, and intuitive tool for lab managers to track their physical inventory. It answers the critical questions of lab management:
37+
The goal of Sherlock v2.0 is to answer the critical questions of lab management:
3538
* **What** do we have and **where** is it?
36-
* **Who** has borrowed our equipment?
37-
* **When** is it due back?
38-
* **What** is our inventory's lifecycle?
39+
* **Who** has borrowed our equipment and **when** is it due back?
40+
* **How** are our resources being used over time?
41+
* **How** can we manage team access and security effectively?
3942

4043
## ✨ Core Features
4144

4245
### Inventory Management
4346
* **Hierarchical Structure:** Organize your inventory logically with **Sections**, **Spaces**, and **Items**.
44-
* **Stock Control:** A full, permanent audit trail for every stock change (e.g., "Received New Stock," "Reported Damaged").
45-
* **Label Printing:** Generate and print custom barcode and QR code labels to seamlessly bridge your physical and digital inventory.
46-
* **Unified Search:** A powerful, live-search dashboard to find any item or student record in the system.
47+
* **Complete Audit Trail:** A permanent log of every stock change (e.g., "Received New Stock," "Reported Damaged").
48+
* **Label Printing:** Generate and print custom barcode and QR code labels.
49+
* **Universal Scan:** Use any connected camera to instantly look up items, spaces, or sections from their labels.
4750

4851
### Advanced Lending System
49-
* **Student Records:** Maintain a secure database of students with filtering and search capabilities.
50-
* **Kiosk-Style Checkout Terminal:** A dedicated, fast interface for lending items, featuring a live, as-you-type search for both students and items.
51-
* **Stock Validation:** The system automatically checks available stock before allowing a checkout.
52-
* **Partial Returns & Loan History:** A sophisticated check-in system that allows for partial returns and keeps a complete, auditable log of every transaction for both students and items.
53-
* **Due Date & Overdue Tracking:** Assign a due date to every loan and get instant visibility on overdue items through the main dashboard and a dedicated report.
52+
* **Student Records:** Maintain a secure database of students.
53+
* **Kiosk-Style Checkout Terminal:** A dedicated, fast interface for lending items.
54+
* **Partial Returns & Condition Tracking:** A sophisticated check-in system that allows for partial returns and tracks the condition ("OK" or "Damaged") of returned items.
55+
* **Due Date & Overdue Tracking:** Assign due dates to every loan and get instant visibility on overdue items.
56+
57+
### Administration & Security
58+
* **Role-Based Access Control:** A two-tier user system (**Admin** and **Member**).
59+
* **Live Security Dashboard:** A "Team Management" page for Admins to view real-time user activity (**Online/Offline** status), suspend/reactivate accounts, and forcibly terminate user sessions.
60+
* **Secure by Default:** All network traffic is encrypted via HTTPS, enabling secure camera access from any device.
61+
62+
## 🚀 Getting Started: A Step-by-Step Guide
63+
64+
This guide will walk you through the one-time setup required to run Sherlock.
65+
66+
### Step 1: Get the Code
67+
68+
Clone this repository to your local machine:
69+
```bash
70+
git clone https://github.com/cp099/Sherlock-Python.git
71+
cd Sherlock-Python
72+
```
73+
74+
### Step 2: Install Python Dependencies
75+
76+
This project uses a virtual environment to manage its packages.
77+
78+
1. **Create and activate the virtual environment:**
79+
* **On macOS/Linux:**
80+
```bash
81+
python3 -m venv venv
82+
source venv/bin/activate
83+
```
84+
* **On Windows:**
85+
```cmd
86+
python -m venv venv
87+
.\venv\Scripts\activate
88+
```
89+
2. **Install the required packages:**
90+
```bash
91+
pip install -r requirements.txt
92+
```
93+
94+
### Step 3: Install Caddy Webserver
95+
96+
Caddy is a modern, secure web server that automatically handles HTTPS for us. This is **required** for the camera scanning feature to work on all devices on your network.
97+
98+
<details>
99+
<summary><strong>🔵 For macOS / Linux</strong></summary>
100+
101+
The easiest way is to use a package manager.
102+
* **With Homebrew (macOS):** `brew install caddy`
103+
* **With `apt` (Debian/Ubuntu):** Follow the official instructions [here](https://caddyserver.com/docs/install#debian-ubuntu-raspbian).
104+
105+
After installation, verify it by opening a new terminal and running `caddy version`.
106+
</details>
107+
108+
<details>
109+
<summary><strong>
110+
🪟 For Windows (Detailed Steps)
111+
</strong></summary>
112+
113+
Setting up a command-line tool on Windows requires a few extra steps. Please follow these carefully.
114+
115+
1. **Download Caddy:**
116+
* Go to the official download page: [**caddyserver.com/download**](https://caddyserver.com/download).
117+
* Select the latest version for the **Windows amd64** platform.
118+
* This will download a file named something like `caddy_2.x.x_windows_amd64.exe`.
119+
120+
2. **Unblock the File:**
121+
* Windows automatically "blocks" executables downloaded from the internet. We must unblock it.
122+
* Find the downloaded file in your Downloads folder, **right-click** it, and select **Properties**.
123+
* At the bottom of the General tab, you should see a security warning. **Check the "Unblock" checkbox** and click **OK**.
54124

55-
### Modern Technology
56-
* **Camera Scanning:** Use your device's camera for rapid checkouts and to instantly look up any item, space, or section with the Universal Scan tool.
57-
* **Data Visualizations:** The main dashboard features charts for weekly loan activity and most popular items, providing instant insight into your lab's operations.
125+
3. **Place and Rename the File:**
126+
* Rename the file to `caddy.exe`.
127+
* Create a new folder on your C: drive called `C:\Caddy`.
128+
* Move `caddy.exe` into this `C:\Caddy` folder.
58129

59-
## 🚀 Deployment
130+
4. **Add Caddy to the System PATH:**
131+
* This is the most critical step. It allows you to run `caddy` from any terminal.
132+
* Press the Windows key and search for **"Edit the system environment variables"**. Open it.
133+
* In the window that appears, click the **"Environment Variables..."** button.
134+
* In the bottom box, under "System variables," find and select the variable named **`Path`**.
135+
* Click **"Edit..."**.
136+
* Click **"New"** and type in the path to your new folder: `C:\Caddy`.
137+
* Click **OK** on all three windows to save your changes.
60138

61-
Sherlock is designed for incredibly simple deployment. It is packaged as a **standalone executable** using PyInstaller, containing the entire application, web server, and all dependencies.
139+
5. **Verify the Installation:**
140+
* **Close and reopen** your terminal (Command Prompt or PowerShell).
141+
* Run the command `caddy version`. If it prints a version number, you have successfully installed Caddy!
62142

63-
### How to Run Sherlock:
64-
1. Go to the [**Releases**](https://github.com/YOUR-USERNAME/Sherlock-python/releases) page of this repository.
65-
2. Download the latest `.zip` file for your operating system (e.g., `Sherlock-v2.0.0-Windows.zip`).
66-
3. Unzip the file and double-click the `Sherlock` executable.
143+
</details>
67144

68-
The server will start, automatically creating a new database on the first run. The application will be available at `http://127.0.0.1:8000` and on your local network.
145+
### Step 4: Run the Application
69146

70-
## 💻 For Developers: Running from Source
147+
We provide simple scripts to handle both development and production modes.
71148

72-
1. **Clone the repository:**
149+
#### Production Mode (Recommended)
150+
151+
This mode runs the secure HTTPS server, which is **required for camera scanning** to work across your network.
152+
153+
1. **On macOS/Linux:**
73154
```bash
74-
git clone https://github.com/YOUR-USERNAME/Sherlock-python.git
75-
cd Sherlock-python
155+
./start_production.sh
156+
```
157+
2. **On Windows:**
158+
```batch
159+
start_production.bat
76160
```
77-
2. **Create and activate a virtual environment:**
161+
162+
The script will start the Caddy and Waitress servers. You can then access Sherlock from any device at the `https://<your_ip_address>:8443` URL printed in the terminal.
163+
164+
> **⚠️ Browser Security Warning (First Time Only):**
165+
> The first time you access the `https://` URL, your browser will show a security warning ("This Connection Is Not Private," etc.). This is normal and expected because the security certificate is self-signed by Caddy. **It is safe to proceed.** Click "Advanced," "Show Details," or "Visit this website" to continue. Your connection is fully encrypted.
166+
>
167+
> **Firewall Popup (First Time Only):**
168+
> Your operating system's firewall (Windows Defender or macOS Firewall) will likely show a popup asking for permission for "Caddy" to accept network connections. You **must click "Allow"** for other devices to be able to connect to the server.
169+
170+
#### Development Mode
171+
172+
This mode runs a simpler HTTP server. Camera access will **only** work when accessing the site from `http://localhost:8000` on the same machine.
173+
174+
1. **On macOS/Linux:**
78175
```bash
79-
python -m venv venv
80-
source venv/bin/activate # On macOS/Linux
81-
.\venv\Scripts\activate # On Windows
176+
./start_development.sh
177+
```
178+
2. **On Windows:**
179+
```batch
180+
start_development.bat
82181
```
83-
3. **Install dependencies:** `pip install -r requirements.txt`
84-
4. **Run migrations:** `python manage.py migrate`
85-
5. **Create a superuser:** `python manage.py createsuperuser`
86-
6. **Run the development server:** `python manage.py runserver`
87182
88183
## 🛠️ Technology Stack
89184
* **Backend:** Python 3, Django
90-
* **Frontend:** HTML, CSS, HTMX, Chart.js
91-
* **Server:** Waitress
92-
* **Packaging:** PyInstaller
185+
* **Frontend:** HTML, CSS, HTMX, Chart.js, `html5-qrcode`
186+
* **Application Server:** Waitress
187+
* **Reverse Proxy (HTTPS):** Caddy
188+
189+
## 🤝 Contributing & Development
190+
For a more detailed development setup, including how to create a superuser for the first time, see the [CONTRIBUTING.md](CONTRIBUTING.md) file.
93191
94192
## ⚖️ License
95193

start_development.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
echo --- Starting Sherlock in DEVELOPMENT mode (HTTP) ---
3+
echo --- Access at: http://127.0.0.1:8000
4+
echo --- Press Ctrl+C to stop the server.
5+
6+
REM
7+
call venv\Scripts\activate.bat
8+
python manage.py runserver

start_production.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@echo off
2+
echo --- Starting Sherlock in PRODUCTION mode (HTTPS) ---
3+
4+
echo --- Detecting network IP... ---
5+
for /f "tokens=1,2 delims=: " %%a in ('ipconfig^|find "IPv4 Address"') do set IP_ADDRESS=%%b
6+
set IP_ADDRESS=%IP_ADDRESS:~1%
7+
set SHERLOCK_ALLOWED_IP=%IP_ADDRESS%
8+
echo --- Detected IP: %IP_ADDRESS% ---
9+
10+
echo --- Generating Caddyfile... ---
11+
(
12+
echo # Caddyfile for Sherlock (auto-generated)
13+
echo
14+
echo :8443 {
15+
echo tls internal
16+
echo reverse_proxy 127.0.0.1:8000
17+
echo }
18+
) > Caddyfile
19+
20+
21+
echo --- Running database migrations... ---
22+
call venv\Scripts\activate.bat
23+
python manage.py migrate --noinput
24+
echo --- Collecting static files... ---
25+
python manage.py collectstatic --noinput
26+
27+
28+
echo --- Starting Caddy in the background... ---
29+
start /b caddy run
30+
31+
echo.
32+
echo =====================================================================
33+
echo Sherlock is now running securely!
34+
echo Access it from any device at: https://%IP_ADDRESS%:8443
35+
echo Or on this machine at: https://localhost:8443
36+
echo =====================================================================
37+
echo.
38+
echo Waitress is running in the foreground. Press Ctrl+C to stop the server.
39+
echo When you are done, run the 'stop_production.bat' script to shut down Caddy.
40+
41+
42+
python run.py

stop_production.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
echo --- Stopping the background Caddy server... ---
3+
caddy stop
4+
echo --- Caddy server has been shut down. ---
5+
pause

0 commit comments

Comments
 (0)