Skip to content

Conversation

@gkorland
Copy link
Contributor

@gkorland gkorland commented Jul 27, 2025

Summary by CodeRabbit

New Features

  • Introduced OAuth2 authentication with Google and GitHub, including login/logout flows and user profile UI.
  • Added support for connecting to PostgreSQL databases via a new modal and endpoint.
  • Implemented per-user graph isolation and management, with schema upload and refresh capabilities.
  • Added confirmation dialogs for destructive SQL operations before execution.
  • Enhanced chat interface with user avatars, modals for authentication, PostgreSQL connection, and reset confirmation.
  • Added LLM-based answer and table validation utilities.

Bug Fixes

  • Improved error handling for authentication, graph loading, and database connection failures.

Refactor

  • Modularized AI agent logic and utilities for query analysis, relevancy, follow-ups, taxonomy, and response formatting.
  • Enhanced code readability and maintainability across loaders, schema validation, and utility modules.
  • Updated CSS for comprehensive theming, responsiveness, and accessibility.

Documentation

  • Expanded README with detailed setup and OAuth configuration instructions.
  • Added new documentation for PostgreSQL loader and AI agent architecture.

Chores

  • Updated dependencies to include flask-dance and psycopg2-binary.
  • Added Dockerfile and startup script for containerization and deployment.

Style

  • Unified code formatting, improved logging practices, and modernized template and static asset structure.

Tests

  • No new tests introduced.

Revert

  • None.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 27, 2025

Walkthrough

This update introduces OAuth-based user authentication, per-user graph isolation, and multi-step query streaming with confirmation for destructive SQL operations. The agent architecture is modularized, with each agent moved to its own file and a new utility for parsing LLM responses. The PostgreSQL loader is enhanced with schema modification detection, schema refresh, and SQL execution. The UI is redesigned for improved theming, responsiveness, and accessibility, including new modals and user profile features. Documentation and example data are expanded, and several workflow and dependency files are updated.

Changes

Cohort / File(s) Change Summary
Authentication & API Routing
api/index.py
Major refactor to implement OAuth2 authentication (Google/GitHub), per-user graph isolation, streaming multi-step query responses, destructive operation confirmation, schema refresh, and new database connection endpoints.
Agent Modularization
api/agents.py (deleted), api/agents/init.py, api/agents/analysis_agent.py, api/agents/relevancy_agent.py, api/agents/follow_up_agent.py, api/agents/taxonomy_agent.py, api/agents/response_formatter_agent.py, api/agents/utils.py, api/agents/README.md
Agents split into individual modules with clear responsibilities and a shared utility for JSON parsing; package __init__.py defines public API. README added for documentation.
PostgreSQL Loader Enhancements
api/loaders/postgres_loader.py, docs/postgres_loader.md
Loader renamed and refactored to support schema modification detection, schema refresh, and generic SQL execution with result serialization. Comprehensive documentation added.
Graph & Schema Handling
api/graph.py, api/loaders/graph_loader.py, api/loaders/csv_loader.py, api/loaders/schema_validator.py, api/loaders/json_loader.py, api/loaders/odata_loader.py, api/helpers/crm_data_generator.py
Refactored for style, modularity, and improved logging; CSV loader fully implemented; graph loader extended with db_url; schema validation modularized; CRM generator improved for encoding and clarity.
Configuration & Constants
api/config.py, api/constants.py
Added validator model constant, improved formatting, and docstrings for clarity. Constants reformatted for readability.
Utilities
api/utils.py
Added LLM-based answer and table validation utilities; improved formatting and docstrings.
Frontend Redesign
api/static/css/chat.css, api/static/js/chat.js, api/templates/chat.html (deleted), api/templates/chat.j2
Complete UI redesign: new theming, responsive layout, modals for login and database connection, user profile dropdown, destructive operation confirmation, avatar support, and improved error handling. Legacy suggestions UI removed.
Workflow & Deployment
.github/workflows/dependency-review.yml, .github/workflows/pylint.yml, Dockerfile, start.sh
Workflow jobs updated for conditional execution and Poetry versioning. New Dockerfile and start script for containerized deployment.
Documentation & Examples
README.md, examples/crm.sql
Expanded setup and OAuth instructions in README. Large CRM SQL schema and data example added.
Miscellaneous
onthology.py
Minor variable renaming and string formatting for clarity.
Dependencies
pyproject.toml, requirements.txt
Added flask-dance and psycopg2-binary; removed platform-specific markers and colorama.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant FlaskApp
    participant OAuthProvider as OAuth (Google/GitHub)
    participant DB as PostgresLoader
    participant GraphDB

    User->>Browser: Visit /login
    Browser->>FlaskApp: /login request
    FlaskApp->>OAuthProvider: Redirect to OAuth login
    OAuthProvider->>Browser: OAuth consent flow
    Browser->>FlaskApp: OAuth callback with token
    FlaskApp->>OAuthProvider: Validate token
    OAuthProvider-->>FlaskApp: User info
    FlaskApp->>Browser: Set session, render chat UI

    User->>Browser: Enter SQL question
    Browser->>FlaskApp: POST /graphs/<graph_id> (with user session)
    FlaskApp->>GraphDB: Retrieve schema (per-user graph)
    FlaskApp->>Agents: Analyze question, generate SQL
    Agents->>FlaskApp: Return analysis, SQL, confidence, etc.
    FlaskApp->>Browser: Stream reasoning steps

    alt Destructive SQL detected
        FlaskApp->>Browser: Stream destructive_confirmation dialog
        User->>Browser: Confirm/cancel
        Browser->>FlaskApp: POST /graphs/<graph_id>/confirm
        alt Confirmed
            FlaskApp->>DB: Execute SQL
            DB->>FlaskApp: Return results
            FlaskApp->>Browser: Stream results and AI explanation
        else Cancelled
            FlaskApp->>Browser: Stream operation_cancelled
        end
    else Safe SQL
        FlaskApp->>DB: Execute SQL
        DB->>FlaskApp: Return results
        FlaskApp->>Browser: Stream results and AI explanation
    end
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90 minutes

