A zero-knowledge session authentication project with a Next.js frontend and FastAPI backend, deployable as a monorepo to Vercel.
auth-project/
├── api/ # Vercel Python Serverless Function
│ ├── index.py # FastAPI entry point (Mangum-wrapped)
│ └── requirements.txt # Python dependencies for the function
├── app/ # FastAPI application package (shared)
│ ├── config.py
│ ├── db.py
│ ├── schemas.py
│ ├── routes/
│ ├── services/
│ └── crypto/
├── frontend/ # Next.js application
│ ├── app/
│ ├── components/
│ ├── lib/
│ ├── services/
│ └── ...
├── vercel.json # Monorepo deploy config
└── requirements.txt # Local dev Python deps (with uvicorn)
- Push this repository to GitHub / GitLab / Bitbucket.
- Go to vercel.com/new and import the repository.
- Leave the Root Directory as
/(the repo root) —vercel.jsonhandles everything. - Add the environment variable
COOKIE_SECURE=truein Vercel project settings. - Click Deploy.
Set these in your Vercel project → Settings → Environment Variables:
| Variable | Default | Description |
|---|---|---|
AUTH_MODE |
dev_bypass |
Set to zk in production to enable real ZK proof verification |
COOKIE_SECURE |
false |
Set to true in production (HTTPS cookies) |
COOKIE_SAMESITE |
lax |
Cookie SameSite policy |
SESSION_TTL_SECONDS |
900 |
Session timeout (15 min) |
CHALLENGE_TTL_SECONDS |
60 |
Challenge expiry |
REDIS_URL |
(DummyRedis in-memory) | Optional: add a Redis URL (e.g., Upstash) for persistent sessions |
Note: Without a
REDIS_URL, the backend uses an in-memory store. Sessions are lost on every cold start. For production, add an Upstash Redis URL.
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txt
uvicorn app.main:app --reloadcd frontend
cp .env.example .env.local # set NEXT_PUBLIC_BACKEND_URL=http://127.0.0.1:8000
npm install
npm run devBrowser
└─► GET/POST /api/backend/* ──► Vercel routes ──► api/index.py (Python Serverless)
└─► GET /* ──► Vercel routes ──► frontend/ (Next.js)
The vercel.json at the repo root configures two build targets:
@vercel/nextbuilds the Next.js app fromfrontend/@vercel/pythonbuilds the FastAPI function fromapi/index.py