Skip to main content

Welcome to Pokie

Tests pypi license

Pokie is an REST web framework built on top of Flask, Rick and Rick-db libraries, following three-layer and clean architecture design principles.

It features an object-oriented design, borrowing from common patterns found in other languages, such as dependency injection, service location, factories and object composition. It also offers the following functionality:

  • Modular design;
  • Dependency registry and factories;
  • Configuration via environment variables or JSON files;
  • CLI command support;
  • Events and signal handlers;
  • Caching (Redis, in-memory, dummy);
  • Jobs with per-job intervals, retry/backoff, and timeouts;
  • CORS and rate limiting via built-in factories;
  • OpenAPI 3.0 spec generation from registered routes;
  • Fixtures;
  • Unit testing support with pytest;
  • Code generation;
  • Automatic REST endpoint generation;
  • REST-oriented service design;
  • Compatibility with Flask;
  • Forward-only SQL migrations;
  • PostgreSQL support;

For detailed information, please check the Documentation

Automatic REST from Database Tables

Generate full CRUD endpoints directly from a database table — no DTO, no RequestRecord, no service class needed:

from pokie.core import BaseModule
from pokie.http import AutoRouter
from pokie.rest.auto import Auto


class Module(BaseModule):
    name = "my_module"

    def build(self, parent=None):
        app = parent.app

        # generate a full REST view from the "customers" table
        view = Auto.view(app, "customers")
        AutoRouter.resource(app, "customer", view, id_type="string")

This introspects the customers table at startup and registers:

URL Method Operation
/customer GET List records
/customer/<string:id_record> GET Get by id
/customer POST Create
/customer/<string:id_record> PUT, PATCH Update
/customer/<string:id_record> DELETE Delete

Listing supports server-side pagination, sorting, filtering and free-text search out of the box via query parameters (offset, limit, sort, match, search).

Automatic REST from DTO Records

For more control, use Auto.rest() with a DTO Record — Pokie generates the RequestRecord and service automatically:

from rick_db import fieldmapper
from pokie.core import BaseModule
from pokie.rest.auto import Auto


@fieldmapper(tablename="customers", pk="customer_id")
class CustomerRecord:
    id = "customer_id"
    company_name = "company_name"
    contact_name = "contact_name"


class Module(BaseModule):
    name = "my_module"

    def build(self, parent=None):
        Auto.rest(
            parent.app,
            "customer",
            CustomerRecord,
            search_fields=[CustomerRecord.company_name, CustomerRecord.contact_name],
            id_type="string",
        )

Both approaches can be incrementally customized — add a custom RequestRecord for input validation, a custom service for business logic, or a custom base class for authentication.

Getting Started

  1. Create the application entrypoint, called main.py:
from rick.resource.config import EnvironmentConfig
from pokie.config import PokieConfig
from pokie.core import FlaskApplication
from pokie.core.factories.pgsql import PgSqlFactory


class Config(EnvironmentConfig, PokieConfig):
    pass


def build_pokie():
    cfg = Config().build()

    modules = [
        # add your modules here
    ]

    factories = [
        PgSqlFactory,
    ]

    pokie_app = FlaskApplication(cfg)
    flask_app = pokie_app.build(modules, factories)
    return pokie_app, flask_app


main, app = build_pokie()

if __name__ == '__main__':
    main.cli()
  1. Scaffold a module:
$ python3 main.py codegen:module my_module_name .
  1. Add the module to the module list on main.py:
    modules = [
        'my_module_name',
    ]
  1. Implement the desired logic in the module

Running tests with tox

  1. Install tox & tox-docker:
$ pip install -r requirements-test.txt
  1. Run tests:
$ tox [-e py<XX>]

Download files

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

Source Distribution

pokie-1.2.0.tar.gz (80.4 kB view details)

Uploaded Source

Built Distribution

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

pokie-1.2.0-py3-none-any.whl (120.4 kB view details)

Uploaded Python 3

File details

Details for the file pokie-1.2.0.tar.gz.

File metadata

  • Download URL: pokie-1.2.0.tar.gz
  • Upload date:
  • Size: 80.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pokie-1.2.0.tar.gz
Algorithm Hash digest
SHA256 c7c6eb93ffc9a90422423313962a385d825ac98af056fbac1f4c2cd330dd4809
MD5 a1146df3e2ec3c2393d710ea4cd92891
BLAKE2b-256 d230d669424f3abc2624d0de66b5fcf52a50e87742785217743baf532e37c60d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pokie-1.2.0.tar.gz:

Publisher: publish.yml on oddbit-project/pokie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pokie-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pokie-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 120.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pokie-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef47ea3fc89c50b9f9319c817edb5120969c610427fb94e570dbdb1aaa833606
MD5 b51b5b34b4470dc815fdd814c891edad
BLAKE2b-256 19a62f41edac9e78f4ef7d9e3746533595d9511e002a453c5e809d82111b62a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pokie-1.2.0-py3-none-any.whl:

Publisher: publish.yml on oddbit-project/pokie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

1 file

0.9.7

1 file

0.9.6

1 file

0.9.5

1 file

0.9.4

1 file

0.9.3

1 file

0.9.2

1 file

0.9.1

1 file

0.9.0

1 file

0.8.0

1 file

0.5.2

1 file

0.5.1

1 file

0.5.0

1 file

0.4.5

1 file

0.4.4

1 file

0.4.3

1 file

0.4.2

1 file

0.4.1

1 file

0.3.5

1 file

0.3.0

1 file

0.2.2

1 file

0.2.0

1 file

0.1.3

1 file

0.1.2

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page