How sarveshwarsenthilkumar/flask-development-template works
This project is a Flask web application template designed to provide a structured foundation for building Flask projects. The purpose is to give developers a ready-to-use setup with pre-configured components like authentication, templating, and database integration using SQLite.
Main Components
• Front-End Presentation Layer: Represented by the 'templates' directory which includes the main HTML views and specific authentication views (login, signup, and loggedIn pages). This layer leverages Jinja2 templating.
• Application Logic and Routing: The central hub is app.py, which initializes the Flask application and defines the routes. Also, auth.py manages specific authentication routes, likely using Flask’s Blueprint mechanism.
• Authentication Utilities: SarvAuth.py houses core authentication helper functions like email checking, user validation, and password hashing.
• Database Management: createDatabase.py is responsible for setting up and seeding the SQLite database. Additionally, sql.py acts as a utility module (inspired by CS50 Harvard’s work) facilitating database interactions.
• Configuration & Environment Management: The '.env' file stores sensitive configuration data (such as encryption keys), while '.gitignore' ensures security by not committing it.
• Dependency Management and Metadata: requirements.txt outlines all Python package dependencies required, and supporting documents like LICENSE.md, README.md, and ToDo.txt provide guidance and legal details.
Relationships and Interactions
• User requests first hit the Flask web server configured in app.py.
• Depending on the URL routes, the requests either call authentication functions (from auth.py and the utility functions in SarvAuth.py) or trigger other application logic.
• The templates folder supplies the view layer by rendering dynamic HTML responses.
• Data persistence and retrieval operations are managed through the SQLite database using the createDatabase.py script and the sql.py module.
• Environment-specific configurations (including encryption keys and port information) are fetched from the .env file during the application startup.
Key Architectural Patterns
• MVC/Template Pattern: Separation between views (HTML templates), controllers (Flask routes in app.py and auth.py), and model/data management (SQLite functionalities via createDatabase.py and sql.py).
• Modularization: Authentication is modularized across auth.py and the helper functions in SarvAuth.py, which aids in clarity and reusability.
• Dependency Injection: Use of external configuration (via .env) for sensitive details and dynamic settings such as the encryption key and port number.