Skip to content

fseasy/docgate

Repository files navigation

Docgate

English | 中文

Docgate is a gated-content stack for products like dajuan.fseasy.top. It lets you keep your site and docs mostly static while adding sign-in, email verification, prepaid-code redemption, and Stripe-based paid access.

It is built for a simple model: Nginx stays at the edge, static content stays static, and a small React + FastAPI layer handles auth, purchase, and permission sync.

Product

What It Solves

  • Protect static docs or course pages behind authentication.
  • Support both prepaid-code activation and self-serve Stripe checkout.
  • Keep public pages, app pages, and protected docs loosely coupled.
  • Stay deployable on a small Linux VPS without Docker.

Current Product

This repository powers the gated content flow for:

  • https://dajuan.fseasy.top

Main User Flows

Prepaid code flow
Admin -> generate code -> user signs in -> user redeems code -> backend marks user paid -> docs become available

Stripe flow
User -> open purchase page -> create checkout session -> Stripe webhook updates DB -> after-pay sync updates roles -> docs become available

Technology

Modules

  • confgen/: unified config generator for frontend env, backend env, and Nginx config.
  • frontend/: React SPA for auth UI, dashboard, purchase flow, and admin tools.
  • backend/: FastAPI service for user state, prepaid codes, Stripe, and internal auth checks.
  • deploy/: Linux deployment scripts for non-Docker installs.

Request Flow

Browser
  |
  v
Nginx
  |-- /app/... ------------------> React SPA
  |-- /api/... ------------------> FastAPI backend
  |-- /docs/... -> auth_request -> FastAPI internal auth check
  |                                 |-- verify local JWT
  |                                 |-- check email verification
  |                                 `-- check paid role
  `-- / --------------------------> public static site

Key Technical Points

  • Fast docs auth path: protected docs use local JWT verification instead of calling SuperTokens core on every request.
  • Nginx auth_request is the gatekeeper, so protected docs can stay static.
  • Nginx auth caching reduces repeated backend auth work.
  • confgen keeps frontend, backend, and Nginx config aligned.
  • The stack is tuned for low-resource VPS deployment.

Module Docs

Local Development

For day-to-day development, the main entry is:

./run_dev_all.sh

That script starts:

  • the frontend dev server
  • the backend dev server

Before that, you still need environment files generated by confgen and a working local Nginx setup if you want to test the full gated-doc flow.

Deployment

On Linux, the intended deployment path is simple: prepare the machine once, then deploy/update with the second script.

cd deploy && \
./env_init.sh && \
./project_init_and_update.sh --mode deving/serving

See deploy/README.md for the details.

About

An almost out-of-box auth wrapper for static content. See the example website.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors