A management portal for Solberg Honung, handling beekeeping (Andelsbiodling) and lamb (Lammandel) shares, bookings, and automated invoicing.
- Season Management: Track and manage different production years.
- Booking Imports: Automatically import bookings from Google Sheets using the Google Sheets API.
- Invoice System: Generate unique invoices and send them automatically via email.
- Administration: Secure login via GitHub OAuth.
- Data Processing: Uses Pandas for robust handling of imported sheet data.
- Development Environment: Fully containerized with Docker and MailCatcher for email testing.
- Backend: Flask, SQLAlchemy, Flask-Migrate
- Data: Pandas, SQLite
- Integrations: Google Sheets API, GitHub OAuth
- Frontend: Bootstrap 5, Jinja2 Templates
- DevOps: Docker, Docker Compose, MailCatcher
-
Clone the repository:
git clone https://github.com/valyo/sh-portal cd sh_portal -
Environment Configuration: Create a
.envfile in the root directory with the following variables:SECRET_KEY=your-secret-key DATABASE_URL=sqlite:///instance/sh.db GITHUB_CLIENT_ID=your-github-id GITHUB_CLIENT_SECRET=your-github-secret GOOGLE_SHEET_ID=your-sheet-id
Place your Google Service Account JSON key (
sh-web-portal-f370fff1378a.json) in the root directory. -
Build and run using Docker Compose:
docker-compose up --build
-
Access the application:
- Web Portal: http://localhost:8087
- MailCatcher (Email testing): http://localhost:1088
.
├── main.py # Application entry point
├── migrations.py # Database migration script
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
├── docker-compose.yml # Multi-container orchestration
├── .env # Environment variables (to be created)
├── sh-web-portal-f370fff1378a.json # Google Service Account key
├── sh_portal/ # Main application package
│ ├── __init__.py # App factory and configuration
│ ├── models.py # SQLAlchemy database models
│ ├── utils.py # Utility functions (Sheet imports, etc.)
│ ├── home.py # Main portal blueprint
│ ├── seasons.py # Season management blueprint
│ ├── andelsbiodling.py # Beekeeping blueprint
│ ├── lammandel.py # Lamb blueprint
│ ├── commands.py # Custom Flask CLI commands
│ ├── static/ # CSS, JS, and Images
│ └── templates/ # HTML templates
├── migrations/ # Database migration history
└── instance/ # SQLite database storage
A helper script develop_pdf.py is available to preview certificate templates locally without running the full portal. It watches the template files and regenerates a PDF preview instantly on every save.
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install weasyprint watchdog jinja2
-
Run the preview script:
python develop_pdf.py
This will generate
certificate_preview.pdfin the root directory and update it whenever you change the HTML template.
To create an initial admin user for GitHub OAuth login, you can use the custom Flask command:
docker-compose exec backend flask create-new-admin <github_username>