Poem

A rabbit hopped through fields of code,
Modular agents now neatly bestowed.
OAuth guards each user's way,
With graphs and queries kept at bay.
A new UI, bright and keen—
The best chat burrow you've ever seen!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between e8d527f and cf9dcb3.

⛔ Files ignored due to path filters (5)
  • api/static/public/icons/github.svg is excluded by !**/*.svg
  • api/static/public/icons/google.svg is excluded by !**/*.svg
  • api/static/public/icons/logo.svg is excluded by !**/*.svg
  • api/static/public/icons/menu.svg is excluded by !**/*.svg
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (37)
  • .github/workflows/dependency-review.yml (1 hunks)
  • .github/workflows/pylint.yml (0 hunks)
  • Dockerfile (1 hunks)
  • README.md (1 hunks)
  • api/agents.py (0 hunks)
  • api/agents/README.md (1 hunks)
  • api/agents/__init__.py (1 hunks)
  • api/agents/analysis_agent.py (1 hunks)
  • api/agents/follow_up_agent.py (1 hunks)
  • api/agents/relevancy_agent.py (1 hunks)
  • api/agents/response_formatter_agent.py (1 hunks)
  • api/agents/taxonomy_agent.py (1 hunks)
  • api/agents/utils.py (1 hunks)
  • api/config.py (3 hunks)
  • api/constants.py (1 hunks)
  • api/extensions.py (1 hunks)
  • api/graph.py (8 hunks)
  • api/helpers/crm_data_generator.py (12 hunks)
  • api/index.py (4 hunks)
  • api/loaders/base_loader.py (1 hunks)
  • api/loaders/csv_loader.py (8 hunks)
  • api/loaders/graph_loader.py (5 hunks)
  • api/loaders/json_loader.py (2 hunks)
  • api/loaders/odata_loader.py (3 hunks)
  • api/loaders/postgres_loader.py (8 hunks)
  • api/loaders/schema_validator.py (2 hunks)
  • api/static/css/chat.css (20 hunks)
  • api/static/js/chat.js (13 hunks)
  • api/templates/chat.html (0 hunks)
  • api/templates/chat.j2 (1 hunks)
  • api/utils.py (6 hunks)
  • docs/postgres_loader.md (1 hunks)
  • examples/crm.sql (1 hunks)
  • onthology.py (1 hunks)
  • pyproject.toml (1 hunks)
  • requirements.txt (1 hunks)
  • start.sh (1 hunks)
💤 Files with no reviewable changes (3)
  • .github/workflows/pylint.yml
  • api/templates/chat.html
  • api/agents.py

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.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gkorland gkorland closed this Jul 31, 2025
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.

3 participants