Spaces:
Sleeping
Sleeping
Commit Β·
5101a73
1
Parent(s): 3342f91
Fix README - restore complete content with proper YAML frontmatter
Browse files
README.md
CHANGED
|
@@ -6,4 +6,167 @@ colorTo: purple
|
|
| 6 |
sdk: static
|
| 7 |
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
sdk: static
|
| 7 |
app_file: index.html
|
| 8 |
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# DocVault - Offline-First Document Storage System
|
| 12 |
+
|
| 13 |
+
Complete offline-first document storage system built with **Python Flask** and local filesystem storage. No cloud dependencies, fully self-contained, and ready for future Hugging Face integration.
|
| 14 |
+
|
| 15 |
+
## π― Features
|
| 16 |
+
|
| 17 |
+
### Core Features
|
| 18 |
+
- β
**Create Files and Folders** - Including nested directory structures
|
| 19 |
+
- β
**Delete Items** - Individual files/folders or bulk deletion
|
| 20 |
+
- β
**Upload Files** - Support for 50+ file types
|
| 21 |
+
- β
**List Contents** - Browse file/folder hierarchy with metadata
|
| 22 |
+
- β
**Rename Items** - Rename files and folders
|
| 23 |
+
- β
**Security** - Path traversal prevention, input validation
|
| 24 |
+
- β
**Logging** - Comprehensive logging with rotation
|
| 25 |
+
- β
**File Metadata** - Size, creation time, modification time
|
| 26 |
+
- β
**Multi-User** - Support for multiple users via user IDs
|
| 27 |
+
|
| 28 |
+
### Storage
|
| 29 |
+
- Local filesystem storage in `data/{user_id}/` structure
|
| 30 |
+
- Automatic marker files (`.gitkeep`) for HF integration compatibility
|
| 31 |
+
- Prevents duplicate filenames with auto-numbering
|
| 32 |
+
- Maintains clean directory structure
|
| 33 |
+
|
| 34 |
+
## π Project Structure
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
.
|
| 38 |
+
βββ server/
|
| 39 |
+
β βββ app.py # Flask application
|
| 40 |
+
β βββ config.py # Configuration settings
|
| 41 |
+
β βββ requirements.txt # Python dependencies
|
| 42 |
+
β βββ routes/
|
| 43 |
+
β β βββ api.py # API endpoints
|
| 44 |
+
β βββ storage/
|
| 45 |
+
β β βββ manager.py # Storage operations
|
| 46 |
+
β βββ utils/
|
| 47 |
+
β βββ logger.py # Logging setup
|
| 48 |
+
β βββ validators.py # Path validation & security
|
| 49 |
+
βββ data/ # Storage directory (auto-created)
|
| 50 |
+
βββ logs/ # Log files (auto-created)
|
| 51 |
+
βββ tests/
|
| 52 |
+
β βββ test_docvault.py # Unit tests
|
| 53 |
+
β βββ test_api.sh # API test script
|
| 54 |
+
βββ index.html # Frontend UI
|
| 55 |
+
βββ app.js # Frontend app logic
|
| 56 |
+
βββ styles.css # Frontend styles
|
| 57 |
+
βββ README.md # This file
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## π Getting Started
|
| 61 |
+
|
| 62 |
+
### Prerequisites
|
| 63 |
+
- Python 3.8+
|
| 64 |
+
- pip or conda
|
| 65 |
+
|
| 66 |
+
### Installation
|
| 67 |
+
|
| 68 |
+
1. **Clone the repository**
|
| 69 |
+
```bash
|
| 70 |
+
git clone <your-repo-url>
|
| 71 |
+
cd DocVault
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
2. **Install dependencies**
|
| 75 |
+
```bash
|
| 76 |
+
pip install -r server/requirements.txt
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
3. **Run the application**
|
| 80 |
+
```bash
|
| 81 |
+
python server/app.py
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
4. **Access the app**
|
| 85 |
+
- Open browser to `http://localhost:5000`
|
| 86 |
+
|
| 87 |
+
## π API Endpoints
|
| 88 |
+
|
| 89 |
+
### File Operations
|
| 90 |
+
- `POST /api/create` - Create file or folder
|
| 91 |
+
- `DELETE /api/delete` - Delete file or folder
|
| 92 |
+
- `PUT /api/rename` - Rename item
|
| 93 |
+
- `POST /api/upload` - Upload file
|
| 94 |
+
- `GET /api/list/<path>` - List directory contents
|
| 95 |
+
|
| 96 |
+
### Request Examples
|
| 97 |
+
|
| 98 |
+
**Create File:**
|
| 99 |
+
```bash
|
| 100 |
+
curl -X POST http://localhost:5000/api/create \
|
| 101 |
+
-H "Content-Type: application/json" \
|
| 102 |
+
-d '{"user_id":"default_user","item_type":"file","name":"test.txt","path":"/"}'
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
**Upload File:**
|
| 106 |
+
```bash
|
| 107 |
+
curl -X POST http://localhost:5000/api/upload \
|
| 108 |
+
-F "user_id=default_user" \
|
| 109 |
+
-F "file=@localfile.txt" \
|
| 110 |
+
-F "path=/"
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
**List Contents:**
|
| 114 |
+
```bash
|
| 115 |
+
curl http://localhost:5000/api/list/default_user/
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
## π§ͺ Testing
|
| 119 |
+
|
| 120 |
+
Run the test suite:
|
| 121 |
+
```bash
|
| 122 |
+
python -m pytest tests/test_docvault.py -v
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Or use the included API test script:
|
| 126 |
+
```bash
|
| 127 |
+
bash tests/test_api.sh
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## π Security Features
|
| 131 |
+
|
| 132 |
+
- **Path Traversal Prevention** - Validates all paths to prevent directory escape attacks
|
| 133 |
+
- **Input Validation** - Sanitizes filenames and paths
|
| 134 |
+
- **User Isolation** - Each user has their own data directory
|
| 135 |
+
- **Error Handling** - Comprehensive error messages without exposing system details
|
| 136 |
+
|
| 137 |
+
## π Logging
|
| 138 |
+
|
| 139 |
+
- Logs stored in `logs/` directory
|
| 140 |
+
- Automatic log rotation (10 MB per file, 10 files kept)
|
| 141 |
+
- Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
| 142 |
+
|
| 143 |
+
## π’ Deployment
|
| 144 |
+
|
| 145 |
+
### Docker
|
| 146 |
+
```bash
|
| 147 |
+
docker build -t docvault .
|
| 148 |
+
docker run -p 5000:5000 docvault
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
### Hugging Face Spaces
|
| 152 |
+
This app is ready for deployment on Hugging Face Spaces as a static frontend application.
|
| 153 |
+
|
| 154 |
+
## π¦ Dependencies
|
| 155 |
+
|
| 156 |
+
- Flask 2.3.2
|
| 157 |
+
- Werkzeug 2.3.6
|
| 158 |
+
- Python 3.8+
|
| 159 |
+
|
| 160 |
+
See `server/requirements.txt` for full list.
|
| 161 |
+
|
| 162 |
+
## π License
|
| 163 |
+
|
| 164 |
+
MIT License
|
| 165 |
+
|
| 166 |
+
## π€ Contributing
|
| 167 |
+
|
| 168 |
+
Contributions welcome! Please feel free to submit a Pull Request.
|
| 169 |
+
|
| 170 |
+
## π§ Support
|
| 171 |
+
|
| 172 |
+
For issues or questions, please open an Issue on GitHub.
|