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