Docs: Consolidate admin documentation and migrate reference data

- Created LOCAL_DEVELOPMENT_GUIDE.md and DEPLOYMENT_GUIDE_MANUAL.md from legacy txt files.
- Migrated country/time_zone data and requirements.txt to documentation/reference_data/.
- Removed redundant admin/documentation/ and admin/data_files/ directories.
- Enhanced app/lib_schema_v3.py to explicitly capture 'required' fields from DB 'NOT NULL' constraint.
- Added verification tests for schema logic and standalone DB connectivity.
This commit is contained in:
Scott Idem
2026-01-16 10:06:51 -05:00
parent db5cf2502a
commit 31fd384704
17 changed files with 465 additions and 222 deletions

View File

@@ -0,0 +1,153 @@
# Manual Server Deployment Guide (Non-Docker)
This guide describes the manual process for deploying the Aether API on a Linux server using Nginx, Gunicorn, and Systemd.
## 1. Initial Server Setup
### Clone the Repository
```bash
sudo git clone https://scott_idem@bitbucket.org/oneskyit/one-sky-it-api-fastapi.git /srv/http/dev_fastapi.oneskyit.com
```
### Configure Permissions
```bash
sudo mkdir admin/log
sudo chown http:http -R /srv/http/dev_fastapi.oneskyit.com/
sudo chmod 775 -R /srv/http/dev_fastapi.oneskyit.com/
```
### Environment Preparation
```bash
cd /srv/http/dev_fastapi.oneskyit.com/
git switch development
virtualenv environment
source environment/bin/activate
pip install -U -r admin/requirements.txt
```
## 2. Gunicorn Configuration (Systemd)
### Socket Configuration (`/etc/systemd/system/gunicorn.socket`)
```ini
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
User=http
[Install]
WantedBy=sockets.target
```
### Service Configuration (`/etc/systemd/system/gunicorn.service`)
```ini
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
Type=notify
User=root
Group=root
RuntimeDirectory=gunicorn
WorkingDirectory=/srv/http/dev_fastapi.oneskyit.com
Environment="PATH=/srv/http/dev_fastapi.oneskyit.com/environment/bin"
ExecStart=/srv/http/dev_fastapi.oneskyit.com/environment/bin/gunicorn \
--bind unix:/srv/http/dev_fastapi.oneskyit.com/gunicorn.sock \
-m 007 app.main:app \
--workers 4 \
-k uvicorn.workers.UvicornWorker \
--access-logfile admin/log/access.log \
--error-logfile admin/log/error.log \
--capture-output --keep-alive 5
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
```
### Activation
```bash
sudo systemctl daemon-reload
sudo systemctl enable gunicorn.socket
sudo systemctl start gunicorn.socket
```
## 3. Nginx Configuration
Create a site configuration file at `/etc/nginx/sites-available/dev_fastapi.oneskyit.com`:
```nginx
server {
access_log /var/log/nginx/access_dev_fastapi.oneskyit.com.log;
listen 443 ssl;
listen [::]:443 ssl http2;
server_name dev-fastapi.oneskyit.com;
ssl_certificate /etc/letsencrypt/live/oneskyit.com-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/oneskyit.com-0001/privkey.pem;
client_max_body_size 4096M;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://unix:/run/gunicorn.sock;
}
# WebSocket Support
location ~ ^/(ws|ws_redis) {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://unix:/run/gunicorn.sock;
}
}
server {
listen 80;
listen [::]:80;
server_name dev-fastapi.oneskyit.com;
return 301 https://$host$request_uri;
}
```
Enable and restart Nginx:
```bash
sudo ln -s /etc/nginx/sites-available/dev_fastapi.oneskyit.com /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service
```
## 4. Troubleshooting
```bash
# Check status
sudo systemctl status gunicorn.socket
sudo systemctl status gunicorn.service
sudo systemctl status nginx.service
# List active units
systemctl list-units --type=service --state=running
```

View File

