Skip to content

Add Flask SaaS website with GitHub login and OTP - #7

Merged
OMCHOKSI108 merged 1 commit into
mainfrom
feature/flask-saas-website
Jun 22, 2026
Merged

Add Flask SaaS website with GitHub login and OTP#7
OMCHOKSI108 merged 1 commit into
mainfrom
feature/flask-saas-website

Conversation

@OMCHOKSI108

@OMCHOKSI108 OMCHOKSI108 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds Flask SaaS website and landing page
  • Adds GitHub OAuth login foundation
  • Adds email OTP verification using Resend
  • Adds MongoDB user and OTP storage foundation
  • Adds usage dashboard for 30 PR/month free plan
  • Adds GitHub App install CTA
  • Adds Render website deployment files

Verification

  • python -m compileall website ✓
  • python -c "from website.app import app; print(app.name)" ✓
  • python scripts/evaluate_reviewer.py (12/12 pass) ✓
  • python scripts/review_code.py (works) ✓
  • Flask endpoints all respond correctly ✓

Notes

  • GitHub App webhook usage enforcement is next
  • 4-minute guide email is designed but not scheduled yet
  • Streamlit dashboard remains available

Summary by CodeRabbit

  • New Features

    • Launched public website and SaaS portal with GitHub OAuth authentication and email verification via OTP.
    • Added user dashboard displaying monthly PR review usage, remaining quota, and recent review history.
    • Implemented free plan limiting users to a monthly PR review quota with contact option to request additional reviews.
    • Added portal pages: landing page, login, email verification, dashboard, reviews feed, usage tracking, settings, and contact.
  • Documentation

    • Updated README with completed roadmap items and website portal documentation.
    • Added comprehensive website service documentation.
  • Chores

    • Added Render deployment configuration and containerized service setup.

Copilot AI review requested due to automatic review settings June 22, 2026 09:32
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: cfd2e6fc-4b3b-4469-aea4-bcc94cc4e2f1

📥 Commits

Reviewing files that changed from the base of the PR and between eee3ae5 and 6b4d51a.

📒 Files selected for processing (31)
  • Dockerfile
  • README.md
  • deploy/render/website.Dockerfile
  • deploy/render/website_start.sh
  • docs/website.md
  • pyproject.toml
  • render.yaml
  • render_entrypoint.sh
  • website/__init__.py
  • website/api_client.py
  • website/app.py
  • website/auth.py
  • website/config.py
  • website/db.py
  • website/email_service.py
  • website/github_app.py
  • website/otp.py
  • website/static/css/styles.css
  • website/static/js/app.js
  • website/templates/base.html
  • website/templates/contact.html
  • website/templates/dashboard.html
  • website/templates/error.html
  • website/templates/index.html
  • website/templates/login.html
  • website/templates/repos.html
  • website/templates/reviews.html
  • website/templates/settings.html
  • website/templates/usage.html
  • website/templates/verify_email.html
  • website/usage.py

📝 Walkthrough

Walkthrough

Adds a complete Flask-based SaaS portal (website/ package) with GitHub OAuth login, email OTP verification via Resend, MongoDB persistence with an in-memory fallback, per-user monthly PR review quota tracking, a CodeSec API client, Jinja2 page templates, and site CSS. Wires the service into existing Render deployment infrastructure via a new render.yaml, dedicated Dockerfile, startup script, and updated pyproject.toml. Updates README and adds docs/website.md.

Changes

Flask SaaS Portal

