Skip to main content

A blog engine core with JSON storage

Project description

Masterblog‑core 📦

PyPI version PyPI - Downloads Python Code style: PEP8 Status License: MIT


📑 Table of Contents


⚠️ Disclaimer

This project began as part of my learning journey during a multi‑month software engineering course.

The original Masterblog repository included a Flask server and frontend. This fork, Masterblog‑core, strips away the web layer and focuses only on the reusable backend logic. The emphasis has shifted toward packaging and redistribution as a standalone Python library.

  • No new features have been added — in fact, the frontend has been removed.
  • The goal is to ensure the underlying models and storage still work as expected.
  • It remains a learning project and is not intended for production use.

📝 Description

Masterblog‑core provides the essential building blocks of a simple blogging system:

  • Blog and Post classes for managing posts.
  • JSON‑based persistence with auto‑incrementing IDs.
  • A lightweight storage layer (filestore, sequence).

This package is designed for reuse in other projects or as a learning reference for object‑oriented design and Python packaging.


✨ Features

  • ➕ Create new blog posts
  • ✏️ Update existing posts
  • ❌ Delete posts
  • ❤️ Like posts (with persistence)
  • 📦 JSON storage with auto‑increment IDs
  • 🔌 File‑path injection for flexible persistence

📁 Project Structure

.
├── .gitignore           # Ignore sensitive/generated files
├── LICENSE              # MIT license text
├── pyproject.toml       # Project metadata and dependencies
├── README.md            # Project documentation
└── src/                 # Main application source code
    └── masterblog_core
        ├── __init__.py  # Public API (Blog, Post, storage) 
        ├── models/      # Data models
        │   ├── blog.py  # Blog class managing posts
        │   └── post.py  # Post class with attributes and methods
        └── storage/     # Persistence layer
            ├── filestore.py  # JSON read/write helpers
            └── sequence.py   # Auto-increment ID handling

📦 Installation

From PyPI:

pip install masterblog-core

For local development:

git clone https://github.com/paul-wosch/Masterblog-core.git
cd Masterblog-core
pip install -e .

Requirements

  • Python 3.10 or newer
  • No external dependencies beyond the Python standard library

⚡ Quick Start

pip install masterblog-core
from masterblog_core import Blog

blog = Blog("blog.json", "sequence.json")
blog.add({"author": "Me", "title": "Hello", "content": "First post!"})

🚀 Usage

After installation, you can import and use the package in Python:

from pathlib import Path
from masterblog_core import Blog, Post

# Define file paths for persistence
PROJECT_ROOT = Path(__file__).resolve().parent
BLOG_FILE_PATH = (PROJECT_ROOT / "blog.json").resolve()
SEQUENCE_FILE_PATH = (PROJECT_ROOT / "sequence.json").resolve()

# Initialize Blog with file paths
my_blog = Blog(BLOG_FILE_PATH, SEQUENCE_FILE_PATH)

# Example usage
my_post = {
    "author": "Your Name",
    "title": "Hello World",
    "content": "This is my first post!",
    "likes": 0
}
my_blog.add(my_post)

🔖 Versioning

The package version is defined once in pyproject.toml and exposed at runtime via
masterblog_core.__version__. This is automatically synchronized using importlib.metadata, so you only need to update the version in one place.

You can check the installed version programmatically:

import masterblog_core
print(masterblog_core.__version__)

How it works

Inside masterblog_core/__init__.py, the version is resolved from the installed package metadata:

from importlib.metadata import version, PackageNotFoundError

try:
    __version__ = version("masterblog-core")
except PackageNotFoundError:
    # Fallback for local development when package metadata is not available
    __version__ = "0.0.0"

This ensures consistency between the distribution metadata and the runtime API.


👥 Contributing

This project is primarily a learning exercise, but contributions, suggestions, or feedback are welcome. If you’d like to propose improvements:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m "feat: Add your feature")
  4. Push to the branch (git push origin feature/your-feature)
  5. Open a Pull Request

🏷️ Badges

  • PyPI version – latest release on PyPI
  • Downloads – monthly installs from PyPI (click for details on pepy.tech)
  • Python – minimum supported Python version
  • Code style – follows PEP8 guidelines
  • Status – indicates this is a learning project
  • License – MIT license

🔗 See Also

This package was extracted from the original Masterblog project, which includes a Flask server and frontend.

  • Use Masterblog‑core if you want the reusable backend logic as a library.
  • Use Masterblog if you want the full web application with UI.

📄 License

This project is licensed under the terms of the MIT License.
See the LICENSE file for full details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masterblog_core-0.1.1.post1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masterblog_core-0.1.1.post1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file masterblog_core-0.1.1.post1.tar.gz.

File metadata

  • Download URL: masterblog_core-0.1.1.post1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for masterblog_core-0.1.1.post1.tar.gz
Algorithm Hash digest
SHA256 92136f141870d666369ff45b44b081ef37145ea65fd59f19864f4e3466161114
MD5 cb89e22c78061e6e96ca8f6277e8ec9c
BLAKE2b-256 f767499fa9c4ad2fb402ada8c904413ebd226219c192b66471303d0d77374c78

See more details on using hashes here.

File details

Details for the file masterblog_core-0.1.1.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for masterblog_core-0.1.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 c61d548c254e3e25cdf5d7b900fdeecde24ae37f8aa59013c73eaabaa8511386
MD5 c271cb97eecae951b3075e31b0244eed
BLAKE2b-256 f660bb72fbbf46a4420da61545e4f6db9617dd2686d27fc72b756388230b8ced

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page