Skip to content

StompZone/cannabase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cannabase

Core data model and persistence layer for tracking cannabis plants and strains.

Overview

Cannabase is a small, framework-agnostic Python library that provides:

  • Strongly-typed models for strains and plants
  • A clear separation between plant IDs and grower labels
  • Support for clones, batches, rooms, and lifecycle stages (veg, flower, harvested, etc.)
  • A simple service layer (PlantService) that UI clients (Discord bots, CLIs, web apps) can talk to
  • A SQLite-backed repository implementation
  • A pytest test suite with coverage configuration

It is intentionally minimal: a clean domain layer with persistence and tests.

Installation

From a checkout of this repo:

pip install -e ".[dev]"

Or with Poetry:

poetry install

Core Concepts

Strains

Strains are defined with the Strain model in cannabase.models:

  • name – e.g. "Blue Dream"
  • breeder – optional breeder or source
  • genetics – e.g. "Blueberry x Haze"
  • flower_time_days_min / flower_time_days_max
  • strain_type – indica, sativa, hybrid, or unknown
  • notes

Strains are keyed by an internal integer id and managed via StrainRepository and SQLiteStrainRepository.

Plants

Plants track lifecycle details with fields including:

  • strain_id, label, status, origin_type
  • room, position, medium, container_size_liters
  • Lifecycle dates: planted, veg start, flower start, harvested, culled
  • Yield (wet_weight_g, dry_weight_g) and notes

Convenience properties:

  • age_days
  • days_in_stage
  • is_active

Quickstart

import datetime as dt

from cannabase.db import connect, init_schema
from cannabase.sqlite_repo import SQLitePlantRepository, SQLiteStrainRepository
from cannabase.services import PlantService

conn = connect("grow.db")
init_schema(conn)

strain_repo = SQLiteStrainRepository(conn)
plant_repo = SQLitePlantRepository(conn)
service = PlantService(strain_repo=strain_repo, plant_repo=plant_repo)

plant = service.add_plant(
    strain_name="Blue Dream",
    planted_at=dt.date(2025, 4, 20),
)

print(f"{plant.label} added! ID: {plant.id}")

plant = service.update_status(
    plant_id=plant.id,
    new_status="flower",
    when=dt.date(2025, 5, 20),
)

print(plant.notes)

Tests and Coverage

pytest
coverage run -m pytest
coverage report
coverage html

Coverage behavior is configured in pyproject.toml.


Project Layout

cannabase/
    models.py
    repositories.py
    sqlite_repo.py
    services.py
    db.py

tests/
    conftest.py
    test_models.py
    test_services.py
    test_sqlite_repo.py

Roadmap

  • Discord bot integration
  • CLI (python -m cannabase)
  • Additional query helpers
  • Event logging for feed/water/pest-management

About

An all-in-one cannabis cultivation data management solution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages