How cbcgb-com/sgbs-training works
1. Repository purpose
- This repo supports a Chinese Bible-study training program (“小組查經帶領訓練”).
- Architecturally it is not just a single app: it combines a training website, an authenticated application, content/docs, and a few tooling/scripts for generating or validating training materials.
2. Two main user-facing surfaces
- apps/ appears to be the runtime web application layer, with app.py, api.py, HTML templates, and static assets.
- docs/ is a separate documentation/knowledge site, likely built with MkDocs, containing class notes, resources, examples, and teaching prep material.
3. Application runtime boundary
- apps/app.py is likely the main web server entrypoint.
- apps/api.py suggests a lightweight internal API or route layer separate from page rendering.
- apps/templates/template.html and apps/static/ indicate server-rendered pages with static frontend assets rather than a full SPA.
4. Core domain package
- The sgbs_training/ package contains the reusable application logic:
- authentication.py for access control / login checks
- api.py for API-facing logic
- docs.py for documentation/content retrieval or rendering
- email.py for message generation/sending
- exercises.py for training exercise logic
- scriptures.py for Bible text/reference handling
- This suggests a clean separation between web entrypoints and domain/services code.
5. Content and learning workflow
- The repo centers on instructional content: lesson foundations, narrative/questioning/argumentation, study-note examples, and teaching resources.
- sgbs_training/exercises.py and sgbs_training/scriptures.py likely power interactive study workflows by combining exercise prompts with scripture references and model answers/examples from docs/examples/.
6. Authentication and user gating
- sgbs_training/authentication.py plus apps/users.txt imply a simple user list or access whitelist rather than a large identity provider.
- This is an important boundary: some content or tools are probably restricted to trainees or instructors, while the MkDocs content may be public or semi-public.
7. Email and generated artifacts
- sgbs_training/email.py and deployments/email_generator.py indicate an email-oriented distribution path, likely for sending class updates, study materials, or generated notifications.
- This is separate from the web app path and represents a batch/offline output channel.
8. Documentation site architecture
- mkdocs.yml plus docs/ indicate a documentation site with:
- class notes
- examples
- resources
- templates and styles
- custom JavaScript for UI behavior
- The docs tree functions as the canonical curriculum/content repository, not just supplemental readme files.
9. Custom docs behavior
- docs/javascripts/chinese-toggle.js and expandable-cards.js suggest interactive documentation features.
- docs/stylesheets/extra.css and transition.css imply custom branding and presentation, likely for a polished teaching site rather than plain docs.
10. Operational/deployment layer
- .github/workflows/ contains separate pipelines for preview, app deployment, website deployment, and merge scheduling.
- Dockerfile indicates containerized execution/deployment.
- The repo therefore has at least two deployable targets: the application and the documentation website.
11. Automation and validation tooling
- notebooks/ contains exploratory/prototype work, including auth checks and Google Docs automation prototypes.
- pyproject.toml, pixi.lock, .pre-commit-config.yaml, and .markdownlint.json show a Python-centric development workflow with formatting/linting and environment locking.
- These are support systems around the main product, not core runtime components.
12. Likely high-level data flow
- Training content is authored in docs/ and perhaps transformed/consumed by sgbs_training/docs.py.
- The web app (apps/ + sgbs_training/) serves authenticated users, combining scripture/exercise logic with templates/static assets.
- Email generation (deployments/email_generator.py / sgbs_training/email.py) produces outbound communications from the same content base.
- CI/CD then publishes the app and docs as separate artifacts.
13. Architecture diagram boundary suggestions
- Draw three major boxes:
- Documentation/Curriculum Site (docs/, mkdocs.yml)
- Authenticated Training App (apps/, sgbs_training/)
- Automation/Deployment (deployments/, .github/workflows/, Dockerfile, notebooks)
- Show shared content flowing from the docs/content layer into the app and email tooling.
Main entry points: mkdocs.yml MkDocs · app.py App server · docs.py Content · index.md Home
Components 25
Documentation site
Curriculum, examples, and MkDocs presentation layer.
- MkDocs · MkDocs configuration for the documentation/teaching site.
mkdocs.yml - Home · Main documentation landing page.
docs/index.md - Foundations · Representative class note for foundational training content.
docs/class-notes/lesson-1-foundations.md - Study notes · Representative worked example used as curriculum material.
docs/examples/luke-study-notes.md - Resources · Representative resource page for training references and guidance.
docs/resources/bible-study-notes.md - Doc scripts · Interactive documentation behaviors for Chinese toggles and expandable cards.
docs/javascripts/chinese-toggle.js - Doc styles · Custom documentation styling and transitions.
docs/stylesheets/extra.css - Dark theme · Custom documentation theme override.
docs/templates/dark.html
Training app
Authenticated web app and server-rendered interface.
- App server · Main authenticated web application entrypoint.
apps/app.py - App API · Lightweight application API/route layer.
apps/api.py - Page template · Primary HTML template for rendered pages.
apps/templates/template.html - Static assets · Static files served by the application.
apps/static - Users list · Simple user whitelist used by authentication checks.
apps/users.txt
Domain package
Reusable training logic shared by the app, docs helpers, and generators.
- Auth · Login and authorization checks.
sgbs_training/authentication.py - Core API · Shared API-facing logic used by the application.
sgbs_training/api.py - Content · Documentation/content retrieval and rendering helpers.
sgbs_training/docs.py - Scriptures · Bible text and reference handling.
sgbs_training/scriptures.py - Exercises · Exercise generation and study workflow logic.
sgbs_training/exercises.py - Email · Email/message generation and sending support.
sgbs_training/email.py
Automation
Deployment, containerization, and offline generation pipelines.
- Email gen · Offline generator for email-oriented outputs.
deployments/email_generator.py - Deploy app · Workflow for building and deploying the training app.
.github/workflows/deploy-app.yaml - Deploy site · Workflow for building and deploying the documentation website.
.github/workflows/deploy-website.yaml - Preview build · Workflow for preview/test builds.
.github/workflows/build-preview.yaml - Merge schedule · Scheduled merge or maintenance workflow.
.github/workflows/merge-schedule.yaml - Docker · Container image definition for runtime/deployment.
Dockerfile
Connections 31
- MkDocs → Home: publishes · MkDocs serves the documentation home and site structure.
- MkDocs → Doc scripts: loads · Docs site includes custom interactive JavaScript.
- MkDocs → Doc styles: styles · Docs site uses custom styling overrides.
- MkDocs → Dark theme: themes · Docs site uses a custom theme template.
- Home → Foundations: links · The docs site connects the home page to curriculum notes.
- Home → Study notes: links · The docs site connects the home page to worked examples.
- Home → Resources: links · The docs site connects the home page to study resources.
- App server → Page template: renders · Server entrypoint renders HTML pages via templates.
- App server → Static assets: serves · Application serves static assets alongside pages.
- App server → App API: routes · Main app delegates route/API handling to its API layer.
- App server → Auth: checks · Web app depends on authentication for gated access.
- App API → Core API: uses · Application API layer uses shared service logic.
- App API → Exercises: drives · API routes expose training exercise workflows.
- App API → Scriptures: reads · API routes use scripture/reference lookups.
- Auth → Users list: validates · Authentication checks against a simple user whitelist.
- Content → Foundations: reads · Content service consumes curriculum notes.
- Content → Study notes: reads · Content service consumes example study materials.
- Content → Resources: reads · Content service consumes supporting resources.
- Exercises → Scriptures: references · Exercise logic is grounded in Bible text and references.
- Exercises → Content: uses · Exercises draw from stored teaching content and examples.
- Email → Content: composes · Email generation uses shared curriculum/content material.
- Email gen → Email: produces · Offline generator produces email-ready output through the mail layer.
- Email gen → Content: uses · Batch email generation consumes the same training content base.
- Deploy app → Docker: builds · App deployment workflow uses container build artifacts.
- Deploy app → App server: deploys · Workflow deploys the authenticated application.
- Deploy site → MkDocs: builds · Website workflow builds the docs site.
- Deploy site → Home: publishes · Website workflow publishes the documentation content.
- Preview build → MkDocs: validates · Preview workflow validates docs builds.
- Preview build → App server: validates · Preview workflow also exercises the app build.
- Merge schedule → Deploy app: coordinates · Scheduled automation coordinates with deployment workflows.
- Merge schedule → Deploy site: coordinates · Scheduled automation coordinates with website publication.