What You Will Build
A production-ready Flask codebase for a B2B SaaS, generated from a paragraph. The generated app includes:
- SQLAlchemy models with Alembic migrations
- Flask blueprints, one per resource
- JWT authentication via Flask-JWT-Extended, tokens in httpOnly cookies
- Organisation-scoped multi-tenancy on every query
- A working
docker-compose.yml
Flask is the right pick when you want a small, explicit microframework you fully control — no batteries you did not ask for.
Prerequisites
- An Archiet account (free at archiet.com/register)
- Docker installed locally
- 10 minutes
Step 1: Write a Minimal PRD
Inventory is a B2B SaaS for warehouses. Organisations sign up and invite staff.
Staff manage products with a SKU, name, quantity, and reorder threshold, and
record stock movements (in / out) against products. Only staff in an
organisation see that organisation's products. We need registration, login,
email verification, and password reset.
Archiet extracts Organisation, User, Product, and StockMovement, plus the auth flow.
Step 2: Open the Blueprint Wizard
Log in at archiet.com/login, click New Blueprint, paste the PRD, click Analyse, and review the model.
Step 3: Choose Flask
On the Generate screen, select Flask, optionally add a compliance overlay, and click Generate.
Step 4: What You Get
inventory/
├── app/
│ ├── __init__.py # app factory, blueprint registration
│ ├── models/
│ │ ├── organisation.py
│ │ ├── user.py
│ │ ├── product.py
│ │ └── stock_movement.py
│ ├── blueprints/
│ │ ├── auth_bp.py
│ │ ├── products_bp.py
│ │ └── stock_bp.py
│ └── extensions.py # db, jwt, migrate
├── migrations/ # Alembic
├── docker-compose.yml
└── wsgi.py
The blueprint route is explicit and tenant-scoped:
# app/blueprints/products_bp.py
from flask import Blueprint, jsonify
from flask_jwt_extended import jwt_required, get_jwt_identity
from app.models.product import Product
products_bp = Blueprint("products", __name__)
@products_bp.route("/products", methods=["GET"])
@jwt_required()
def list_products():
org_id = get_jwt_identity()["org_id"]
products = Product.query.filter_by(org_id=org_id).all()
return jsonify([p.to_dict() for p in products])
filter_by(org_id=org_id) on every query — tenant isolation enforced at the data layer. @jwt_required() guards every protected route, and the JWT lives in an httpOnly cookie.
Step 5: Run It Locally
cd inventory
cp .env.example .env
docker compose up -d
docker compose exec web flask db upgrade
The API is at http://localhost:5000/api/. Register, verify your email (Mailtrap catches it locally), log in, and the cookie-based JWT keeps you authenticated.
What to Do Next
Keep it small: Flask's appeal is that you see every moving part. Add only the extensions you need.
Extend with your AI editor: the generated ARCHITECTURE.md gives Cursor or Copilot the full picture of your blueprints and models.
Other Python stacks: Django if you want an admin and DRF out of the box; FastAPI if you want async and automatic OpenAPI docs.
The DELIVERY_RECEIPT.md lists every generated file and its quality score.