Giter VIP home page Giter VIP logo

fastapi-soft-ui-dashboard's Introduction

FastAPI Soft Dashboard

Open-source FastAPI starter provided by AppSeed op top of a modern Bootstrap 5 design. Designed for those who like bold elements and beautiful websites, Soft UI Dashboard is ready to help you create stunning websites and webapps. Soft UI Dashboard is built with over 70 frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining.


Product Roadmap

Status Item info
Up-to-date Dependencies -
Soft Dashboard Design (Free Version) by Creative-Tim
UI Kit Bootstrap 5, Dark-Mode (persistent)
Persistence SQLite, MySql
Basic Authentication classic user/password
API Products & Sales (linked tables)
GET Requests (public), get/, get/id
Mutating requests (Create, UPD, DEL) (reserved for authenticated users)
Docker Simple Setup (local usage)
OAuth Github & Twitter providers
Unitary tests -

Soft UI Dashboard - Open-source FastAPI starter provided by by AppSeed.


Project Structure

This application is composed of 3 basic parts in the root folder.

  • src provides the codebase for the main application.
  • alembic manages the DB database migration layer
  • tests stores the unit testing library.

Manual Build

Download the code

$ git clone https://github.com/app-generator/fastapi-soft-ui-dashboard.git
$ cd fastapi-soft-ui-dashboard

Install modules via VENV

$ python -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt

Create .env from env.sample - here is a sample

Note: Setting the debugging config to 1 will start the app with SQLite, setting it to 0 will start the app with MySql.

DEBUGGING=1

DATABASE_HOSTNAME=localhost
DATABASE_PORT=5432
DATABASE_PASSWORD=somepassword
DATABASE_NAME=somedbname
DATABASE_USERNAME=mayberoot

SECRET_KEY=SUPER_SECRET_HERE
ALGORITHM=HS256

ACCESS_TOKEN_EXPIRE_MINUTES=30

Migrate the database (create tables)

$ alembic upgrade head

Start the app

$ uvicorn src.app:app --reload

At this point, the app runs at http://127.0.0.1:8000/.


✨ Codebase structure

The project is coded using a modular, intuitive structure as presented below:

< PROJECT ROOT >
   |
   |-- src/
   |    |
   |    |-- helpers/                        # A simple app that serve HTML files
   |    |    |-- database.py                # Define app routes
   |    |    |-- utils.py                   # Define app routes
   |    |
   |    |-- routers/                        # Handles routes (all sections)
   |    |    |-- auth/                      # Implements authentication routes  
   |    |    |-- ui_routes.py                 
   |    |    |-- user_routes.py
   |    |
   |    |-- 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
   |    |    
   |  models.py                             # Defines the models
   |  config.py                             # Holds APP Configuration
   |  __init__.py                           # Builds the FastAPI object
   |  app.py                                # Bundles ALL resources
   |
   |-- requirements.txt                     # App Dependencies
   |
   |-- .env                                 # Inject Configuration via Environment
   |
   |-- ************************************************************************


FastAPI Soft Dashboard - Open-source Starter provided by AppSeed

fastapi-soft-ui-dashboard's People

Contributors

app-generator avatar barreraalexander avatar zub786 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fastapi-soft-ui-dashboard's Issues

Sign IN - Random user

Hello @barreraalexander

On SIgnIN, when an unregistered user is used, the app is not showing any error message.

The app should return a message to the user.
Also, if the user is registered and the password is not ok, the error message should be "Wrong Password Used".

Please take a look, Ty!

image

SQLite DB - Initial Creation

Hello @barreraalexander

The existing SQLite DB was removed - saving binaries on the codebase is not a good practice.

Please add to this issue the steps a new user should follow in order to generate the SQLite database and the tables.

Ty!

Logout link - unavailable

Once authenticated, the user cannot log out.
all related links are inactive.

Is enough to have the logout link in the navigation bar.

Please remove the logout option from sidebar.

Ty @barreraalexander

Docker Execution - The default target

Hello @barreraalexander

Note: Please update your local copy. I just commit some (minor) changes.


Once the users check out the project, they should be able to start the product using Docker:

$ docker-compose up --build

The defaults related to this:

  • Docker development YAML is executed
  • 5085 is the external port
  • 5005 is the inner APP port (not visible outside Docker)
  • SQLite used for persistence
  • Database migrated and ready to be used
  • No default users (zero provisioning).

The current behavior

On fresh install, $ docker-compose up --build bumps errors.

Please take a look. Ty!

Here is the full log:

S D:\work\repo-free\fastapi-soft-ui-dashboard> docker-compose up --build
Creating network "fastapi-soft-ui-dashboard_default" with the default driver
Building appseed-app
[+] Building 2.4s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                         0.0s 
 => => transferring dockerfile: 32B                                                                                                                                                                                          0.0s 
 => [internal] load .dockerignore                                                                                                                                                                                            0.0s 
 => => transferring context: 2B                                                                                                                                                                                              0.0s 
 => [internal] load metadata for docker.io/library/python:3.9.7                                                                                                                                                              2.1s 
 => [internal] load build context                                                                                                                                                                                            0.1s
 => => transferring context: 72.93kB                                                                                                                                                                                         0.1s
 => [1/5] FROM docker.io/library/python:3.9.7@sha256:8771691756bbf5beff80d64fca8f5b12e018352ddd9e30d8cdfef8cc3717b0e6                                                                                                        0.0s
 => CACHED [2/5] WORKDIR /usr/src/app                                                                                                                                                                                        0.0s
 => CACHED [3/5] COPY requirements.txt ./                                                                                                                                                                                    0.0s
 => CACHED [4/5] RUN pip install --no-cache-dir -r requirements.txt                                                                                                                                                          0.0s
 => [5/5] COPY . .                                                                                                                                                                                                           0.1s
 => exporting to image                                                                                                                                                                                                       0.1s
 => => exporting layers                                                                                                                                                                                                      0.0s
 => => writing image sha256:8a1f71a0795f0b971678c6e391c532098e34b352fdf548a73dad637fb562ce30                                                                                                                                 0.0s
 => => naming to docker.io/library/fastapi-soft-ui-dashboard_appseed-app                                                                                                                                                     0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Creating appseed_app ... done
