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.1.tar.gz (17.5 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.1-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kayframework-0.1.1.tar.gz
  • Upload date:
  • Size: 17.5 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.1.tar.gz
Algorithm Hash digest
SHA256 c4de690aaf802ec79ae779ae03daed6960973502a8e8c28f3a8830f45b8bd969
MD5 2106e2000087f98eace927461e66d4e1
BLAKE2b-256 1a96042cafe237e4eebc8f889cf4fe7d52d86063d6fb32051619e2d6002e9bb5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kayframework-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 579359dfc77e71dcad4337caabfc184087ca9ac4885b4052a5088129b64f96ff
MD5 be7ba424c5974a761dec81d5c0f1228d
BLAKE2b-256 1cfab5ce6684eded7ac3cb9d34c55a60b726c5e0f499ad3f8756bc017ea0f946

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