How harshini-raja/ai_greeting_cards works
Purpose and Entry Points
This is a Python greeting-card generation engine, currently centered on birthday-card assets and a JSON template. The likely runnable entry point is run_standalone.py; generate_placeholders.py supports asset/template preparation. The package API begins at card_engine/__init__.py.
Application Orchestration
card_engine/card_service.py is the primary application-service boundary: it likely coordinates template selection, domain input, layout, and rendering into generated card output. card_engine/domain.py defines the core card concepts and data exchanged between stages. run_standalone.py is the outer execution boundary for local generation.
Template and Asset Inputs
Templates are separated from executable logic. templates/birthday_classic.json defines a birthday-card composition, while card_engine/templates.py loads or interprets template definitions. Static visual inputs are organized under assets/birthday/ and assets/birthday/base; card_engine/assets.py resolves and supplies those resources to the generation pipeline.
Layout and Typography Stage
card_engine/layout.py converts template/domain content into positioned visual elements. card_engine/typography.py handles text-specific decisions such as font-related measurement or styling. This separation makes text placement a distinct concern from overall card composition.
Rendering Boundary
card_engine/render.py turns resolved layout and assets into the final card artifact. card_engine/card_service.py should be the caller-facing layer above this renderer, keeping output production separate from template parsing and domain construction. Generated artifacts are represented by the repository’s output/ directory.
Primary Flow
The intended control flow is: standalone caller → card service → domain/template and asset resolution → layout/typography → renderer → output/. Template JSON and static assets are input boundaries; rendering is the production boundary. generate_placeholders.py likely creates fallback or development visual resources before normal rendering.
Runtime and Infrastructure
The repository is a local Python package with filesystem-based templates, assets, and output rather than visible network infrastructure or external services. No deployment, database, queue, or web-server entry point is present in the supplied tree.
Main entry points: card_service.py Card service · layout.py Layout engine · assets.py Asset resolver · render.py Renderer
Components 14
Entry Points
- Standalone runner · Local card-generation execution boundary.
run_standalone.py - Placeholder generator · Prepares fallback or development visual resources.
generate_placeholders.py - Package API
card_engine/__init__.py
Template & Assets
- Birthday classic template · Defines the birthday-card composition.
templates/birthday_classic.json - Birthday assets
- Base birthday assets
assets/birthday/base
Card Engine
- Card service · Coordinates the card generation pipeline.
card_engine/card_service.py - Card domain · Core card concepts exchanged between stages.
card_engine/domain.py - Template loader
card_engine/templates.py - Asset resolver
card_engine/assets.py - Layout engine · Positions resolved visual elements.
card_engine/layout.py - Typography engine · Measures and styles text for placement.
card_engine/typography.py - Renderer · Produces the final card artifact.
card_engine/render.py
Generated Output
- Output artifacts
Connections 18
- Standalone runner → Card service: generates card
- Package API → Card service: exposes
- Placeholder generator → Birthday assets: prepares
- Card service → Card domain: builds input
- Card service → Template loader: selects template
- Card service → Asset resolver: resolves assets
- Card service → Layout engine: composes card
- Birthday classic template → Template loader: template definition
- Birthday assets → Asset resolver: visual resources
- Base birthday assets → Asset resolver: base resources
- Card domain → Layout engine: card content
- Template loader → Layout engine: composition rules
- Asset resolver → Layout engine: resolved resources
- Layout engine → Typography engine: text placement
- Typography engine → Renderer: styled text
- Layout engine → Renderer: positioned elements
- Asset resolver → Renderer: renderable assets
- Renderer → Output artifacts: writes card