Skip to content

joeygrable94/GCAPI-Backend

Repository files navigation

GCAPI Backend

CodeQL GitHub CI codecov


Getting Started

First check to ensure Python 3.11 is installed and is the current version in use.

python3 --version
> python3.11

Create a virtual environment, activate it, then install the backend python pip requirements.dev.txt file.

python3.11 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
uvicorn app.main:app --host 0.0.0.0 --port 8888 --log-level info --reload
> ... App Running at 0.0.0.0:8888
> :q
source venv/bin/deactivate

Application Structure

main.py                 # Main entry point for the application
worker.py               # Taskiq worker entry point
tasks/                  # Taskiq task definitions
cli/                    # Command line interface
    db.py                   # Manages database operations
    secure.py               # Manages secure cipher operations
core/                   # Core application code shared
    config/                 # Configuration settings
    logger/                 # Logger configuration
    pagination/             # Pagination settings
    security/               # Security protocols and utilities
        auth/                   # Authentication protocols (Auth0)
        csrf/                   # Cross Site Request Forgery protection
        encryption/             # Encryption protocols (RSA, AES)
        permissions/            # Permissions protocols
        schemas.py              # Security models
    utilities/              # Core service layer utilities
    templates.py            # Jinja2 templates
db/                     # Database operations layer
crud/                   # CRUD Layer for data models
models/                 # Database models
schemas/                # Pydantic models for data validation
api/                    # API Layer
    v1/endpoints/           # Version controlled endpoints
    deps/                   # Dependencies injected into endpoints
    exceptions/             # Error and exception handling
    middleware/             # API Middleware
    openapi.py              # OpenAPI schema
    utilities.py            # API layer utilities
public/static/          # Public static assets: images, styles, scripts
templates/email/        # Jinja2 email templates

Security Resources

Hashing and Encrypting Data

Examples:

Session Management


FastAPI Resources


Alembic

Configuration

First, run the alembic init command and specify where the migrations are to be stored.

alembic init alembic

Next edit the alembic.ini file to the location of the initialized alembic directory

[alembic]
script_location = alembic

Last, edit the env.py file in the migrations directory to include your config and db base to migrate.

Commands

Check current db version.

alembic current

After changing db models/tables, run revision, and autogenerate. Always add a message about what changed in the db models/tables.

alembic revision --autogenerate -m "added table ____"
alembic upgrade head
alembic upgrade +1
alembic downgrade -1
alembic downgrade base

SQLAlchemy ORM

Pagination


PyTest

PyTest Commands

pytest
pytest tests/crud
pytest tests/api/api_v1/test_websites.py

PyTest Resources


External Resources

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages