๐ŸŒ AIๆœ็ดข & ไปฃ็† ไธป้กต
Skip to content

CodeLabsProStack is a SNAP stack - Built using SvelteKit - NextJS - (fast)API - Postgres- stack toolkit for building, testing and deploying fullstack CMS, CRM and Mobile SaaS applications

License

Notifications You must be signed in to change notification settings

codelabspro/CodeLabsProStack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

65 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CodeLabsProStack

CodeLabsProStack is a SvelteKit - NextJS - (fast)API - Postgres- stack toolkit for building, testing and deploying fullstack CMS, CRM and Mobile SaaS applications

Useful Links

https://codeverter.vercel.app

Screenshots

Steps for blog


==> python3 -m venv myvenv

==> source myvenv/bin/activate

pip install fastapi

pip install "uvicorn[standard]"

pip install pydantic

pip install --upgrade pip

==> python --version (should be 3.9 or higher)
Python 3.10.9

==> uvicorn --version
Running uvicorn 0.15.0 with CPython 3.10.9 on Darwin

pip install sqlalchemy

pip install passlib

pip install bcrypt

pip install sqladmin

JWT Dependencies

pip install "python-jose[cryptography]"

pip install "passlib[bcrypt]"

Run backend locally

conda deactivate

cd app

python3 -m venv myvenv OR source myvenv/bin/activate

pip install -r requirements.txt
###################################

uvicorn main:app --reload
###################################

Deployment

Dockerfileยถ

Now in the same project directory create a file Dockerfile with:

#
FROM python:3.9

#
WORKDIR /code

#
COPY ./requirements.txt /code/requirements.txt

#
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

#
COPY ./app /code/app

#
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]

  • Build Dockerfile
docker build -t codelabsprostack:0.0.1 .
  • Run Docker Container Locally
docker run -p 8080:8080 --name codelabsprostack codelabsprostack:0.0.1
  • List docker images
docker images -a
  • List running docker processes
docker ps -a
  • Remove running docker process
docker rm codelabsprostack

Frontend Develop

  • Frontend (web) was created using SvelteKit with the below config

==> npm create skeleton-app@latest web
โ”Œ  Create Skeleton App (version 0.0.29)

Welcome to Skeleton ๐Ÿ’€! A UI tookit for Svelte + Tailwind

Problems? Open an issue on https://github.com/skeletonlabs/skeleton/issues if none exists already.
โ”‚
โ—‡  Add type checking with TypeScript?
โ”‚  Yes, using TypeScript syntax
โ”‚
โ—‡  Add ESLint for code linting?
โ”‚  Yes
โ”‚
โ—‡  Add Prettier for code formatting ?
โ”‚  Yes
โ”‚
โ—‡  Add Playwright for browser testing ?
โ”‚  No
โ”‚
โ—‡  Add Vitest for unit testing ?
โ”‚  No
โ”‚
โ—‡  Install component dependencies:
โ”‚  CodeBlock (installs highlight.js), Popups (installs floating-ui)
โ”‚
โ—‡  Pick tailwind plugins to add:
โ”‚  forms, typography, line-clamp
โ”‚
โ—‡  Select a theme:
โ”‚  Crimson
โ”‚
โ—‡  Which Skeleton app template?
โ”‚  Bare Bones
โ”‚
โ—‡  Done installing

Done! You can now:

cd web

###################################
npm run dev
###################################

Develop local

cd web

npm run dev

Alembic

  • Alembic for migrations

alembic init <alembic_folder_name>

pip install alembic

alembic init <alembic_migrations_folder> OR alembic init alembic

* alembic.ini

Add sqlalchemy.url = postgres://codelabsprostack_admin_1:@127.0.0.1/codelabsprostack_prod_1 to line 64 of alembic.ini


OR

In env.py, load CONNECTION_STRING from .env

dotenv_path = join(dirname(file), '.env') load_dotenv(dotenv_path)

CONNECTION_STRING = os.environ.get("CONNECTION_STRING") config.set_main_option('sqlalchemy.url', CONNECTION_STRING)



* script.py.mako

Add import sqlmodel below import sqlalchemy as sa in script.py.mako


* env.py - In env.py
Below
from logging.config import fileConfig

from models import * from sqlmodel import SQLModel


Change

target_metadata = None


to

target_metadata = SQLModel.metadata


* Alembic create migrations

cd app alembic revision --autogenerate -m "Create"


* Alembic run migrations

cd app alembic upgrade heads


* Alembic downgrade

alembic downgrade


## Postgres Troubleshooting

psql --host=localhost --username=my_user --dbname=my_database

psql --host=localhost --username=codelabsprostack_admin_1 --dbname=codelabsprostack_prod_1

psql postgres -c 'SHOW config_file' config_file

/opt/homebrew/var/postgres/postgresql.conf`

postgres=# REASSIGN OWNED BY skfaps_user TO unicorn_user; REASSIGN OWNED postgres=# DROP OWNED BY skfaps_user; DROP OWNED postgres=# DROP USER skfaps_user; ERROR: role "skfaps_user" cannot be dropped because some objects depend on it DETAIL: 1 object in database skfaps_dev_1 postgres=# DROP DATABASE skfaps_dev_1; DROP DATABASE postgres=# DROP USER skfaps_user;


# Migrations Log

alembic revision --autogenerate -m "Create"

alembic revision --autogenerate -m "Added tags to Post user model"

alembic revision --autogenerate -m "Removed tags from Post user model"

alembic revision --autogenerate -m "Added Prompt dataclass to models"

alembic upgrade heads


## Useful Links

Alembic + SQLModel - https://www.youtube.com/watch?v=Rb4_90gG_Lc

Alembic - https://youtu.be/SdcH6IEi6nE


## Generate SECRET_KEY

openssl rand -base64 32

ee8b93f88b000896451907e0f6e7fe7b1fc62b096a3ff9b8166577eb9390150b

About

CodeLabsProStack is a SNAP stack - Built using SvelteKit - NextJS - (fast)API - Postgres- stack toolkit for building, testing and deploying fullstack CMS, CRM and Mobile SaaS applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •