Initial commit: Clean Mold Cost Calculator application
- Flask-based mold cost calculation application - PostgreSQL database with SQLAlchemy ORM - Docker/Podman containerization - Comprehensive documentation in docs/ - Clean, organized codebase without obsolete files - Production-ready deployment configuration - Enhanced pytest configuration with coverage reporting - Master/Development branch structure
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
# 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 <repository-url>
|
||||
cd mold_cost_online_tool
|
||||
```
|
||||
|
||||
2. **Set up environment variables**
|
||||
Create `.env.development` file for development:
|
||||
```bash
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_DB=mold_cost
|
||||
DATABASE_HOST=db_development
|
||||
SECRET_KEY=your-secret-key
|
||||
MAIL_SERVER=smtp.example.com
|
||||
MAIL_USERNAME=your-email@example.com
|
||||
MAIL_PASSWORD=your-password
|
||||
MAIL_DEFAULT_SENDER=your-email@example.com
|
||||
ADMIN_EMAIL=admin@example.com
|
||||
ADMIN_PASSWORD=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 <repository-url>
|
||||
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
|
||||
export DATABASE_URL=postgresql://user:password@localhost/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
|
||||
DATABASE_URL=postgresql://user:password@host/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
|
||||
|
||||
[Add your license information here]
|
||||
|
||||
## Support
|
||||
|
||||
[Add support contact information here]
|
||||
Reference in New Issue
Block a user