Layer / File(s) Summary
Packaging and deployment wiring
pyproject.toml, Dockerfile, deploy/render/website.Dockerfile, deploy/render/website_start.sh, render_entrypoint.sh, render.yaml
Adds the website extra to pyproject.toml and Hatch build includes, extends the main Dockerfile to copy website assets and install gunicorn, adds a dedicated website Dockerfile and gunicorn startup script, adds a website branch in render_entrypoint.sh, and defines all four Render services (codesec-api, codesec-dashboard, codesec-review-ui, codesec-website) with their environment variables in render.yaml.
Configuration and database abstraction
website/config.py, website/db.py
Introduces Config loading all env vars at import time and MemDB (in-memory MongoDB-like fallback) plus get_mongo() which selects between real pymongo and the in-memory fallback on connection failure. Adds hash_otp (SHA-256) and utcnow helpers.
GitHub OAuth authentication flow
website/auth.py
Adds auth_bp Blueprint with /auth/github/start (state + redirect), /auth/github/callback (CSRF check, code exchange, GitHub profile/email fetch, MongoDB _upsert_user, session storage, email-verified routing), /logout, and private OAuth helper functions.
OTP verification and email service
website/otp.py, website/email_service.py, website/github_app.py
Adds OTPError, generate_otp, send_otp (cooldown enforcement, hashed record insert, Resend dispatch), and verify_otp (expiry/attempt checking, hash comparison, email_verified update). Adds _resend_request, _log_event, and four email-sending functions (send_otp_email, send_welcome_email, send_usage_guide_email, send_limit_reached_email). Adds install_url() helper for GitHub App links.
Usage computation and API client
website/usage.py, website/api_client.py
Adds get_usage and wrapper helpers (remaining_reviews, is_limit_reached, usage_percent) to compute per-user monthly quota. Adds fetch_reviews and fetch_stats HTTP GET wrappers against the CodeSec API with safe defaults on failure.
Flask app factory and routes
website/app.py
Adds create_app factory (config, blueprint registration, Jinja context injection), all route handlers (/, /login, /verify-email, POST /otp/send, POST /otp/verify, /dashboard, /reviews, /usage, /repos, /contact, /settings), 404/500 error handlers, _get_db lazy helper, and _inject_global_context processor.
Jinja templates and static assets
website/templates/*, website/static/css/styles.css, website/static/js/app.js
Adds base.html nav/footer shell and all page templates: index.html (landing with hero/features/pricing/resources), login.html, verify_email.html (OTP send/verify JS), dashboard.html (usage card, reviews table), reviews.html, usage.html, repos.html, settings.html, contact.html, error.html. Adds full site stylesheet with theme variables, responsive layout, dashboard/auth/form/table styles, and a stub app.js.
README and website documentation
README.md, docs/website.md
Updates README roadmap to mark completed SaaS items and adds portal URL, OAuth flow, OTP rules, and usage display sections. Adds docs/website.md covering all routes, env vars, MongoDB schemas, graceful degradation, and Render deployment steps.

Sequence Diagram

sequenceDiagram
  participant Browser
  participant FlaskApp as Flask (app.py)
  participant auth_bp as auth.py
  participant GitHubAPI as GitHub API
  participant otp_py as otp.py
  participant ResendAPI as Resend API
  participant MongoDB

  rect rgba(100, 150, 255, 0.5)
    note over Browser,MongoDB: GitHub OAuth Login
    Browser->>FlaskApp: GET /login
    Browser->>auth_bp: GET /auth/github/start
    auth_bp->>Browser: redirect to github.com/login/oauth/authorize
    Browser->>auth_bp: GET /auth/github/callback?code=&state=
    auth_bp->>GitHubAPI: POST /login/oauth/access_token
    GitHubAPI-->>auth_bp: access_token
    auth_bp->>GitHubAPI: GET /user + GET /user/emails
    GitHubAPI-->>auth_bp: profile + emails
    auth_bp->>MongoDB: upsert user by github_id
    auth_bp->>Browser: redirect /verify-email or /dashboard
  end

  rect rgba(100, 220, 130, 0.5)
    note over Browser,MongoDB: Email OTP Verification
    Browser->>FlaskApp: POST /otp/send
    FlaskApp->>otp_py: send_otp(user_id, email)
    otp_py->>MongoDB: cooldown check + insert hashed OTP
    otp_py->>ResendAPI: POST /emails (OTP code)
    ResendAPI-->>otp_py: response
    otp_py->>MongoDB: log email event
    Browser->>FlaskApp: POST /otp/verify (code)
    FlaskApp->>otp_py: verify_otp(user_id, otp)
    otp_py->>MongoDB: fetch unexpired OTP, validate hash
    otp_py->>MongoDB: set email_verified=True
    FlaskApp->>Browser: redirect /dashboard
  end

  rect rgba(255, 180, 80, 0.5)
    note over Browser,MongoDB: Dashboard Data Load
    Browser->>FlaskApp: GET /dashboard
    FlaskApp->>MongoDB: find user doc
    FlaskApp->>FlaskApp: get_usage(user)
    FlaskApp->>FlaskApp: fetch_reviews(api_url)
    FlaskApp->>Browser: render dashboard.html
  end
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

🐇 Hop hop, a portal arrives today,
OAuth tokens and OTP spray,
Mongo or MemDB, whichever you please,
Gunicorn spins up with the greatest of ease,
Free plan reviews — thirty a month, not a hitch!
The rabbit deployed with a satisfying click. 🚀


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@OMCHOKSI108
OMCHOKSI108 merged commit 77106bb into main Jun 22, 2026
2 of 3 checks passed
@OMCHOKSI108
OMCHOKSI108 deleted the feature/flask-saas-website branch June 22, 2026 09:32
@github-actions

Copy link
Copy Markdown

CodeSecAudit AI Review

Verdict: APPROVE

Summary

Reviewed 11 changed code file(s) and found 0 potential issue(s). Highest severity: None.

Risk Score

0/100

Issues Found

No security issues detected.


Notes

  • This is an AI-assisted defensive security review.
  • It does not replace manual review or professional SAST tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants