Skip to content

Commit

Permalink
Bump Codebase & UI
Browse files Browse the repository at this point in the history
  • Loading branch information
app-generator committed Jul 12, 2023
1 parent b988787 commit 10f33d1
Show file tree
Hide file tree
Showing 373 changed files with 54,071 additions and 135 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
__pycache__
*.pyc
*.pyo
*.pyd
21 changes: 21 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# True for development, False for production
DEBUG=False

# Flask ENV
FLASK_APP=run.py
FLASK_ENV=development

# If not provided, a random one is generated
# SECRET_KEY=<YOUR_SUPER_KEY_HERE>

# Used for CDN (in production)
# No Slash at the end
ASSETS_ROOT=/static/assets

# If DB credentials (if NOT provided, or wrong values SQLite is used)
# DB_ENGINE=mysql
# DB_HOST=localhost
# DB_NAME=appseed_db
# DB_USERNAME=appseed_db_usr
# DB_PASS=pass
# DB_PORT=3306
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# tests and coverage
*.pytest_cache
.coverage

# database & logs
*.db
*.sqlite3
*.log

# venv
env
venv

# other
.DS_Store

# sphinx docs
_build
_static
_templates

# javascript
package-lock.json
.vscode/symbols.json

apps/static/assets/node_modules
apps/static/assets/yarn.lock
apps/static/assets/.temp

51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Change Log

## [1.0.5] 2023-07-12
### Changes

- Deployment-ready for Render (CI/CD)
- `render.yaml`
- `build.sh`
- `DB Management` Improvement
- `Silent fallback` to **SQLite**

## [1.0.4] 2021-11-10
### Changes

- Bump UI: Material Dashboard - v3.0.0
- Update Bootstrap to v5.1.3
- Update to Material Design 2
- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v2.0.0
- Dependencies update (all packages)
- Flask==2.0.1 (latest stable version)
- Better Code formatting
- Improved Files organization
- Optimize imports
- Docker Scripts Update
- Gulp Tooling (SASS Compilation)
- Fixes:
- Import error caused by WTForms

## [1.0.3] 2021-05-16
### Changes

- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v1.0.6
- Freeze used versions in `requirements.txt`
- jinja2 = 2.11.3

## [1.0.2] 2021-05-11
### Improvements

- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v1.0.5
- Freeze used versions in `requirements.txt`
- flask_sqlalchemy = 2.4.4
- sqlalchemy = 1.3.23

## [1.0.1] 2021-02-10
### Improvements

- Bump UI: [Jinja Material](https://github.com/app-generator/jinja-material-dashboard) v1.0.2
- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v1.0.4

## [1.0.0] 2020-07-30
### Initial Release
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.9

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements.txt .

# install python dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# gunicorn
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "run:app"]
150 changes: 15 additions & 135 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@

<br />

