Shared database (PostgreSQL) and cache (Redis) primitives for the FORKTEX ecosystem
Project description
forktex-core
Shared PostgreSQL and Redis primitives for the ForkTex ecosystem.
forktex-core is the foundation library every ForkTex Python service depends on. It owns the async SQLAlchemy engine, session helpers, ORM mixins, and Redis caching primitives, so individual services don't reinvent connection management.
What This Repo Ships
This repo ships exactly one package: forktex-core on PyPI.
It is consumed as a runtime dependency by:
forktex-cloud-api(cloud platform server) —from forktex_core.psql.connection import init_engine, get_sessionforktex-intelligence-api(intelligence platform server) — same- any future ForkTex Python service that needs PostgreSQL or Redis
Install
pip install forktex-core
PostgreSQL (asyncpg + SQLAlchemy 2) and Redis (hiredis) are both included by default — there are no optional extras you need to remember.
Quick Start
PostgreSQL
from forktex_core.psql import (
init_engine, close_engine, get_session,
BaseDBModel, TimestampMixin, AuditMixin,
)
# Initialize once in your app's lifespan
init_engine("postgresql+asyncpg://user:pass@localhost/db")
# Use a session anywhere
async with get_session() as session:
user = await session.get(User, user_id)
Tunable engine kwargs are passed straight through to create_async_engine:
init_engine(
"postgresql+asyncpg://user:pass@host/db",
pool_size=20,
max_overflow=10,
pool_pre_ping=True,
)
Redis
from forktex_core.redis import init, close, cached
await init("redis://localhost:6379/0")
@cached(ttl=300)
async def get_profile(user_id: str):
...
Operate
The root Makefile is generated by forktex fsd makefile sync. Do not hand-edit it.
make help # list every available target
make deps # pip install -e .
make format # ruff format
make lint # ruff check
make test # pytest tests/
make build # python3 -m build → dist/
make publish # twine upload dist/*
make clean # remove caches and dist/
make ci # format-check + lint + test
make start / make stop / make logs are intentional no-ops — forktex-core is a library, there's nothing to run.
FSD Self-Description
This repo follows the ForkTex Standard Delivery (FSD) shape:
- root manifest:
forktex.json - manifest schema version:
manifestVersion = 1.0.0 - FSD contract version:
fsd.version = 1.0.0 - profile:
workspace/python-monorepo - target maturity:
L3 - single publishable package:
forktex-coreat path.
Re-validate locally with:
forktex fsd --project-dir . check
forktex arch discover --project-dir . --output-dir /tmp/arch-corepy
Repository Layout
core-py/
├── forktex.json
├── Makefile
├── pyproject.toml
├── README.md
└── src/forktex_core/
├── psql/ # async SQLAlchemy engine, sessions, ORM mixins
└── redis/ # connection, namespaces, ops, decorators
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forktex_core-0.1.1.tar.gz.
File metadata
- Download URL: forktex_core-0.1.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ef3b33ba37c83e5536d0f1c4767d559d2771edf42b8c3d564d56b1a75cafde
|
|
| MD5 |
3b3e0698889916902a09df6abc69f01f
|
|
| BLAKE2b-256 |
18980f0deea5ce849d373a2adb7782a4c876f44c99594a29e381148a4c74cdc3
|
File details
Details for the file forktex_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: forktex_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95c478de7b0c5601d0a6a09fbf1e47f0f5adb13392bf1e03087f8637dfd51e6c
|
|
| MD5 |
90dc84f7bff114f4e2243639d1955f8c
|
|
| BLAKE2b-256 |
54a00400d1f672c9afeadb4b30cb5d9e7eb74c76cc156700dfd319df540fdfee
|