1 line
8.1 KiB
JSON
1 line
8.1 KiB
JSON
{"ts":"2026-03-21T23:53:51.596853071Z","type":{"kind":"loop_started","prompt":"You are building a production-ready Inspection Reporting and Management web application from scratch. The GitHub remote URL is: https://github.com/pingud98/prototoolagain.git\n\n---\n\n## TECH STACK\n\n- Language: Python 3.11+\n- Web Framework: Flask (with Flask-Login, Flask-WTF, Flask-SQLAlchemy)\n- Database: SQLite via SQLAlchemy ORM\n- PDF Generation: WeasyPrint (A4-formatted output)\n- TLS/HTTPS: Self-signed certificate via trustme or mkcert for local hosting\n- Frontend: Jinja2 templates + Tailwind CSS (via CDN) + vanilla JS\n- Auth: Bcrypt password hashing, session-based login\n- File Storage: Local filesystem under /uploads/, referenced in DB\n\n---\n\n## PROJECT STRUCTURE\n\ninspection-app/\n├── app/\n│ ├── __init__.py\n│ ├── models.py\n│ ├── routes/\n│ │ ├── auth.py\n│ │ ├── inspections.py\n│ │ ├── admin.py\n│ │ └── export.py\n│ ├── templates/\n│ │ ├── base.html\n│ │ ├── login.html\n│ │ ├── dashboard.html\n│ │ ├── inspection_form.html\n│ │ ├── inspection_view.html\n│ │ └── admin/\n│ │ ├── users.html\n│ │ └── user_form.html\n│ ├── static/\n│ │ ├── css/\n│ │ └── js/\n│ └── utils/\n│ ├── pdf_generator.py\n│ └── security.py\n├── uploads/\n├── certs/\n├── setup.py\n├── config.py\n├── run.py\n├── requirements.txt\n└── .gitignore\n\n---\n\n## DATABASE MODELS\n\n### User\n- id, username, full_name, email, password_hash, is_admin, is_active, created_at\n\n### Inspection\n- id, installation_name, location, inspection_date, version (int, starts at 1),\n reference_number (int), observations, conclusion_text,\n conclusion_status (enum: ok / minor / major),\n created_by (FK User), created_at, updated_at\n\n### InspectionInspector\n- id, inspection_id (FK), user_id (FK nullable), free_text_name (nullable)\n (Supports both registered users and free-text names)\n\n### Photo\n- id, inspection_id (FK), filename, caption,\n action_required (enum: none / urgent / before_next), uploaded_at\n\n---\n\n## SETUP SCRIPT (setup.py)\n\nThe setup script must:\n1. Install all dependencies from requirements.txt using pip\n2. Generate a self-signed TLS certificate and key, saved to certs/\n3. Create the SQLite database and run all table migrations\n4. Prompt the admin for: username, full name, email, password (with confirmation)\n5. Create the admin account with is_admin=True\n6. Print a success message with the local HTTPS URL (e.g. https://localhost:5000)\n7. Be runnable with: python setup.py\n\n---\n\n## CORE FEATURES\n\n### Authentication\n- Login page (username + password)\n- Session-based auth with Flask-Login\n- All routes protected — redirect to login if not authenticated\n- Logout route\n- No self-registration — admin creates all accounts\n\n### Admin Panel (/admin)\n- List all users\n- Create new user (username, full name, email, password, admin toggle)\n- Edit user (change name, email, reset password, toggle active/admin)\n- Deactivate (not delete) users\n- Only accessible to is_admin=True users\n\n### Dashboard (/)\n- Table of all inspections the logged-in user has access to\n- Columns: Reference No., Installation Name, Location, Date, Version, Conclusion Status, Actions\n- Actions: View, Edit, Export PDF\n- \"New Inspection\" button\n\n### Inspection Form (/inspection/new and /inspection/<id>/edit)\n\nFields:\n1. Installation Name — text input\n2. Location — text input\n3. Date of Inspection — date picker\n4. Version — auto-incremented integer (display only, not editable)\n5. Reference Number — integer input\n6. Inspector(s) — pre-filled with logged-in user's full name; allow adding more via:\n - Dropdown of registered users\n - Free-text field for external individuals\n - Display as removable tags/chips\n7. Observations — large textarea\n8. Photos section:\n - Upload multiple photos\n - For each uploaded photo display a thumbnail\n - Per-photo fields: caption (text), action_required (radio buttons):\n \"No action required\"\n \"Urgent action required\"\n \"Action required before next inspection\"\n - Ability to remove photos\n9. Conclusion section:\n - Conclusion comments textarea\n - Radio buttons (select exactly one):\n OK for operation in current state\n Minor comments — Remedial actions required for continued operation\n Major comments — Operation suspended until resolution and satisfactory follow-up inspection\n\nButtons:\n- New inspection: \"Complete Report\" → saves, sets version=1, redirects to view page\n- Edit existing: \"Update Report\" → saves, increments version by 1, redirects to view page\n- Cancel → returns to dashboard\n\n### Inspection View (/inspection/<id>)\n- Read-only formatted view of the report\n- Shows all fields, photos (with captions and action status), inspectors, conclusion\n- \"Edit Report\" button\n- \"Export as PDF\" button\n\n---\n\n## PDF EXPORT (/inspection/<id>/pdf)\n\n- Generated using WeasyPrint\n- Formatted for A4 pages\n- Include:\n - App name / report title header\n - All inspection fields in a clean two-column layout\n - Inspector names listed\n - Observations in a clearly delineated box\n - Photos displayed in a grid (max 2 per row), each with caption and action status clearly labelled\n - Conclusion section with selected status prominently displayed\n - Footer with page number and generation timestamp\n- Flows naturally across multiple A4 pages if content requires it\n- Served as a file download: inspection_report_<ref>_v<version>.pdf\n\n---\n\n## SECURITY REQUIREMENTS\n\n- All passwords hashed with bcrypt (min cost factor 12)\n- CSRF protection on all forms via Flask-WTF\n- File uploads validated: only JPEG, PNG, GIF, WEBP accepted; max 10MB per file\n- Uploaded filenames sanitised with werkzeug.utils.secure_filename and stored with UUID prefix\n- User input escaped in all templates (Jinja2 autoescaping enabled)\n- Admin routes protected with both login_required and admin_required decorators\n- Secret key loaded from environment variable SECRET_KEY or auto-generated and saved to .env on first run\n- HTTPS enforced — Flask run with SSL context using certs from certs/\n- .env and *.db and certs/ added to .gitignore\n\n---\n\n## GITHUB INSTRUCTIONS\n\n- The repository already exists and has been initialised with prior commits\n- Completely discard all prior history\n- Use git checkout --orphan new-branch, add all files, commit, then force-push to main\n- Commit message: \"Initial commit: Inspection reporting app\"\n- Include a comprehensive README.md with:\n - Project overview\n - Requirements (Python version, OS)\n - Setup instructions (python setup.py)\n - How to run (python run.py)\n - How to access (HTTPS URL)\n - Notes on the self-signed certificate browser warning\n\n---\n\n## CODE QUALITY STANDARDS\n\n- All Python files include docstrings\n- Routes grouped into Blueprints\n- No hardcoded secrets\n- Database access only via SQLAlchemy ORM — no raw SQL\n- Error pages for 403, 404, 500\n- Flash messages for all user actions (success and error)\n- Logging to a rotating file log (logs/app.log)\n\n---\n\n## EXECUTION ORDER\n\nBuild in this order:\n1. requirements.txt and config.py\n2. app/models.py\n3. app/__init__.py (app factory)\n4. Auth blueprint + templates\n5. Admin blueprint + templates\n6. Inspection blueprint + form + view templates\n7. PDF export utility + route\n8. setup.py\n9. run.py\n10. README.md\n11. .gitignore\n12. GitHub force-push\n\nDo not proceed to the next step until the current one is complete and internally consistent.\n\n---\n\n## NOTES FOR THE OPERATOR\n\n- WeasyPrint requires system-level dependencies. Install them before running setup.py:\n Debian/Ubuntu: sudo apt install libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0\n macOS: brew install pango\n Windows: See https://doc.courtbouillon.org/weasyprint/stable/first_steps.html\n\n\n"}}
|