File size: 6,034 Bytes
96a6d41 |
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# MongoDB Data Storage Structure
This document describes exactly what data is stored in MongoDB when you use the Image Colorization API.
## Database: `colorization_db`
### Collection 1: `api_calls`
Stores every API endpoint call with timestamp.
**Data Structure:**
```json
{
"_id": ObjectId("..."), // MongoDB auto-generated ID
"endpoint": "/health", // API endpoint path
"method": "GET", // HTTP method (GET, POST)
"status_code": 200, // HTTP status code
"timestamp": ISODate("2025-11-27T04:22:27.823Z"), // UTC timestamp when API was called
"request_data": { // Request parameters/data
"filename": "Descratch.png",
"content_type": "image/png"
},
"response_data": { // Response data returned
"status": "healthy",
"model_loaded": true
},
"error": null, // Error message if any
"user_id": null, // User ID if authenticated
"ip_address": "127.0.0.1" // Client IP address
}
```
**Example for `/upload` endpoint:**
```json
{
"endpoint": "/upload",
"method": "POST",
"status_code": 200,
"timestamp": ISODate("2025-11-27T10:00:00.000Z"),
"request_data": {
"filename": "Descratch.png",
"content_type": "image/png"
},
"response_data": {
"success": true,
"image_id": "abc123-def456-ghi789",
"image_url": "https://.../uploads/abc123.jpg",
"filename": "abc123.jpg"
},
"error": null,
"user_id": null,
"ip_address": "192.168.1.100"
}
```
**Example for `/colorize` endpoint:**
```json
{
"endpoint": "/colorize",
"method": "POST",
"status_code": 200,
"timestamp": ISODate("2025-11-27T10:00:05.000Z"),
"request_data": {
"filename": "Descratch.png",
"content_type": "image/png",
"positive_prompt": "colorize this image",
"negative_prompt": "low quality",
"seed": 123,
"num_inference_steps": 8
},
"response_data": {
"success": true,
"result_id": "xyz789-abc123-def456",
"download_url": "https://.../results/xyz789.png",
"api_download_url": "https://.../download/xyz789",
"filename": "xyz789.png",
"caption": "colorized image"
},
"error": null,
"user_id": null,
"ip_address": "192.168.1.100"
}
```
---
### Collection 2: `image_uploads`
Stores information about every image upload.
**Data Structure:**
```json
{
"_id": ObjectId("..."), // MongoDB auto-generated ID
"image_id": "abc123-def456-ghi789", // Unique image identifier (UUID)
"filename": "Descratch.png", // Original filename
"file_size": 245678, // File size in bytes
"content_type": "image/png", // MIME type
"uploaded_at": ISODate("2025-11-27T10:00:00.000Z"), // UTC timestamp
"user_id": null, // User ID if authenticated
"ip_address": "192.168.1.100" // Client IP address
}
```
**Example with Descratch.png:**
```json
{
"image_id": "abc123-def456-ghi789",
"filename": "Descratch.png",
"file_size": 245678,
"content_type": "image/png",
"uploaded_at": ISODate("2025-11-27T10:00:00.000Z"),
"user_id": null,
"ip_address": "192.168.1.100"
}
```
---
### Collection 3: `colorizations`
Stores information about every colorization request.
**Data Structure:**
```json
{
"_id": ObjectId("..."), // MongoDB auto-generated ID
"result_id": "xyz789-abc123-def456", // Unique result identifier (UUID)
"image_id": "abc123-def456-ghi789", // Original image identifier
"prompt": "colorize this image", // Text prompt used (if any)
"model_type": "sdxl", // Model type: "fastai", "pytorch", "sdxl", "gan"
"processing_time": 3.45, // Time taken to process in seconds
"created_at": ISODate("2025-11-27T10:00:05.000Z"), // UTC timestamp
"user_id": null, // User ID if authenticated
"ip_address": "192.168.1.100" // Client IP address
}
```
**Example with Descratch.png:**
```json
{
"result_id": "xyz789-abc123-def456",
"image_id": "abc123-def456-ghi789",
"prompt": "colorize this image with vibrant natural colors",
"model_type": "sdxl",
"processing_time": 3.45,
"created_at": ISODate("2025-11-27T10:00:05.000Z"),
"user_id": null,
"ip_address": "192.168.1.100"
}
```
---
## What Gets Stored When You Use Descratch.png
When you upload and colorize `Descratch.png`, the following data will be stored:
1. **API Call Logs** (`api_calls` collection):
- `/health` - Health check call
- `/upload` - Image upload call with request/response data
- `/colorize` - Colorization call with processing parameters
- `/download` - Download result call (if you download the result)
- `/results` - Public result access call (if accessed)
2. **Image Upload Record** (`image_uploads` collection):
- Image ID (UUID)
- Filename: "Descratch.png"
- File size in bytes
- Content type: "image/png"
- Upload timestamp
- IP address
3. **Colorization Record** (`colorizations` collection):
- Result ID (UUID)
- Image ID reference
- Model type used
- Processing time
- Creation timestamp
- IP address
## All Data Includes Timestamps
Every record includes a UTC timestamp:
- `api_calls.timestamp` - When the API endpoint was called
- `image_uploads.uploaded_at` - When the image was uploaded
- `colorizations.created_at` - When the colorization was created
## Querying the Data
You can query MongoDB to:
- Find all API calls in the last 24 hours
- Track which images were uploaded
- Monitor colorization processing times
- Analyze API usage patterns
- Track errors and status codes
|