Files
CGW-Quote-Builder/product_app/README.md
T
2026-04-11 00:04:09 -05:00

148 lines
4.2 KiB
Markdown

# Product App - Modular Flask Application
## 🏗️ Structure
```
product_app/
├── app.py # Main application file
├── passenger_wsgi.py # Passenger WSGI entry point for production
├── requirements.txt # Python dependencies
├── blueprints/ # Modular routes organized by feature
│ ├── __init__.py
│ ├── auth.py # Login/logout/session management
│ └── users.py # User CRUD operations
├── templates/ # HTML templates
│ ├── login.html
│ └── user_manager.html
└── data/ # Data storage
└── users.json # User accounts with hashed passwords
```
## 🎯 Features Implemented
### ✅ Authentication System (blueprints/auth.py)
- Login with username/password
- Session management
- Password hashing (PBKDF2-SHA256, 1M iterations)
- Login required decorator
- Permission checking: `can_user('manage_users')`
- User status checking (active/inactive)
### ✅ User Management (blueprints/users.py)
- View all users
- Add new users
- Delete users
- Toggle active/inactive status
- Change passwords (requires admin verification)
- Location-based access control
- Permission system (manage_users, create_quotes, etc.)
- Download users as JSON
## 🔐 Default Login
- **Username:** `Master`
- **Password:** `Master`
- **Permissions:** Full access (manage_users)
## 🚀 Local Testing
```bash
cd product_app
python app.py
```
Visit: http://localhost:8080/
## Routes
### Main Routes
- `/` - Home (redirects to login if not authenticated)
- `/test` - Test page to verify app is running
### Authentication Routes (auth_bp)
- `/login` - Login page
- `/logout` - Logout
- `/api/login` - POST: Login API
- `/api/session` - GET: Current session info
### User Management Routes (users_bp)
- `/users/` - User management page
- `/users/api` - GET: List all users, POST: Add user
- `/users/api/<index>` - DELETE: Delete user
- `/users/api/<index>/active` - PATCH: Toggle active status
- `/users/api/<index>/change-password` - POST: Change password
- `/users/api/download` - GET: Download users.json
## 📦 Production Deployment
### Upload to Server: `/home/bmdwtjuw/product-finder/`
Files to upload:
- `app.py`
- `passenger_wsgi.py` (or just use existing)
- `blueprints/` (entire folder)
- `__init__.py`
- `auth.py`
- `users.py`
- `templates/` (entire folder)
- `login.html`
- `user_manager.html`
- `data/users.json`
### Control Panel Settings
- **Application startup file:** `passenger_wsgi.py` (or `app.py`)
- **Application Entry point:** `application`
- **Python version:** 3.13.11
### Test After Deployment:
1. https://columbiawindows.com/product-finder/test
2. https://columbiawindows.com/product-finder/login
3. Login with Master/Master
4. Test user management
## 🔧 Adding New Features
### Create a New Blueprint
1. Create `blueprints/your_feature.py`:
```python
from flask import Blueprint, render_template
from blueprints.auth import login_required, can_user
your_feature_bp = Blueprint('your_feature', __name__, url_prefix='/your-feature')
@your_feature_bp.route('/')
@login_required
def index():
return render_template('your_feature.html')
```
2. Register in `app.py`:
```python
from blueprints.your_feature import your_feature_bp
app.register_blueprint(your_feature_bp)
```
3. Create `templates/your_feature.html`
4. Test locally, then upload to server
## 📝 Benefits of Blueprint Structure
**Separation of Concerns:** Each feature in its own file
**Easy to Maintain:** Find and edit specific features quickly
**Scalable:** Add new features without touching existing code
**Testable:** Each blueprint can be tested independently
**Reusable:** Share decorators (login_required, permission_required) across blueprints
## 🛠️ Next Steps
- Add more blueprints for other features (quotes, products, etc.)
- Add more templates as needed
- Extend permission system
- Add location selection page
- Add the main product finder quiz