Skip to content

Add base layout and landing page#96

Open
kunal-595 wants to merge 4 commits intoKathiraveluLab:devfrom
kunal-595:feat/base-template
Open

Add base layout and landing page#96
kunal-595 wants to merge 4 commits intoKathiraveluLab:devfrom
kunal-595:feat/base-template

Conversation

@kunal-595
Copy link
Copy Markdown

Jinja2 base template with nav, landing page at /,CSS. Routes for register/login will plug into this later

Copilot AI review requested due to automatic review settings March 8, 2026 10:51
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes the foundational structure for a new web application. It sets up the core Flask application, integrates Jinja2 for templating with a base layout and landing page, and includes initial CSS styling. Furthermore, it introduces MongoDB integration with a basic user model, laying the groundwork for future authentication and data persistence features.

Highlights

  • Core Flask Application Setup: A basic Flask application has been initialized, including environment variable loading, secret key generation, and fundamental routes for the index page and a health check endpoint.
  • Jinja2 Templating and Base Layout: A Jinja2 base template (base.html) has been introduced, featuring a navigation bar and content blocks. An index.html template extends this base to serve as the landing page.
  • Basic Styling: A style.css file has been added to provide foundational styling for the application's layout, typography, and navigation elements.
  • MongoDB Integration: A database.py module has been created to establish and manage a connection to MongoDB, including functions for retrieving the database client and closing the connection upon application shutdown.
  • User Model with Authentication: A User model has been implemented in models.py, providing methods for creating new users with bcrypt-hashed passwords, retrieving users by email or ID, and verifying passwords.
  • Dependency Management: A requirements.txt file lists all necessary Python packages, ensuring consistent environment setup for development and deployment.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .env.example
    • Added example environment variables for application configuration, including SECRET_KEY, FLASK_DEBUG, FLASK_PORT, and MONGO_URI.
  • app.py
    • Added the main Flask application initialization logic.
    • Implemented environment variable loading using python-dotenv.
    • Configured a secret key, generating one automatically in debug mode.
    • Defined the root route ('/') to render the index.html template.
    • Added a '/health' endpoint for application health checks.
    • Registered a database connection closure function to run on application exit.
  • database.py
    • Added MongoDB connection setup using pymongo.
    • Provided get_db() function to retrieve the default database instance.
    • Implemented close_db() function to close the MongoDB client connection.
  • models.py
    • Added a User class for managing user data in MongoDB.
    • Implemented static methods for creating users with bcrypt password hashing.
    • Included methods to retrieve users by email or ID.
    • Provided a static method to check user passwords against stored hashes.
  • requirements.txt
    • Added project dependencies: bcrypt, flask, pymongo, and python-dotenv with specified version ranges.
  • static/style.css
    • Added global CSS resets and basic styling for body, navigation, links, and main content areas.
    • Defined styles for the navigation bar, brand logo, and navigation links.
    • Included styling for main content wrapper and heading elements.
  • templates/base.html
    • Added a base Jinja2 HTML template with a standard document structure.
    • Included meta tags for character set and viewport.
    • Linked the style.css stylesheet.
    • Implemented a navigation bar with a brand link and placeholder navigation links.
    • Defined title and content blocks for child templates to extend.
  • templates/index.html
    • Added the landing page template, extending base.html.
    • Set the page title to 'BHV — Home'.
    • Included a main heading and a descriptive paragraph for the application.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an initial Flask/Jinja2 app skeleton with a shared base layout + landing page, basic styling, and MongoDB-backed user model scaffolding to support upcoming auth work.

Changes:

  • Introduces Jinja2 base.html with a nav and an index.html landing page.
  • Adds initial global CSS styling in static/style.css.
  • Adds Flask app factory, MongoDB connection helpers, and a User model; plus environment/requirements scaffolding.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
templates/index.html Landing page content extending the base template.
templates/base.html Shared layout (head, nav, main content block) and static CSS include.
static/style.css Base styling for page, nav, and main content.
requirements.txt Adds Flask, dotenv, pymongo, and bcrypt dependencies.
models.py Adds a MongoDB-backed User model with password hashing/checking helpers.
database.py Adds MongoDB client + helper functions for DB access and closing.
app.py Adds Flask app factory, / and /health routes, and shutdown hook.
.env.example Documents expected environment variables for local configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app.py
Comment on lines +8 to +12
from database import close_db


def create_app():
load_dotenv()
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

Importing close_db triggers database.py module import, which creates the Mongo client before load_dotenv() is called in create_app(). Consider loading dotenv at module import time (before importing database), or refactoring database.py to avoid initializing the client until after configuration is loaded.