> Free product - **Flask Dashboard** starter project - Features:
- Up-to-date [dependencies](./requirements.txt): **Flask 2.0.1**
- [SCSS compilation](#recompile-css) via **Gulp**
- UI Kit: **Material Dashboard - v3.0.0** (Bootstrap 5 Version) by **Creative-Tim**
- Flask Codebase - provided by **[AppSeed](https://appseed.us/)**
- SQLite, PostgreSQL, SQLAlchemy ORM
- Alembic (DB schema migrations)
- Modular design with **Blueprints**
- Session-Based authentication (via **flask_login**)
- Forms validation
- Deployment scripts: Docker, Gunicorn / Nginx, Heroku
> Features:
-`Up-to-date dependencies`
- ✅ Database: `SQLite`
-`DB Tools`: SQLAlchemy ORM, Flask-Migrate (schema migrations)
- ✅ Session-Based authentication (via **flask_login**), Forms validation
-`Docker`
- ✅ CI/CD via `Render`

<br />

Expand Down Expand Up @@ -47,28 +43,26 @@

## Docker Support

> Get the code
> 👉 **Step 1** - Get the code
```bash
$ git clone https://github.com/app-generator/material-dashboard-flask.git
$ cd material-dashboard-flask
```

> Start the app in Docker
> 👉 **Step 2** - Start the APP in `Docker`
```bash
$ docker-compose pull # download dependencies
$ docker-compose build # local set up
$ docker-compose up -d # start the app
$ docker-compose up --build
```

Visit `http://localhost:85` in your browser. The app should be up & running.
Visit `http://localhost:5085` in your browser. The app should be up & running.

<br />

## Quick start
## Manual Build

> UNZIP the sources or clone the private repository. After getting the code, open a terminal and navigate to the working directory, with product source code.
> 👉 **Step 1** - Get the code
```bash
$ # Get the code
Expand Down Expand Up @@ -112,122 +106,8 @@ $ # Access the dashboard in browser: http://127.0.0.1:5000/
<br />

## Documentation
The documentation for the **Material Dashboard Flask** is hosted at our [website](https://demos.creative-tim.com/material-dashboard-flask/docs/1.0/getting-started/getting-started-flask.html).

<br />

## File Structure
Within the download you'll find the following directories and files:

```bash
< PROJECT ROOT >
|
|-- apps/
| |
| |-- home/ # A simple app that serve HTML files
| | |-- routes.py # Define app routes
| |
| |-- authentication/ # Handles auth routes (login and register)
| | |-- routes.py # Define authentication routes
| | |-- models.py # Defines models
| | |-- forms.py # Define auth forms (login and register)
| |
| |-- static/
| | |-- <css, JS, images> # CSS files, Javascripts files
| |
| |-- templates/ # Templates used to render pages
| | |-- includes/ # HTML chunks and components
| | | |-- navigation.html # Top menu component
| | | |-- sidebar.html # Sidebar component
| | | |-- footer.html # App Footer
| | | |-- scripts.html # Scripts common to all pages
| | |
| | |-- layouts/ # Master pages
| | | |-- base-fullscreen.html # Used by Authentication pages
| | | |-- base.html # Used by common pages
| | |
| | |-- accounts/ # Authentication pages
| | | |-- login.html # Login page
| | | |-- register.html # Register page
| | |
| | |-- home/ # UI Kit Pages
| | |-- index.html # Index page
| | |-- 404-page.html # 404 page
| | |-- *.html # All other pages
| |
| config.py # Set up the app
| __init__.py # Initialize the app
|
|-- requirements.txt # Development modules - SQLite storage
|-- requirements-mysql.txt # Production modules - Mysql DMBS
|-- requirements-pqsql.txt # Production modules - PostgreSql DMBS
|
|-- Dockerfile # Deployment
|-- docker-compose.yml # Deployment
|-- gunicorn-cfg.py # Deployment
|-- nginx # Deployment
| |-- appseed-app.conf # Deployment
|
|-- .env # Inject Configuration via Environment
|-- run.py # Start the app - WSGI gateway
|
|-- ************************************************************************
```

<br />

> The bootstrap flow
- `run.py` loads the `.env` file
- Initialize the app using the specified profile: *Debug* or *Production*
- If env.DEBUG is set to *True* the SQLite storage is used
- If env.DEBUG is set to *False* the specified DB driver is used (MySql, PostgreSQL)
- Call the app factory method `create_app` defined in app/__init__.py
- Redirect the guest users to Login page
- Unlock the pages served by *home* blueprint for authenticated users

<br />

## Recompile CSS

To recompile SCSS files, follow this setup:

<br />

**Step #1** - Install tools

- [NodeJS](https://nodejs.org/en/) 12.x or higher
- [Gulp](https://gulpjs.com/) - globally
- `npm install -g gulp-cli`
- [Yarn](https://yarnpkg.com/) (optional)

<br />

**Step #2** - Change the working directory to `assets` folder

```bash
$ cd apps/static/assets
```

<br />

**Step #3** - Install modules (this will create a classic `node_modules` directory)

```bash
$ npm install
// OR
$ yarn
```

<br />

**Step #4** - Edit & Recompile SCSS files

```bash
$ gulp scss
```

The generated file is saved in `static/assets/css` directory.
The documentation for the **Material Dashboard Flask** is hosted at our [website](https://demos.creative-tim.com/material-dashboard-flask/docs/1.0/getting-started/getting-started-flask.html).

<br />

Expand Down
55 changes: 55 additions & 0 deletions apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""

from flask import Flask
from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy
from importlib import import_module


db = SQLAlchemy()
login_manager = LoginManager()


def register_extensions(app):
db.init_app(app)
login_manager.init_app(app)


def register_blueprints(app):
for module_name in ('authentication', 'home'):
module = import_module('apps.{}.routes'.format(module_name))
app.register_blueprint(module.blueprint)


def configure_database(app):

@app.before_first_request
def initialize_database():
try:
db.create_all()
except Exception as e:

print('> Error: DBMS Exception: ' + str(e) )

# fallback to SQLite
basedir = os.path.abspath(os.path.dirname(__file__))
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'db.sqlite3')

print('> Fallback to SQLite ')
db.create_all()

@app.teardown_request
def shutdown_session(exception=None):
db.session.remove()


def create_app(config):
app = Flask(__name__)
app.config.from_object(config)
register_extensions(app)
register_blueprints(app)
configure_database(app)
return app
12 changes: 12 additions & 0 deletions apps/authentication/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""

from flask import Blueprint

blueprint = Blueprint(
'authentication_blueprint',
__name__,
url_prefix=''
)
Loading

0 comments on commit 10f33d1

Please sign in to comment.