Bulletin Builder ORM is a Python and MongoEngine-based abstraction layer for interacting with a MongoDB database. This ORM streamlines data management for the Bulletin Builder application, providing a robust and maintainable interface for CRUD operations and access control.
See the complete documentation at
- Modular structure by domain (templates, bulletins, cards, users, roles, groups, reviews, visual resources)
- Based on MongoEngine for efficient mapping with MongoDB
- Compatible with Python > 3.10
- Pydantic schemas for robust validation and serialization
- Easy integration into Bulletin Builder systems and other projects
- Python > 3.10
- MongoDB (local or remote)
- Dependencies:
- mongoengine
- pymongo
- dnspython
- python-dotenv
- pydantic
- typing_extensions
Install directly from GitHub:
pip install git+https://github.com/CIAT-DAPA/acb_ormTo install a specific version:
pip install git+https://github.com/CIAT-DAPA/acb_orm@v0.0.1Configure the database connection by creating a .env file in the project root or setting environment variables:
DATABASE_URI=mongodb://user:password@localhost:27017
DATABASE_NAME=bulletin_builderacb_orm/
│
├── src/
│ └── acb_orm/
│ ├── collections/ # MongoEngine models for each collection
│ ├── schemas/ # Pydantic schemas for validation
│ ├── auxiliaries/ # Embedded documents and utilities
│ ├── enums/ # Enumerations for states and types
│ ├── validations/ # Custom validations
│
├── tests/ # Unit and integration tests
├── pyproject.toml # Package configuration
└── README.md # Main documentationRun all tests with:
PYTHONPATH=src pytest tests/The database is organized into the following collections, each with its specific purpose and structure:
Main template repository, grouping all versions and metadata.
_id: ObjectIdtemplate_name: stringdescription: stringlog: audit object (created_at, creator_user_id, updated_at, updater_user_id)status: string (e.g., "active", "archived")current_version_id: reference totemplates_versionsaccess_config: access control object (access_type,allowed_groups)
Stores each individual version of a template as an immutable snapshot.
_id: ObjectIdtemplate_master_id: reference totemplates_masterversion_num: string or numberprevious_version_id: reference to previous version or nulllog: audit objectcommit_message: stringcontent: template structure and design
Bulletin index, contains metadata and reference to the latest version.
_id: ObjectIdbulletin_name: stringbase_template_master_id: reference totemplates_masterbase_template_version_id: reference totemplates_versionscurrent_version_id: reference tobulletins_versionsstatus: string (e.g., "draft", "published")log: audit object
Stores each complete and immutable version of a bulletin.
_id: ObjectIdbulletin_master_id: reference tobulletins_masterversion_num: number or stringprevious_version_id: reference to previous version or nulllog: audit objectdata: complete bulletin structure with filled fields
Record of each bulletin review cycle.
_id: ObjectIdbulletin_master_id: reference tobulletins_masterreviewer_user_id: reference touserslog: audit objectcompleted_at: completion datecomments: array of comments and nested replies
Metadata catalog for visual files.
_id: ObjectIdfile_url: stringfile_name: stringfile_type: stringtags: array of stringslog: audit object
Reusable content library for bulletins.
_id: ObjectIdcard_name: stringcard_type: stringtemplates_master_ids: array of references totemplates_masteraccess_config: access control objectcontent: flexible card structure
User information and access control.
_id: ObjectIdext_id: string (external ID, e.g., keycloak)is_active: booleanlog: audit object
Defines platform roles and permissions.
_id: ObjectIdrole_name: stringdescription: stringpermissions: CRUD object per modulelog: audit object
Organizes users by affiliation and country.
_id: ObjectIdgroup_name: stringcountry: stringdescription: stringusers_access: array of objects{user_id, role_id}log: audit object