Skip to main content

A minimalist JSON-based database for MVPs

Project description

JASON.py 🦲 - Minimalist Json-based Database for MVPs

Because sometimes your database needs to punch data in the face.

Meet JASON - the JSON database that's as straightforward as its namesake, Jason Statham. No fancy schemas, no complicated relationships, just pure, bald-faced data storage that gets the job done.

Like the man himself, JASON is:

  • Fast and furious with your data
  • Doesn't waste time with unnecessary complexity
  • A safe transporter of your information (though maybe not in a fancy European car)
  • Completely bald-proof (we mean fault-proof)
  • Ready to kick NoSQL in the face

If your application needs a database solution that's as direct as a Statham one-liner and hits as hard as his right hook, JASON is your guy. No fancy suits, no complicated dance moves - just raw, actionable data handling with two methods - load and save!

A minimalist, no-brainer, simple JSON-based database solution for your MVP chatbots and apps that need NoSQL. Perfect for early-stage projects where simplicity and speed matter more than scalability. Jason is a simple json-based db solution for MVP chatbots and projects with up to 1k users and 100 concurrent users at a time. This project is early stage, so bear in mind there might be some bugs and it might not work properly.


Vision

To provide a lightweight, easy-to-use database solution for MVP chatbots, allowing developers to focus on building their bot logic without worrying about database setup or maintenance when you don't really have too many users to care about scalability.


Conditions for Usage

When to Use This Solution

  1. MVP Stage:

    • Perfect for early-stage chatbots where you need a quick, lightweight database solution.
    • Ideal for prototyping and testing ideas without the overhead of a full database.
  2. Small to Medium User Base:

    • Works well for chatbots with up to 1,000 active users.
    • Handles up to 100 concurrent read/write operations per second comfortably.
  3. Simple Data Structure:

    • Best for chatbots where each user’s data can be represented as a flat or moderately nested JSON structure.
    • Not suitable for complex relationships or queries (e.g., JOINs, transactions).
  4. Low to Moderate Write Frequency:

    • Suitable for chatbots where user data is updated occasionally (e.g., during interactions).
    • Not ideal for high-frequency writes (e.g., logging every message).
  5. Single-Instance Deployment:

    • Designed for single-instance deployments (e.g., one server running the bot).
    • Not suitable for distributed systems or multi-instance deployments.

When to Switch to a More Serious Solution

  1. Large User Base:

    • If your chatbot grows beyond 1,000 active users, consider switching to a database like SQLite, PostgreSQL, or MongoDB.
  2. High Write Frequency:

    • If you need to write data frequently, switch to a database optimized for high write throughput.
  3. Complex Queries:

    • If you need advanced querying (e.g., filtering, sorting, aggregations), use a database with query support.
  4. Distributed Systems:

    • If your chatbot runs on multiple instances (e.g., for scalability), switch to a distributed database like Redis or Cassandra.
  5. Data Integrity Requirements:

    • If you need transactions, atomicity, or data consistency guarantees, use a database like PostgreSQL.

Features

  • Simple: Each user’s data is stored in a separate JSON file.
  • Async I/O: Uses aiofiles for non-blocking file operations.
  • One Schema To Rule Them All: Define a single default JSON structure for all users.
  • Atomic Writes: Each user’s data is stored in a separate file, ensuring atomic writes.
  • Per-User Locking: Ensures safe concurrent access using asyncio.Lock
  • orjson Serialization: Faster than standard JSON with optional pretty-printing
  • Memory Safety: Always returns copies of data to prevent accidental cache modification
  • Cache Coherency: Automatic cache clearing if final save fails

Installation

Option one: Install via pip:

pip install jason-db

Option two: Download the jason.py file and include it in your project.


Quickstart

  1. Initialize the Database:

    from jason_db import JASON
    
    # Define the default structure for your JSON files
    DEFAULT_STRUCTURE = {
        'challenges': {},
        'active_challenge': None,
        'challenge_balance': 0
    }
    
    # Initialize the DB
    db = JASON(db_folder='/path/to/db/folder', default_structure=DEFAULT_STRUCTURE)
    
  2. Load User Data:

    user_id = "12345"
    user_data = await db.load_user_data(user_id)
    print(user_data)  # Outputs the user's data or the default structure
    
  3. Save User Data:

    user_id = "12345"
    user_data = await db.load_user_data(user_id)
    user_data['challenge_balance'] += 1  # Modify data
    await db.save_user_data(user_id, user_data)
    

Use Cases

  1. Telegram Bots:

    • Store user preferences, conversation state, or game progress.
    • Example: A chatbot that tracks user challenges and balances.
  2. Prototyping:

    • Quickly test ideas without setting up a full database.
    • Example: A proof-of-concept chatbot for a startup pitch.
  3. Small-Scale Projects:

    • Ideal for personal projects or small teams with limited resources.
    • Example: A hobby project to learn chatbot development.

Limitations

  • Not for Large-Scale Systems: Use for up to 1,000 active users, maybe 10,000 in some cases tops.
  • No Advanced Queries: Only supports basic read/write operations.
  • Single-Instance Only: Not suitable for distributed deployments.

When to Upgrade

If your chatbot grows beyond 1,000-10,000 users or requires advanced features like transactions, consider switching to:

  • SQLite for a lightweight SQL database.
  • PostgreSQL for a robust relational database.
  • MongoDB for a NoSQL database with flexible schemas.

Contributing

Feel free to open issues or submit pull requests! This project is open-source and welcomes contributions.


License

MIT License. Use it freely for personal and commercial projects.

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

jason-db-0.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

jason_db-0.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file jason-db-0.2.0.tar.gz.

File metadata

  • Download URL: jason-db-0.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for jason-db-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a2619a813f415fdc154e074f0f137cf6592ece82c47a011e76f24cf9fd302969
MD5 e9259531b36aa266d27d44e0f92e451f
BLAKE2b-256 3eaf703a23cd2b3a9bbeaf8433cdafb84466a775ea7c98b699443d8298a62a0a

See more details on using hashes here.

File details

Details for the file jason_db-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: jason_db-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for jason_db-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4130abecf9891ba3c7705c3b46e977053fdea103b3f339ce7d5328046d5ba73d
MD5 283742b15bd6244006d595391189d893
BLAKE2b-256 b0830b4a4e5a316ae83f9b3a165e2b31f91702117e87d732560f4d6adbc88d52

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