File Management & Storage
Relevant source files
The following files were used as context for generating this wiki page:
The File Management & Storage system provides a robust infrastructure for handling, organizing, and securing various document types across the platform. It facilitates the upload, storage, and retrieval of Request for Quotation (RFQ) documentation, vendor certifications, project-specific blueprints, and administrative templates. This system integrates directly with Supabase Storage and PostgreSQL to maintain both physical file assets and their associated metadata.
The architecture supports multi-role access, ensuring that sensitive documents such as bidding specifications or vendor licenses are only accessible to authorized personnel. It also includes utility features like template import/export in JSON and CSV formats to streamline administrative workflows.
Document Storage Architecture
The system utilizes a bucket-based storage strategy in Supabase to segregate different types of business assets. Each functional area (Vendors, RFQs, Projects) has designated storage paths to maintain organized file hierarchies.
Storage Buckets and Paths
The following table outlines the primary storage locations and their intended use cases:
| Bucket Name | Sub-folder Pattern | Description |
|---|---|---|
rfq-documents | {rfq_id}/{timestamp}_{filename} | Technical specs, blueprints, and floor plans for RFQs. |
vendor-assets | documents/ | Business licenses and vendor certifications. |
documents | project-documents/{project_id}/ | General project-related documents and shared files. |
Sources: [src/pages/admin/RFQEdit.tsx:298-301], [src/components/DocumentManagement.tsx:86-89], [src/pages/VendorDocuments.tsx:114-115]
Logical Data Flow
The data flow for file operations involves a dual-action process where the physical file is uploaded to an object store, followed by a metadata insertion into a corresponding database table.
Sources: [src/pages/admin/RFQEdit.tsx:295-345], [src/components/DocumentManagement.tsx:78-120]
RFQ Document Management
Administrators manage complex technical documents during the RFQ creation and editing process. The system categorizes these files to provide context to bidding vendors.
RFQ Document Categories
Documents uploaded within the RFQ module are assigned specific badges for easy identification:
- Specification: Detailed technical requirements.
- Blueprint: Architectural or technical drawings.
- Floor Plan: Layouts of property levels.
- MEP Design: Mechanical, Electrical, and Plumbing engineering files.
- Property Photo: Visual references of the site.
Sources: [src/pages/admin/RFQEdit.tsx:313-320], [src/pages/admin/RFQEdit.tsx:691-700]
Template Import and Export
To facilitate rapid RFQ generation, the system supports importing and exporting configuration data.
- JSON Export: Captures the entire RFQ structure (except sensitive status/ID fields) into a portable file.
- CSV Import/Export: Allows bulk editing of project details, building dimensions, and technical specs.
Sources: [src/pages/admin/RFQEdit.tsx:442-463], [src/pages/admin/RFQEdit.tsx:489-517]
Vendor Documentation and Compliance
Vendors are required to maintain business documents and certifications. The system tracks the verification status of these files to ensure compliance with platform standards.
Metadata Schema
The vendor_documents table tracks the following fields for every asset:
| Field | Type | Description |
|---|---|---|
id | UUID | Unique identifier for the document record. |
vendor_id | UUID | Link to the vendor's profile. |
document_type | String | e.g., 'business_document', 'certificate'. |
is_verified | Boolean | Whether an admin has approved the document. |
file_size | Number | Size in bytes for storage tracking. |
file_path | String | Path within the vendor-assets bucket. |
Sources: [src/pages/VendorDocuments.tsx:34-45], [src/components/VendorDocumentsList.tsx:28-40]
Admin Verification Workflow
When a vendor uploads a document, it enters a "Pending" state. Admins can view the file via signed URLs and update the status.
Sources: [src/components/VendorDocumentsList.tsx:50-76], [src/components/VendorDocumentsList.tsx:160-176]
Security and Access Control
Access to files is strictly governed by user roles and subscription statuses.
Authorization Rules
- Admins: Full CRUD access to all documents in the system.
- Vendors: Can upload their own business documents. They can download project/RFQ documents ONLY if they have an active subscription.
- Public Users: Can view masked RFQ details but cannot access underlying technical documents without authentication.
Sources: [src/components/DocumentManagement.tsx:47-49], [src/components/DocumentManagement.tsx:122-125]
Secure Retrieval
The system avoids public URLs for sensitive documents. Instead, it generates short-lived signed URLs for viewing and downloading.
// Example of signed URL generation for secure access
const { data: signedData } = await supabase.storage
.from('rfq-documents')
.createSignedUrl(filePath, 86400); // 24-hour expiry
Sources: [src/pages/admin/RFQEdit.tsx:308-311], [src/components/VendorDocumentsList.tsx:178-185]
Summary
The File Management & Storage module serves as the central repository for all project and business assets. By leveraging Supabase Storage and a structured metadata approach, the system ensures that technical specifications and compliance documents are stored securely, categorized accurately, and accessible only to authorized participants. This infrastructure is critical for the RFQ bidding process and vendor onboarding lifecycle.