Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
319 changes: 319 additions & 0 deletions DatabaseCalculator.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
export const DatabaseCalculator = () => {
const [values, setValues] = useState({

Check warning on line 2 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L2

Did you really mean 'setValues'?
database_type: 'mysql',

Check warning on line 3 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L3

Did you really mean 'database_type'?
storage_size: 100,

Check warning on line 4 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L4

Did you really mean 'storage_size'?
storage_unit: 'GB',

Check warning on line 5 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L5

Did you really mean 'storage_unit'?
concurrent_connections: 100,

Check warning on line 6 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L6

Did you really mean 'concurrent_connections'?
queries_per_second: 1000,

Check warning on line 7 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L7

Did you really mean 'queries_per_second'?
backup_frequency: 'daily',

Check warning on line 8 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L8

Did you really mean 'backup_frequency'?
replication_factor: 1

Check warning on line 9 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L9

Did you really mean 'replication_factor'?
});

const [results, setResults] = useState({});

Check warning on line 12 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L12

Did you really mean 'setResults'?

const handleChange = (name, value) => {

Check warning on line 14 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L14

Did you really mean 'handleChange'?
setValues(prev => ({
...prev,
[name]: value
}));
};

const calculate = () => {
const storageBytes = values.storage_size * (values.storage_unit === 'GB' ? 1024 * 1024 * 1024 : 1024 * 1024);

Check warning on line 22 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L22

Did you really mean 'storageBytes'?

// Database-specific multipliers for resource requirements
const dbMultipliers = {
mysql: { cpu: 1.0, memory: 1.0, storage: 1.0 },
postgresql: { cpu: 1.2, memory: 1.3, storage: 1.1 },
mongodb: { cpu: 1.1, memory: 1.5, storage: 1.2 },
redis: { cpu: 0.8, memory: 2.0, storage: 0.5 },
cassandra: { cpu: 1.3, memory: 1.4, storage: 1.5 }
};

const multiplier = dbMultipliers[values.database_type] || dbMultipliers.mysql;

// Calculate resource requirements
const baseMemoryGB = Math.max(2, (values.concurrent_connections * 0.01) + (values.queries_per_second * 0.001));
const recommendedMemoryGB = baseMemoryGB * multiplier.memory * values.replication_factor;

const baseCPUCores = Math.max(2, (values.queries_per_second * 0.0001) + (values.concurrent_connections * 0.001));
const recommendedCPUCores = baseCPUCores * multiplier.cpu;

const totalStorageGB = (storageBytes / (1024 * 1024 * 1024)) * multiplier.storage * values.replication_factor;

// Backup storage calculation
const backupMultiplier = values.backup_frequency === 'hourly' ? 24 : values.backup_frequency === 'daily' ? 7 : 4;
const backupStorageGB = totalStorageGB * 0.3 * backupMultiplier; // Assume 30% compression

setResults({
recommended_memory: recommendedMemoryGB,
recommended_cpu: recommendedCPUCores,
total_storage: totalStorageGB,
backup_storage: backupStorageGB,
total_storage_with_backup: totalStorageGB + backupStorageGB
});
};

useEffect(() => {
calculate();
}, [values]);

const databaseTypes = [

Check warning on line 61 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L61

Did you really mean 'databaseTypes'?
{ value: 'mysql', label: 'MySQL' },
{ value: 'postgresql', label: 'PostgreSQL' },
{ value: 'mongodb', label: 'MongoDB' },
{ value: 'redis', label: 'Redis' },
{ value: 'cassandra', label: 'Cassandra' }

Check warning on line 66 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L66

Did you really mean 'cassandra'?
];

const storageUnits = [

Check warning on line 69 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L69

Did you really mean 'storageUnits'?
{ value: 'MB', label: 'MB' },
{ value: 'GB', label: 'GB' }
];

const backupFrequencies = [

Check warning on line 74 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L74

Did you really mean 'backupFrequencies'?
{ value: 'hourly', label: 'Hourly' },
{ value: 'daily', label: 'Daily' },
{ value: 'weekly', label: 'Weekly' }
];

const inputFields = [

Check warning on line 80 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L80

Did you really mean 'inputFields'?
{
name: 'database_type',

Check warning on line 82 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L82

Did you really mean 'database_type'?
label: 'Database Type',
type: 'select',
options: databaseTypes,

Check warning on line 85 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L85

Did you really mean 'databaseTypes'?
description: 'The type of database system you are planning to use.'
},
{
name: 'storage_size',

Check warning on line 89 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L89

Did you really mean 'storage_size'?
label: 'Storage Size',
type: 'number',
unit: values.storage_unit,

Check warning on line 92 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L92

Did you really mean 'storage_unit'?
description: 'The amount of storage space required for your database.'
},
{
name: 'storage_unit',
label: 'Storage Unit',
type: 'select',
options: storageUnits,

Check warning on line 99 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L99

Did you really mean 'storageUnits'?
description: 'The unit of measurement for storage size.'
},
{
name: 'concurrent_connections',

Check warning on line 103 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L103

Did you really mean 'concurrent_connections'?
label: 'Concurrent Connections',
type: 'number',
unit: 'Connections',
description: 'The maximum number of simultaneous database connections.'
},
{
name: 'queries_per_second',

Check warning on line 110 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L110

Did you really mean 'queries_per_second'?
label: 'Queries Per Second',
type: 'number',
unit: 'QPS',
description: 'The expected number of database queries per second.'
},
{
name: 'backup_frequency',

Check warning on line 117 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L117

Did you really mean 'backup_frequency'?
label: 'Backup Frequency',
type: 'select',
options: backupFrequencies,

Check warning on line 120 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L120

Did you really mean 'backupFrequencies'?
description: 'How often you plan to create database backups.'
},
{
name: 'replication_factor',

Check warning on line 124 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L124

Did you really mean 'replication_factor'?
label: 'Replication Factor',
type: 'number',
unit: 'Replicas',
description: 'The number of database replicas for high availability.'
}
];

const resultFields = [

Check warning on line 132 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L132

Did you really mean 'resultFields'?
{ name: 'recommended_memory', label: 'Recommended Memory', unit: 'GB', description: 'The recommended amount of RAM for optimal performance.' },

Check warning on line 133 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L133

Did you really mean 'recommended_memory'?
{ name: 'recommended_cpu', label: 'Recommended CPU Cores', unit: 'Cores', description: 'The recommended number of CPU cores.' },

Check warning on line 134 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L134

Did you really mean 'recommended_cpu'?
{ name: 'total_storage', label: 'Total Storage Required', unit: 'GB', description: 'The total storage space required including replication.' },

Check warning on line 135 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L135

Did you really mean 'total_storage'?
{ name: 'backup_storage', label: 'Backup Storage', unit: 'GB', description: 'Additional storage required for backups.' },

Check warning on line 136 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L136

Did you really mean 'backup_storage'?
{ name: 'total_storage_with_backup', label: 'Total with Backups', unit: 'GB', description: 'Total storage including backup space.' }

Check warning on line 137 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L137

Did you really mean 'total_storage_with_backup'?
];

return (
<div style={{
maxWidth: '800px',

Check warning on line 142 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L142

Did you really mean 'maxWidth'?
margin: '0 auto',
padding: '20px',
fontFamily: 'system-ui, -apple-system, sans-serif'

Check warning on line 145 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L145

Did you really mean 'fontFamily'?
}}>
<div style={{
backgroundColor: '#f8f9fa',

Check warning on line 148 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L148

Did you really mean 'backgroundColor'?
border: '1px solid #e9ecef',
borderRadius: '8px',
padding: '24px',
marginBottom: '24px'

Check warning on line 152 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L152

Did you really mean 'marginBottom'?
}}>
<h3 style={{
margin: '0 0 20px 0',
color: '#495057',
fontSize: '1.25rem',

Check warning on line 157 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L157

Did you really mean 'fontSize'?
fontWeight: '600'

Check warning on line 158 in DatabaseCalculator.mdx

View check run for this annotation

Mintlify / Mintlify Validation - vale-spellcheck

DatabaseCalculator.mdx#L158

Did you really mean 'fontWeight'?
}}>
Database Sizing Calculator
</h3>

<div style={{ marginBottom: '24px' }}>
<h4 style={{
margin: '0 0 16px 0',
color: '#6c757d',
fontSize: '1rem',
fontWeight: '500'
}}>
Input Parameters
</h4>

<div style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))',
gap: '16px'
}}>
{inputFields.map(field => (
<div key={field.name} style={{ marginBottom: '12px' }}>
<div style={{
display: 'flex',
alignItems: 'center',
marginBottom: '4px'
}}>
<label
htmlFor={field.name}
title={field.description}
style={{
marginRight: 'auto',
fontSize: '0.875rem',
fontWeight: '500',
color: '#495057'
}}
>
{field.label}
</label>

{field.type === 'select' ? (
<select
id={field.name}
name={field.name}
value={values[field.name]}
onChange={(e) => handleChange(field.name, e.target.value)}
title={field.description}
style={{
margin: '0 10px',
padding: '6px 8px',
border: '1px solid #ced4da',
borderRadius: '4px',
fontSize: '0.875rem',
width: '120px'
}}
>
{field.options.map(option => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
) : (
<input
id={field.name}
name={field.name}
type="number"
value={values[field.name]}
onChange={(e) => handleChange(field.name, parseFloat(e.target.value) || 0)}
title={field.description}
required
style={{
margin: '0 10px',
padding: '6px 8px',
border: '1px solid #ced4da',
borderRadius: '4px',
fontSize: '0.875rem',
width: '80px'
}}
/>
)}

<label style={{
width: '80px',
fontSize: '0.875rem',
color: '#6c757d'
}}>
{field.unit || ''}
</label>
</div>
</div>
))}
</div>
</div>

<hr style={{ margin: '24px 0', border: 'none', borderTop: '1px solid #dee2e6' }} />

<div>
<h4 style={{
margin: '0 0 16px 0',
color: '#6c757d',
fontSize: '1rem',
fontWeight: '500'
}}>
Calculated Results
</h4>

<div style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))',
gap: '16px'
}}>
{resultFields.map(field => (
<div key={field.name} style={{ marginBottom: '12px' }}>
<div style={{
display: 'flex',
alignItems: 'center',
marginBottom: '4px'
}}>
<label
title={field.description}
style={{
marginRight: 'auto',
fontSize: '0.875rem',
fontWeight: '500',
color: '#495057'
}}
>
{field.label}
</label>
<input
type="text"
value={(results[field.name] || 0).toFixed(2)}
disabled
title={field.description}
style={{
margin: '0 10px',
padding: '6px 8px',
border: '1px solid #ced4da',
borderRadius: '4px',
fontSize: '0.875rem',
width: '80px',
backgroundColor: '#f8f9fa',
color: '#495057'
}}
/>
<label style={{
width: '80px',
fontSize: '0.875rem',
color: '#6c757d'
}}>
{field.unit}
</label>
</div>
</div>
))}
</div>
</div>
</div>
</div>
);
};
Loading