Suggested change
from database import close_db
def create_app():
load_dotenv()
load_dotenv()
from database import close_db
def create_app():

Copilot uses AI. Check for mistakes.
Comment thread models.py
Comment on lines +33 to +34
def get_by_id(user_id):
return User._collection().find_one({"_id": ObjectId(user_id)})
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

ObjectId(user_id) will raise an exception if user_id is not a valid ObjectId string/bytes, which can turn a simple lookup into a 500 error for callers. Catch the relevant bson.errors.InvalidId (and TypeError) and return None (or raise a controlled app-level error) instead.

Copilot uses AI. Check for mistakes.
Comment thread database.py
Comment on lines +5 to +14
uri = os.environ.get("MONGO_URI", "mongodb://localhost:27017/bhv")
_client = MongoClient(uri)


def get_db():
return _client.get_default_database()


def close_db():
_client.close()
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

MongoClient is created at import time using os.environ before load_dotenv() runs (app.py imports database before calling create_app()). As a result, MONGO_URI set in a local .env file won’t be picked up and the app may always connect to the default URI. Initialize the client lazily (e.g., inside get_db()), or defer reading MONGO_URI until after dotenv is loaded.

Suggested change
uri = os.environ.get("MONGO_URI", "mongodb://localhost:27017/bhv")
_client = MongoClient(uri)
def get_db():
return _client.get_default_database()
def close_db():
_client.close()
_client = None
def get_db():
global _client
if _client is None:
uri = os.environ.get("MONGO_URI", "mongodb://localhost:27017/bhv")
_client = MongoClient(uri)
return _client.get_default_database()
def close_db():
global _client
if _client is not None:
_client.close()
_client = None

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the basic structure of the Flask application, including a base template, a landing page, and initial setup for the database and models. The code is a good starting point. I've left a few comments with suggestions for improving code structure, maintainability, and clarity. These include refactoring duplicated logic, improving the database connection handling, simplifying the model code, and enhancing the HTML templates for better readability and user experience.

Comment thread app.py

if __name__ == "__main__":
app = create_app()
debug = os.environ.get("FLASK_DEBUG", "0").lower() in ("1", "true", "yes")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This line duplicates the logic from lines 15-16 for determining the debug status. To avoid duplication and improve maintainability, you could calculate this value once. A good practice in Flask is to set app.config['DEBUG'] inside create_app. The app.run() method will then automatically use this configuration, so you wouldn't need to pass the debug parameter explicitly.

Comment thread database.py
from pymongo import MongoClient

uri = os.environ.get("MONGO_URI", "mongodb://localhost:27017/bhv")
_client = MongoClient(uri)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Creating the MongoClient at the module level means a connection is initiated as soon as this module is imported. This can make the application harder to test and configure, as it relies on the environment being set up correctly before any code runs. Consider creating the client within the application factory (create_app in app.py) and attaching it to the Flask app object, or at least using a lazy initialization pattern within this module to defer the client creation until it's actually needed.

Comment thread models.py
Comment on lines +24 to +25
result = User._collection().insert_one(doc)
doc["_id"] = result.inserted_id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The insert_one method from pymongo mutates the document dictionary in-place to add the _id field. This means the doc dictionary will have the _id after the call. The result object and the explicit assignment of _id on the next line are therefore redundant if you are returning the doc. You can simplify this section.

Suggested change
result = User._collection().insert_one(doc)
doc["_id"] = result.inserted_id
User._collection().insert_one(doc)

Comment thread templates/base.html
Comment on lines +17 to +18
<a href="{{ url_for('index') }}">Sign in</a>
<a href="{{ url_for('index') }}">Get started</a>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

These links for 'Sign in' and 'Get started' currently point to the home page. While this is likely a placeholder, it can be slightly confusing. To make it clear that these features are not yet implemented, you could use href="#". This is a common practice for links that are not yet functional and makes the template's intent clearer.

        <a href="#">Sign in</a>
        <a href="#">Get started</a>

Comment thread templates/index.html
Comment on lines +1 to +2
{% extends "base.html" %} {% block title %}BHV — Home{% endblock %} {% block
content %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and to follow common conventions, it's best to place each Jinja2 statement on its own line.

{% extends "base.html" %}

{% block title %}BHV — Home{% endblock %}

{% block content %}

@kunal-595
Copy link
Copy Markdown
Author

@mdxabu , plz review this pr

@mdxabu
Copy link
Copy Markdown
Member

mdxabu commented Mar 8, 2026

Don't create new PRs, make changes in a single PR itself!

#93

Use this PR!

@pradeeban pradeeban added the on hold Not merging this PR now. label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold Not merging this PR now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants