Skip to main content

Minimal FastAPI auth framework skeleton

Project description

KAYFRAMEWORK — Minimal FastAPI Framework

KAYFRAMEWORK is a minimal framework built on FastAPI. It provides a tiny core, a module system, and a CLI to scaffold modules. Everything else is intentionally left to the user.


1) Goal

  • Minimal framework with a module system
  • Small, readable core
  • Users decide which features to add

2) Project Structure

app/
  api/              # Router and error handlers
  auth/             # Auth module (routes, schema, service, models)
  core/             # Config, security, dependencies
  db/               # DB session and base
  modules/          # Optional modules (loaded via MODULES)
  templates/        # Jinja2 templates
  utils/            # Helpers
  main.py           # App entry

kayframework/
  cli.py            # CLI entry

.env.example        # Environment sample
pyproject.toml      # Project + lint/format/type config

3) Setup

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

4) Environment (.env)

Use .env.example as a base to create .env.

Important vars

  • SECRET_KEY: Must be long and random
  • ENV: local or prod
  • COOKIE_SECURE: false for local, true for production
  • DATABASE_URL: SQLite or Postgres
  • MODULES: comma-separated module list (example: blog,admin)

Example

SECRET_KEY=CHANGE_ME_USE_A_LONG_RANDOM_VALUE
ENV=local
LOG_LEVEL=INFO
DATABASE_URL=sqlite:///users.db
COOKIE_SECURE=false
MODULES=

5) Run

uvicorn app.main:app --reload
  • Home: GET /
  • Swagger: GET /docs

6) Module System

Modules live under app/modules/<name>/ and must expose router in routes.py.

Enable modules via .env:

MODULES=blog,admin

Routes will be mounted at:

/modules/blog
/modules/admin

7) CLI

Create a module scaffold:

kay new module blog

This generates:

app/modules/blog/
  __init__.py
  routes.py
  schema.py
  service.py
  models.py

Create a new project:

kay new app myproject

Run the app:

kay run

Run tests:

kay test

Lint:

kay lint

Format:

kay format

Type check:

kay typecheck

Version:

kay version

Build:

kay build

Clean:

kay clean

Init:

kay init

Doctor:

kay doctor

Help:

kay help

8) Tests

pytest

Current tests:

  • Register + Login + Me flow

9) Lint / Format / Type

ruff check .
black --check .
mypy app

10) CI (GitHub Actions)

.github/workflows/ci.yml runs:

  • ruff (lint)
  • black --check (format)
  • mypy (type)
  • pytest (tests)

11) Install (Package)

Local editable install:

pip install -e .

With dev tools:

pip install -e ".[dev]"

12) Security Notes

  • Replace SECRET_KEY before any real deployment.
  • For ENV=prod, COOKIE_SECURE=true should be used.
  • HTTPS is expected for production.

13) License

See LICENSE.

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

kayframework-0.1.2.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

kayframework-0.1.2-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file kayframework-0.1.2.tar.gz.

File metadata

  • Download URL: kayframework-0.1.2.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kayframework-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3bea4a316ef59b5fc1cc5e38401c9ca5d3049d7c6657cb89799ac4e74f755224
MD5 a72f6bcc52b459abf6cb7e53c05e9cf2
BLAKE2b-256 1861137b3b227b46fb9952bf7e74a5f769d2d312d2355342ba0e8203e480fd39

See more details on using hashes here.

File details

Details for the file kayframework-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kayframework-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kayframework-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 73d0cdfe2cb315762d91c513504fd1a653f95bc1ccebc8f99d62bfdaff7619f7
MD5 195827fb8c28b246ce0721b150fdcb38
BLAKE2b-256 9aca2572d81cb93f08f7181683a99f3c802f2d77244308c695f94c9e9c5e7389

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