A Progressive Web App (PWA) for ecommerce group buy poultry products that are only available on certain days. Users can place orders, optionally pay online, and track their orders.
- Vue 3 - Progressive JavaScript framework
- Vite - Build tool and dev server
- Vue Router - Client-side routing
- Axios - HTTP client for API calls
- Nginx - Web server for production
- Flask - Python web framework
- Flask-SQLAlchemy - ORM for database operations
- Flask-CORS - Cross-Origin Resource Sharing support
- PyMySQL - MySQL database connector
- Gunicorn - WSGI HTTP Server for production
- Google Cloud Platform (GCP)
- Cloud Run - Serverless container platform
- Cloud Build - CI/CD pipeline
- Cloud SQL - Managed MySQL database (to be configured)
- Service Accounts - Authentication and authorization
gsf-app/
├── backend/ # Flask backend application
│ ├── app.py # Application factory
│ ├── config.py # Configuration settings
│ ├── routes.py # API routes
│ ├── wsgi.py # WSGI entry point
│ ├── requirements.txt # Python dependencies
│ ├── Dockerfile # Backend container image
│ ├── cloud-run.yaml # Cloud Run configuration
│ ├── deploy.sh # Deployment script
│ └── models/ # Database models
│ ├── __init__.py
│ └── base.py # Base model class
├── app/ # Vue.js app frontend (app.grainstoryfarm.ca)
│ ├── src/
│ │ ├── api/ # API client configuration
│ │ ├── router/ # Vue Router configuration
│ │ ├── views/ # Vue components/pages
│ │ ├── App.vue # Root component
│ │ └── main.js # Application entry point
│ ├── index.html # HTML template
│ ├── package.json # Node.js dependencies
│ ├── vite.config.js # Vite configuration
│ ├── Dockerfile # Frontend container image
│ ├── nginx.conf # Nginx configuration
│ ├── docker-entrypoint.sh # Container entrypoint
│ ├── cloud-run.yaml # Cloud Run configuration
│ └── deploy.sh # Deployment script
├── cloudbuild.yaml # Cloud Build CI/CD configuration
├── deploy-all.sh # Deploy all services script
├── instance/ # Local instance files (git-ignored)
│ └── service_accounts/ # Service account credentials
└── README.md # This file
- Python 3.11+
- Node.js 20+
- MySQL (or Cloud SQL)
- Docker (for containerized deployment)
- Navigate to backend directory:
cd backend- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the backend directory:
SECRET_KEY=your-secret-key-here
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your-password
MYSQL_DATABASE=gsf_app- Start the backend (includes Cloud SQL Proxy):
./start-local.shOr manually:
# Start Cloud SQL Proxy in one terminal
./start-proxy.sh
# In another terminal, start Flask
source venv/bin/activate
python app.pyThe backend will be available at http://localhost:5001
- Navigate to app directory:
cd app- Install dependencies:
npm install- Create a
.envfile in the app directory (optional, defaults to/api):
VITE_API_BASE_URL=http://localhost:5000/api
VITE_GOOGLE_MAPS_API_KEY=your-google-maps-api-key-hereNote: The VITE_GOOGLE_MAPS_API_KEY is required for address autocomplete functionality. To get a Google Maps API key:
-
Go to Google Cloud Console
-
Create a new project or select an existing one
-
Enable the "Places API" and "Maps JavaScript API"
-
Create credentials (API Key)
-
Configure API key restrictions:
- Go to APIs & Services > Credentials
- Click on your API key
- Under "Application restrictions", select "HTTP referrers (web sites)"
- Add the following referrers:
http://localhost:3000/*(for local development)http://localhost:*/*(for any localhost port)https://app.grainstoryfarm.ca/*(for production)https://*.grainstoryfarm.ca/*(for all subdomains)
- Under "API restrictions", restrict to:
- Maps JavaScript API
- Places API
- Save the changes
-
Run the development server:
npm run devThe app frontend will be available at http://localhost:3000
- Google Cloud SDK installed and configured
- GCP project:
focused-mote-477703-f0 - Service account credentials in
instance/service_accounts/ - Cloud SQL instance created (for database)
The project uses a service account for deployment. The credentials are stored in:
instance/service_accounts/focused-mote-477703-f0-0571d061607f.json
Note: This file is git-ignored and should not be committed to version control.
Deploy all services (backend, app frontend, and admin frontend) using the single deployment script:
./deploy-all.sh us-central1Or with custom service account path:
./deploy-all.sh us-central1 path/to/service-account.jsonThis script will:
- Build and deploy backend to Cloud Run
- Build and deploy app frontend to Cloud Run
- Build and deploy admin frontend to Cloud Run
- Map custom domains (app.grainstoryfarm.ca and admin.grainstoryfarm.ca)
The application uses custom domains:
- App Frontend:
app.grainstoryfarm.ca→gsf-app-frontend - Backend:
backend.grainstoryfarm.ca→gsf-app-backend
Domain mappings are already configured in Cloud Run. To manage them:
# List domain mappings
gcloud beta run domain-mappings list --region us-central1 --project=focused-mote-477703-f0
# Describe a domain mapping
gcloud beta run domain-mappings describe --domain=app.grainstoryfarm.ca --region us-central1 --project=focused-mote-477703-f0Set the following secrets in Google Cloud Secret Manager for the backend:
mysql-host- MySQL host addressmysql-user- MySQL usernamemysql-password- MySQL password
Update backend/cloud-run.yaml to reference these secrets.
For the app frontend, set the VITE_API_BASE_URL environment variable in Cloud Run to point to your backend URL.
- Create a Cloud SQL MySQL instance in GCP
- Create the database:
gsf_app - Set up database migrations using Skeema (similar to reference project) or Flask-Migrate
- Configure connection using Cloud SQL Proxy or private IP
- Create a service account in GCP Console
- Grant necessary permissions:
- Cloud Run Admin
- Cloud Build Service Account
- Cloud SQL Client (if using Cloud SQL)
- Download the service account key JSON file
- Store it securely (not in git) and reference it in your deployment scripts
GET /api/health- Returns API health status
GET /api/test- Test endpoint
More endpoints will be added as features are developed.
-
Set up database models for:
- Products (poultry items)
- Orders
- Users/Customers
- Payment transactions
-
Implement PWA features:
- Service worker for offline support
- Web app manifest
- Push notifications
-
Add authentication and authorization
-
Implement payment integration
-
Add order tracking functionality
[Add your license here]