Central to the OpenCannabis project's goals is a unified datamodel for use across functional boundaries. When cultivators talk about flowers with labs, and labs talk about test results with retailers, and so on, they are all talking about the same thing - but in today's legal cannabis industry, they aren't speaking the same language.
- Toolchain
- General Guidelines
- Message Categories
- Part 1.1: Core Structures
base
: Foundational structures used across the spec.temporal
: Dates, times, and so on.crypto
: Cryptographic primitives and containers.geo
: Structures relating to geography.device
: Managed and anonymous, operating systems, browsers.content
: Narrative and marketing content.person
: People, names, birth dates, and so on.contact
: Email, phone, and postal addresses.media
: Images, video, documents, etc.structs
: Utility structures used across the spec.
- Part 1.2: Extension Structures
labtesting
: Laboratory testing and QA.pricing
: Pricing schemes and structures.proximity
: Bluetooth and GPS-related structures.oauth
: OAuth2 implementation structures.products
: High-level product structures.commerce
: Commercial ordering and fulfillment structures.accounting
: Bookkeeping, accounting, taxes, and so on.
- Part 1.1: Core Structures
The model put forth by OpenCannabis is specified in a programming language called Protocol Buffers that originated inside Google. Protobuf, as it is referred to colloquially, has numerous strengths that this project leverages to deliver better compatibility and support to spec adopters:
- Protobuf is an easy language to learn, even for non-technical contributors
- Models written in Protobuf can be compiled into a ton of languages: all popular ones and quite a few others, too.
This means: complete language agnosticism if you are adopting OpenCannabis! 🚀
- Language support includes, but is not limited to: C/C++, Java, C#, Python Go, Objective-C, Swift, PHP, and R
- Custom Protobuf plugins can be written to generate custom code, docs, or other materials
- Compatibility with other Protobuf-authored models, such as OpenRTB and Google APIs
Models implemented in Protobuf are referred to as Messages. Services, which specify Methods, make use of Messages as input and output structures.
These guidelines govern how OpenCannabis specifications make use of Protobuf.
- Models accompanying a specification MUST provide an implementation written in Protobuf.
- Source files MUST use the syntax mode
proto3
. - Source files MUST use the package prefix with
opencannabis
. - Source files MUST adhere to the policies in 3/OCS- 1.2(A-D).
These guidelines govern how OpenCannabis protobuf source files must be formatted and specified.
- Source files MUST specify a
java_package
. - Source files MUST specify a
objc_class_prefix
. - Source files MUST specify a Java package starting with
io.opencannabis
. - Source files MUST place exactly one newline at the beginning of the file.
- Source files MUST place exactly one newline after the
syntax = proto3
declaration. - Source files MUST list file-level options immediately after the
syntax
declaration. - Source files MUST list imports immediately after file-level options, separated by exactly one newline.
- Source files MUST place exactly two newlines after the imports.
- Source files SHOULD specify an
optimize_for
value ofSPEED
. - Source files SHOULD specify a
java_outer_classname
. - Source files SHOULD make use of the
objc_class_prefix
value ofOCS
. - Source files SHOULD place
enum
specifications at the beginning of the file. - Source files SHOULD place
service
specifications at the end of the file. - Source files MAY break up many imports into groups, each separated by exactly one newline.
These guidelines govern how OpenCannabis protobuf messages are structured and specified.
- Messages MUST begin with a capital letter.
- Messages MUST adhere to CamelCase when including multiple words in their name.
- Messages MUST include a comment describing their use and purpose, according to 3/OCS-1.2(D).
- Messages MUST select or allocate a Message Category according to 3/OCS-1.3.
- Messages MUST include exactly one newline between each other.
- Messages MUST immediately begin properties without an initial newline.
- Messages MUST NOT include a terminal newline before the closing curly bracket.
- Messages SHOULD specify required or notable properties first.
These guidelines govern individual message properties.
- Properties MUST be specified in all-lowercase, underscored form (i.e.,
example_property_name
). - Properties MUST include exactly one newline after their definition, unless they are the last property specified.
- Properties MUST include a comment describing their use and purpose, according to 3/OCS-1.2(D).
These guidelines govern inline source comments on Messages, Properties, Services and Methods.
- Comments MUST begin with a single space.
- Comments MUST end with a period.
- Comments MUST occur directly above the entry they are commenting on, with no newline below.
- Comments MUST wrap lines at 80 characters; no less, no more.
- Comments SHOULD describe their subject in simple, easy-to-understand terms.
- Comments SHOULD be complete sentences, in present-imperative form (i.e., 'Specifies xyz, in abc circumstances.').
Messages may be grouped or placed adjacently according to their functional purpose. Message categories may either be included in the core specification, (in which case, they are considered Core Message Categories) or they are proposed by an Extension to the OpenCannabis specification, the process for which is specified below in Subsection B. Each Core Message Category and Extension Message Category must include the models and procedures associated with that category.
All categories are to be registered, and listed accordingly in the main specification, in Appendix A: Model Categories, along with their type and maturity status.
These guidelines govern the taxonomic process and interpretation of message categories:
- Message categories MUST follow the 1/C4 and 2/COSS guidelines and lifecycle.
- Message categories MUST be addressed by a one-word name in all-lowercase.
- Message categories MUST align folder structure with Protocol Buffer package structure.
- Message categories MUST NOT be coupled to stakeholder boundaries (i.e.,
cultivation
ormanufacturing
). - Contributors MUST provide a strong rationale for creating a new message category.
- Contributors SHOULD make an attempt to use an existing category rather than create one.
- Message categories SHOULD be allocated according to functional boundaries (i.e.,
media
oranalytics
) - Message categories MAY be nested in other message categories.