Skip to content

Add SaaS website and GitHub OAuth foundation - #5

Closed
OMCHOKSI108 wants to merge 1 commit into
mainfrom
feature/website-saas-foundation
Closed

Add SaaS website and GitHub OAuth foundation#5
OMCHOKSI108 wants to merge 1 commit into
mainfrom
feature/website-saas-foundation

Conversation

@OMCHOKSI108

@OMCHOKSI108 OMCHOKSI108 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds Flask marketing website and dashboard foundation
  • Adds GitHub OAuth login flow
  • Adds MongoDB-backed user profile foundation with in-memory fallback
  • Adds Resend welcome email foundation
  • Adds usage display 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
  • python scripts/review_code.py --code "eval(user_input)" --json

Notes

  • GitHub App webhook is not implemented yet
  • Usage enforcement is display-only in this step
  • Resend guide/limit emails are next step

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a Flask-based website with GitHub OAuth login and user authentication
    • Introduced a personalized dashboard displaying review history and usage statistics against monthly limits
    • Added account settings page and welcome email notifications for new users
    • Integrated GitHub App installation flow for repository access

- Flask marketing website + dashboard (landing, login, dashboard, reviews, usage, contact, settings, error pages)
- GitHub OAuth login flow with /auth/github/start, /auth/github/callback, /logout
- MongoDB-backed user storage (users collection) with in-memory fallback
- Resend welcome email on first sign-in (safe opt-in, never blocks login)
- Usage display: 30 PR reviews/month with progress bar and remaining count
- GitHub App install CTA button (configured via GITHUB_APP_SLUG env var)
- API client: fetches review history from FastAPI backend
- Render deployment: render.yaml + website.Dockerfile + start script
- pyproject.toml: website extra (flask, requests, gunicorn)
- docs/website.md: full setup, OAuth, deployment, limitations
Copilot AI review requested due to automatic review settings June 22, 2026 08:52

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.

@github-actions

Copy link
Copy Markdown

CodeSecAudit AI Review

Verdict: APPROVE

Summary

Reviewed 9 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.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 00fad388-0c95-4145-ba66-632d875f663d

📥 Commits

Reviewing files that changed from the base of the PR and between 78c7c97 and 5859dcf.

📒 Files selected for processing (25)
  • README.md
  • deploy/render/website.Dockerfile
  • deploy/render/website_start.sh
  • docs/website.md
  • pyproject.toml
  • render.yaml
  • website/__init__.py
  • website/api_client.py
  • website/app.py
  • website/auth.py
  • website/config.py
  • website/db.py
  • website/email_service.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/reviews.html
  • website/templates/settings.html
  • website/templates/usage.html
  • website/usage.py

📝 Walkthrough

Walkthrough

This PR introduces a complete Flask-based SaaS website (website/ package) for CodeSecAudit AI, including GitHub OAuth authentication, MongoDB user persistence with in-memory fallback, Resend welcome emails, usage tracking against a monthly PR review limit, Jinja2 templates with a full CSS stylesheet, a Render Dockerfile and startup script, render.yaml service config, and corresponding documentation and README updates.

Changes

Flask SaaS Website

Layer / File(s) Summary
Config class and package dependencies
pyproject.toml, website/config.py
Config class wires all environment variables (OAuth, MongoDB, Resend, rate limits) via class attributes; pyproject.toml gains a website optional extra (Flask, Requests, Gunicorn) and extends dev to include it.
User persistence with MongoDB + in-memory fallback
website/db.py
Lazy MongoDB initialization with ping check; upsert_user, get_user, and update_usage functions route to MongoDB when connected and fall back to a module-level _users dict otherwise.
GitHub OAuth authentication blueprint
website/auth.py
auth_bp blueprint implements /auth/github/start (CSRF state, GitHub redirect), /auth/github/callback (token exchange, profile/email fetch, upsert, welcome email dispatch, session population), and /logout.
API client, usage utilities, and email service
website/api_client.py, website/usage.py, website/email_service.py
fetch_reviews, fetch_stats, fetch_review call the FastAPI backend with error suppression; get_usage/remaining_reviews/usage_percent compute monthly usage metrics; send_welcome_email POSTs to Resend with a non-blocking failure path.
Flask app factory and route handlers
website/app.py
create_app() configures session cookie security, registers auth_bp, and injects github_app_url/owner_email context globals; defines route handlers for /, /login, /dashboard, /reviews, /usage, /contact, /settings, and custom 404/500 error pages.
Jinja templates and static assets
website/templates/*, website/static/css/styles.css, website/static/js/app.js
base.html provides theme-aware nav and flash rendering; page templates cover index, login, dashboard, reviews, usage, contact, settings, and error; styles.css defines all UI components; app.js auto-dismisses flash messages.
Render deployment infrastructure and docs
deploy/render/website.Dockerfile, deploy/render/website_start.sh, render.yaml, docs/website.md, README.md
Dockerfile builds the website image with the website extra; startup script execs Gunicorn on port 10000; render.yaml defines the codesec-website service with env vars; docs/website.md documents local dev, deployment, and limitations; README adds live links and Quickstart section.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant FlaskApp
    participant GitHub
    participant MongoDB
    participant ResendAPI

    Browser->>FlaskApp: GET /auth/github/start
    FlaskApp->>Browser: redirect → GitHub OAuth authorize URL
    Browser->>GitHub: user authorizes
    GitHub->>Browser: redirect with ?code=
    Browser->>FlaskApp: GET /auth/github/callback?code=
    FlaskApp->>GitHub: POST /login/oauth/access_token
    GitHub-->>FlaskApp: access_token
    FlaskApp->>GitHub: GET /user + GET /user/emails
    GitHub-->>FlaskApp: profile + emails
    FlaskApp->>MongoDB: upsert_user(github_id, data)
    MongoDB-->>FlaskApp: user dict + is_new
    FlaskApp->>ResendAPI: POST /emails (welcome, if new user)
    ResendAPI-->>FlaskApp: 200/201 or error (non-blocking)
    FlaskApp->>Browser: session["user"] set → redirect /dashboard
    Browser->>FlaskApp: GET /dashboard
    FlaskApp->>FlaskApp: get_usage(session.user)
    FlaskApp->>FlaskApp: fetch_reviews(limit=5) via api_client
    FlaskApp-->>Browser: render dashboard.html
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 A website hops into the scene,
With OAuth flows and dashboards clean,
MongoDB stores each user's tale,
While Gunicorn spins without fail.
Flask routes bloom like spring clover—
CodeSecAudit's web life starts over! 🌸


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.

@OMCHOKSI108

Copy link
Copy Markdown
Owner Author

Superseded by PR #7 — content merged into main

@OMCHOKSI108
OMCHOKSI108 deleted the feature/website-saas-foundation branch June 22, 2026 09:43
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