# Mold Cost Calculator A Flask-based web application for calculating mold costs and managing quotations. ## Features - **Cost Calculation** - Mold type-based calculations - Complexity factors (sidewall, slider, cavity) - Texture options (standard, custom, laser) - Tax rate support for different countries - **User Management** - Secure authentication system - Role-based access control - Admin dashboard for user management - Email-based registration with allowlist - **Quotation System** - Create and manage quotations - Export functionality - Historical record keeping - Admin review and management ## Tech Stack - **Backend**: Flask, SQLAlchemy - **Frontend**: HTML, CSS, JavaScript - **Database**: PostgreSQL (production/development), SQLite in-memory (testing) - **Server**: Gunicorn - **Proxy**: Nginx - **Authentication**: Flask-Login - **Forms**: Flask-WTF - **Database Migrations**: Flask-Migrate - **Containerization**: Podman/Docker ## Project Structure ``` mold_cost_online_tool/ ├── app/ # Application package │ ├── forms/ # Form definitions │ ├── models/ # Database models │ ├── static/ # Static files (CSS, JS) │ └── templates/ # HTML templates ├── instance/ # Instance-specific files ├── logs/ # Application logs ├── migrations/ # Database migrations ├── tests/ # Test files ├── deploy/ # Deployment configuration ├── db_data/ # Database data (development) ├── app.py # Main application file ├── config.py # Configuration ├── run.py # Application entry point ├── requirements.txt # Python dependencies ├── gunicorn_config.py # Gunicorn configuration ├── podman-compose.yml # Production container setup └── podman-compose.development.yml # Development container setup ``` ## Setup and Installation ### Option 1: Using Containers (Recommended) 1. **Clone the repository** ```bash git clone cd mold_cost_online_tool ``` 2. **Set up environment variables** Create `.env.development` file for development: ```bash POSTGRES_USER=your_db_user POSTGRES_PASSWORD=your_db_password POSTGRES_DB=mold_cost DATABASE_HOST=db_development SECRET_KEY=your-secret-key-here MAIL_SERVER=smtp.example.com MAIL_USERNAME=your-email@example.com MAIL_PASSWORD=your-mail-password MAIL_DEFAULT_SENDER=your-email@example.com ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=your-admin-password ``` 3. **Start the development environment** ```bash podman-compose -f podman-compose.development.yml up --build ``` 4. **Initialize the database** ```bash flask db upgrade ``` ### Option 2: Local Development 1. **Clone the repository** ```bash git clone cd mold_cost_online_tool ``` 2. **Create and activate virtual environment** ```bash python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate ``` 3. **Install dependencies** ```bash pip install -r requirements.txt ``` 4. **Set up PostgreSQL database** - Install PostgreSQL - Create database and user - Set environment variables for database connection 5. **Set up environment variables** ```bash export FLASK_APP=run.py export FLASK_ENV=development export SECRET_KEY=your-secret-key-here export DATABASE_URL=postgresql://your_user:your_password@localhost/your_dbname ``` 6. **Initialize the database** ```bash flask db upgrade ``` ## Development 1. **Run development server** ```bash python run.py ``` 2. **Run tests** ```bash python -m pytest tests/ ``` ## Deployment 1. **Production server setup** - Configure Nginx as reverse proxy - Set up Gunicorn with provided configuration - Configure SSL certificates - Set up PostgreSQL database 2. **Environment variables for production** ```bash FLASK_APP=run.py FLASK_ENV=production SECRET_KEY=your-secure-secret-key-here DATABASE_URL=postgresql://your_user:your_password@your_host/your_dbname ``` 3. **Start the application** ```bash gunicorn -c gunicorn_config.py run:app ``` ## Database Management - **Backups**: Automated daily backups using `pg_dump` - **Migrations**: Use Flask-Migrate for database schema changes - **Development**: Uses PostgreSQL container with persistent data - **Testing**: Uses SQLite in-memory database for fast, isolated tests ## Security Features - CSRF protection - Secure password hashing - Session management - Input validation - Security headers - Rate limiting - SQL injection prevention ## Maintenance - Regular database backups - Log rotation - Security updates - Performance monitoring ## Contributing 1. Fork the repository 2. Create a feature branch 3. Commit your changes 4. Push to the branch 5. Create a Pull Request ## License PCT & TOOLING app, all rights reserved. ## Support For support and inquiries, please contact: jimmy.gan@adidas.com # Test CD Trigger - Fri Jun 27 06:58:01 CST 2025