9b84cee5beb50ccd485c347512170841250324aa
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)
-
Clone the repository
git clone <repository-url> cd mold_cost_online_tool -
Set up environment variables Create
.env.developmentfile for development: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 -
Start the development environment
podman-compose -f podman-compose.development.yml up --build -
Initialize the database
flask db upgrade
Option 2: Local Development
-
Clone the repository
git clone <repository-url> cd mold_cost_online_tool -
Create and activate virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Install dependencies
pip install -r requirements.txt -
Set up PostgreSQL database
- Install PostgreSQL
- Create database and user
- Set environment variables for database connection
-
Set up environment variables
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 -
Initialize the database
flask db upgrade
Development
-
Run development server
python run.py -
Run tests
python -m pytest tests/
Deployment
-
Production server setup
- Configure Nginx as reverse proxy
- Set up Gunicorn with provided configuration
- Configure SSL certificates
- Set up PostgreSQL database
-
Environment variables for production
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 -
Start the application
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
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
PCT & TOOLING app, all rights reserved.
Support
For support and inquiries, please contact: jimmy.gan@adidas.com
Description
Languages
Python
41.1%
HTML
41%
JavaScript
8.1%
Shell
5.3%
CSS
2.6%
Other
1.9%