Attaching to appseed_app
appseed_app    | INFO:     Will watch for changes in these directories: ['/usr/src/app']
appseed_app    | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
appseed_app    | INFO:     Started reloader process [1] using watchgod
appseed_app    | Process SpawnProcess-1:
appseed_app    | Traceback (most recent call last):
appseed_app    |   File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
appseed_app    |     self.run()
appseed_app    |   File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
appseed_app    |     self._target(*self._args, **self._kwargs)
appseed_app    |   File "/usr/local/lib/python3.9/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
appseed_app    |     target(sockets=sockets)
appseed_app    |   File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
appseed_app    |     return asyncio.run(self.serve(sockets=sockets))
appseed_app    |   File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
appseed_app    |     return loop.run_until_complete(main)
appseed_app    |   File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
appseed_app    |     return future.result()
appseed_app    |   File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 67, in serve
appseed_app    |     config.load()
appseed_app    |   File "/usr/local/lib/python3.9/site-packages/uvicorn/config.py", line 458, in load
appseed_app    |     self.loaded_app = import_from_string(self.app)
appseed_app    |   File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
appseed_app    |     module = importlib.import_module(module_str)
appseed_app    |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
appseed_app    |     return _bootstrap._gcd_import(name[level:], package, level)
appseed_app    |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
appseed_app    |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
appseed_app    |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
appseed_app    |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
appseed_app    |   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
appseed_app    |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
appseed_app    |   File "/usr/src/app/./src/app.py", line 4, in <module>
appseed_app    |     from src.routers.auth.auth_routes import router as auth_router
appseed_app    |   File "/usr/src/app/./src/routers/auth/auth_routes.py", line 6, in <module>
appseed_app    |     import src.models as models
appseed_app    |   File "/usr/src/app/./src/models.py", line 1, in <module>
appseed_app    |     from src.helpers.database import Base
appseed_app    |   File "/usr/src/app/./src/helpers/database.py", line 10, in <module>
appseed_app    |     if (settings.debugging):
appseed_app    | AttributeError: 'Settings' object has no attribute 'debugging'

FastAPI Codebase Structure

Proposed Codebase Structure

The project aims to provide a simple, intuitive, and easy-to-extend structure.


Hello @barreraalexander - please take a look at this codebase footprint and improve or simplify it.

The current version is


< PROJECT ROOT >
   |-- docs/                            # Folder to contain any helping docs
   |   |-- api_examples.json            # Example doc
   |-- scripts/                         # Folder to contain any SQL scripts
   |   |-- scripts.sql                  # Example script
   |-- src/                             # Folder having all the python code
   |    |-- models                      # Folder having all models
   |       |-- custom/                  # Folder for custom models
   |       |-- db/                      # Folder for database models
   |           |-- product.py           # Example file for the product model
   |           |-- sales.py             # Example file for sales model
   |       |-- request.py               # File containing all request models
   |       |-- response.py              # File containing all response models
   |    |-- routers/                    # Folder for all FastAPI routes
   |       |-- auth/               # Folder for authentication routes
   |           |-- auth_routes.py  # File containing authentication routes 
   |       |-- product_routes.py   # File containing product routes 
   |       |-- sales_routes.py     # File containing sales routes 
   |        |-- healthcheck.py          # Base file for health check for FastAPI
   |    |-- helpers/                    # Folder containing helper methods
   |        |-- product_helpers.py      # File having product related helper methods
   |        |-- sales_helpers.py        # File having sales related helper methods
   |        |-- common_helpers.py       # File having common helper methods
   |        |-- database.py             # File having database connection and methods
   |        |-- cache.py                # File having cache connection and methods
   |        |-- decorators.py           # File having decorators
   |    |-- 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
   |    |-- app.py                      # Containing main method, project startup
   |    |-- config.py                   # Containing Settings class for fetching configurations
   |    |-- constants.py                # Global constants
   |    |-- exception_handlers.py       # Global exception handling
   |
   |-- tests/                           # Folder having tests
   |    |-- __init__.py                 # Containing test startup
   |    |-- test.py              # Containing tests 
   |
   |-- .env.dist                        # Template for environment variables
   |-- .env                             # Actual environment variables file
   |-- .gitignore                       # File containing git ignore configurations                           
   |-- CHANGELOG.md                     # File containing change logs
   |-- LICENSE                          # File containing license information
   |-- Dockerfile                       # Docker file
   |-- Makefile                         # File containing make commands
   |-- README.md                        # README file
   |-- docker-compose.yaml              # File to run docker along with other dependencies
   |-- requirements.txt                 # Python packages dependencies
   |-- package-lock.json                # npm packages information
   |-- package.json                     # npm packages dependencies
   |
   |-- ************************************************************************

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.