--- 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 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/` - 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.