mohsin-devs commited on
Commit
61696fa
·
verified ·
1 Parent(s): 6e5d3a2

Upload README.md

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