configuration - Mardens-Inc/Pricing-App GitHub Wiki
Complete guide to all configuration files in the Pricing App.
Table of Contents
- Database Configuration
- Backend Configuration
- Frontend Configuration
- Build Configuration
- Development Scripts
Database Configuration
dev-server.json
Location: Project root (gitignored)
Purpose: MySQL database credentials
{
"host": "localhost",
"user": "your_db_user",
"password": "your_db_password",
"hash": "some_hash_value"
}
Fields:
host: Database server hostnameuser: MySQL usernamepassword: MySQL passwordhash: Authentication hash (application-specific)
Setup:
# Create file
cat > dev-server.json <<EOF
{
"host": "localhost",
"user": "root",
"password": "yourpassword",
"hash": "yourhash"
}
EOF
# Ensure it's gitignored
echo "dev-server.json" >> .gitignore
Backend Configuration
Cargo.toml
Location: Project root
Key Sections:
[package]
name = "pricing_app"
version = "1.5.4"
edition = "2024"
[bin](/Mardens-Inc/Pricing-App/wiki/bin)
name = "pricing_app"
path = "src-actix/main.rs"
[lib]
name = "pricing_app_lib"
path = "src-actix/lib.rs"
[dependencies]
# See backend/dependencies.md for full list
[example](/Mardens-Inc/Pricing-App/wiki/example)
name = "migrate_tool"
path = "tools/migrate_tool.rs"
# ... more migration tools
Updating Version:
version = "1.5.5" # Increment for new release
constants.rs
Location: src-actix/constants.rs
Purpose: Global configuration constants
pub const DEBUG: bool = cfg!(debug_assertions);
pub const PORT: u16 = 1421;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const UPLOAD_FOLDER: &str = "uploads";
pub const ICONS_FOLDER: &str = "icons";
Modifying:
PORT: Change server portUPLOAD_FOLDER: Change upload directoryICONS_FOLDER: Change icon directory
rustfmt.toml
Location: Project root
Purpose: Rust code formatting rules
max_width = 150
use_small_heuristics = "Max"
Frontend Configuration
package.json
Location: Project root
Key Sections:
{
"name": "pricing-app",
"version": "1.5.4",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
"build": "npm run build-frontend && npm run build-api",
"build-win": "npm run build-frontend && npm run build-api-win",
"build-frontend": "tsc && vite build",
"build-api": "wsl cargo build --release",
"build-api-win": "cargo build --release",
"run-api": "cargo run --bin pricing_app",
"watch-api": "cargo watch -x 'run --bin pricing_app'"
}
}
Version Sync: Keep version in sync with Cargo.toml
vite.config.ts
Location: Project root
Purpose: Vite build tool configuration
export default defineConfig({
plugins: [react()],
server: {
host: "localhost",
port: 3218,
hmr: {
protocol: "ws",
host: "localhost",
port: 3218
}
},
build: {
outDir: "target/wwwroot",
emptyOutDir: true
},
esbuild: {
supported: {
'top-level-await': true
},
legalComments: 'none'
}
});
Key Settings:
server.port: Dev server port (3218)build.outDir: Production build output- HMR settings for hot reload
tsconfig.json
Location: Project root
Purpose: TypeScript compiler configuration
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"removeComments": true
},
"include": ["src"]
}
Key Settings:
strict: Enable all strict type checkingnoUnusedLocals: Error on unused variablesjsx: Use React 17+ JSX transform
tailwind.config.js
Location: Project root
Purpose: Tailwind CSS configuration
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}"
],
theme: {
extend: {
colors: {
primary: "#ec2b37" // Mardens red
}
}
},
darkMode: "class",
plugins: [
require("@heroui/react")
]
};
Customization:
theme: {
extend: {
colors: {
primary: "#ec2b37",
secondary: "#0070f3"
},
fontFamily: {
sans: ["Inter", "sans-serif"]
}
}
}
postcss.config.js
Location: Project root
Purpose: PostCSS configuration (CSS processing)
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
.eslintrc.cjs
Location: Project root
Purpose: ESLint configuration
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended'
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true }
]
}
};
Build Configuration
pnpm-workspace.yaml
Location: Project root
Purpose: Define monorepo workspace
packages:
- "build-deps"
.npmrc
Location: Project root
Purpose: npm configuration
public-hoist-pattern[]=*@heroui/*
Why: Hoist HeroUI packages to root for better dependency resolution
Development Scripts
scripts/dev.js
Location: scripts/dev.js
Purpose: Start both backend and frontend dev servers
const { spawn } = require('child_process');
// Start backend with cargo watch
const api = spawn('npm', ['run', 'watch-api'], {
stdio: 'inherit',
shell: true
});
// Start frontend with Vite
const frontend = spawn('vite', [], {
stdio: 'inherit',
shell: true
});
// Handle exit
process.on('SIGINT', () => {
api.kill();
frontend.kill();
process.exit();
});
Environment Variables
Development
# Enable debug logging
RUST_LOG=debug
# Enable SQL query logging
RUST_LOG=sqlx=debug
# Enable trace logging (very verbose)
RUST_LOG=trace
Usage
# Backend
RUST_LOG=debug cargo run
# Tests
RUST_LOG=debug cargo test -- --nocapture
Production Configuration
Environment Detection
Backend:
pub const DEBUG: bool = cfg!(debug_assertions);
if DEBUG {
// Development mode
} else {
// Production mode
}
Frontend:
export const isProduction = window.location.hostname === "pricing-new.mardens.com";
if (isProduction) {
// Production mode
}
Build Output
Frontend: target/wwwroot/ (embedded in binary)
Backend: target/release/pricing_app (single executable)
Static Files
In production, frontend assets are embedded in the binary using include_dir!:
static ASSETS: Dir = include_dir!("$CARGO_MANIFEST_DIR/target/wwwroot");
Configuration Checklist
Initial Setup
- Create
dev-server.jsonwith database credentials - Install Rust toolchain (1.75+)
- Install Node.js (18+)
- Run
cargo buildto install dependencies - Run
npm installto install dependencies - Create MySQL database named "pricing"
Before Deployment
- Update version in
Cargo.toml - Update version in
package.json - Update
Changelog.json - Test build:
npm run build - Run tests:
cargo test - Check for TypeScript errors:
tsc --noEmit
Common Issues
"dev-server.json not found":
- Create file in project root with database credentials
"Port 1421 already in use":
- Stop other instance:
pkill -f pricing_app - Or change PORT in
constants.rs
"Port 3218 already in use":
- Stop Vite:
pkill -f vite - Or change port in
vite.config.ts
Build failures:
- Clear caches:
cargo clean && rm -rf node_modules && npm install - Check Rust version:
rustc --version(need 1.75+) - Check Node version:
node --version(need 18+)
Last Updated: 2025-11-04