@@ -0,0 +1,78 @@
# Local Development Guide
This guide provides instructions for setting up and running the Aether API locally for development.
## 1. Prerequisites
- Python 3.9+ (or as specified in `requirements.txt`)
- `virtualenv` or `venv`
## 2. Setup Procedure
### Create and Activate Environment
```bash
# Go to root of application
cd ~/path/to/directory/aether_api_fastapi/
# Create new application environment
virtualenv environment
# Activate application environment
source environment/bin/activate
```
### Install Requirements
```bash
# Install application requirements
pip install -r admin/requirements.txt
# Troubleshooting/Force Reinstall if needed:
# pip install --upgrade --force-reinstall -r admin/requirements.txt
# pip install --ignore-installed -r admin/requirements.txt
```
## 3. Running the Application
### Start with Uvicorn (Reload enabled)
```bash
uvicorn app.main:app --host 0.0.0.0 --port 5005 --reload
```
### Accessing the API
The application will be available at:
- API Root: [http://localhost:5005](http://localhost:5005)
- Swagger Docs: [http://localhost:5005/docs](http://localhost:5005/docs)
## 4. Git Workflow Basics
### Initialization
```bash
git init
git remote add origin https://scott_idem@bitbucket.org/oneskyit/one-sky-it-api.git
```
### Basic Commands
```bash
# Adding and committing
git add .
git commit -m 'Your commit message'
# Pushing to branches
git push -u origin master
git push -u origin development
```
### Branch Management
```bash
# List branches
git branch -a
# Create and switch to new branch
git branch new-branch-name
git switch new-branch-name
```
## 5. Deployment Basics (Manual)
If you are cloning for the first time on a server:
```bash
git clone https://scott_idem@bitbucket.org/oneskyit/one-sky-it-api-fastapi.git /srv/http/destination_path
```

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
# Updated manually 2024-04-26 with a lot of trial and error.
# A few are commented out even though they are actually used and required. Other packages already pull them in.
# SQLAlchemy needs to be upgraded to 2.x. There are issues with async IO or something related to that.
# https://docs.sqlalchemy.org/en/14/changelog/migration_20.html
# aioredis # BAD! Not maintained!
aiofiles
# aiohttp # added 2024-04-24
# anyio
argon2-cffi
argon2-cffi-bindings
# asgiref
async-timeout
baize # added 2023-08-17
# certifi
# cffi
charset-normalizer
click
Deprecated
dnspython
email-validator
et-xmlfile
fastapi==0.95.1 # working 0.94.1, 0.88.0; not working >= 0.95.0, 0.95.1
# greenlet>=2.0.2
# gevent
gunicorn # working >=21.2.0
h11
html2text
httpcore
httptools
httpx
idna
itsdangerous
# Jinja2>=3.1.2
MarkupSafe
mysqlclient
numpy
openpyxl
orjson
# packaging
pandas
passlib
pdf2image
Pillow
pycparser
pydantic
PyJWT
pyparsing
psutil
python-dateutil
python-dotenv
python-multipart
pytz
PyYAML
qrcode
redis[hiredis] # redis==5.0.0 hiredis==2.2.3
requests
rfc3986
six
sniffio
SQLAlchemy==1.4.52 # working 1.4.52; (2.0.29) I am working with
starlette # working ==0.26.1, 0.22.0; not working newest 0.37.2
stripe
typing_extensions
ujson
urllib3
uvicorn # working ==0.20.0
uvloop
Wand
watchfiles
watchgod
websockets
wrapt
xlrd

View File

@@ -0,0 +1,70 @@
# Updated manually 2023-09-12 with a lot of trial and error.
# A few are commented out even though they are actually used and required. Other packages already pull them in.
# SQLAlchemy needs to be upgraded to 2.x. There are issues with async IO or something related to that.
# https://docs.sqlalchemy.org/en/14/changelog/migration_20.html
# aioredis # BAD! Not maintained!
aiofiles
anyio
argon2-cffi
argon2-cffi-bindings
# asgiref
async-timeout
baize # added 2023-08-17
# certifi
# cffi
charset-normalizer
click
Deprecated
dnspython
email-validator
et-xmlfile
fastapi>=0.88.0
greenlet>=2.0.2
gunicorn>=20.1.0
h11
html2text>=2020.1.16
httpcore
httptools
httpx
idna
itsdangerous
# Jinja2>=3.1.2
MarkupSafe
mysqlclient
numpy>=1.25.2
openpyxl
orjson
# packaging
pandas>=2.1.0
passlib
pdf2image>=1.16.3
Pillow>=10.0.0
pycparser
pydantic>=1.10.12
PyJWT>=2.8.0
pyparsing
python-dateutil
python-dotenv
python-multipart
pytz
PyYAML>=6.0.1
qrcode>=7.4.2
redis[hiredis] # redis==5.0.0 hiredis==2.2.3
requests
rfc3986
six
sniffio
SQLAlchemy==1.4.49 # 1.4.47 is the newest (2.0.20) I am working with
starlette>=0.22.0
stripe>=6.4.0
typing_extensions
ujson
urllib3
uvicorn
uvloop
watchfiles
watchgod
websockets>=11.0.3
wrapt
xlrd

File diff suppressed because one or more lines are too long