- Python 3.8 or higher
- pip (Python package manager)
git clone <repository-url>
cd thywillpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the project root:
cp .env.example .envEdit the .env file and add your configuration:
# Required
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# Optional - Text Archive Settings
TEXT_ARCHIVE_ENABLED=true
TEXT_ARCHIVE_BASE_DIR=./text_archives
TEXT_ARCHIVE_COMPRESSION_AFTER_DAYS=365
# Optional - Other settings
MULTI_DEVICE_AUTH_ENABLED=true
REQUIRE_APPROVAL_FOR_EXISTING_USERS=true
PEER_APPROVAL_COUNT=2Optional configuration variables are documented in .env.example.
Initialize the database tables:
./thywill db init# Recommended - uses ThyWill CLI with safety protections
./thywill start
# Alternative - direct uvicorn (development only)
uvicorn app:app --reload --host 0.0.0.0 --port 8000- When you first start the application, it will generate an admin invite token
- Look for the token in the console output:
==== First-run invite token (admin): <token> ==== - Visit
http://localhost:8000/claim/<token>to create the admin account - Use the admin account to generate invite links for other users
- Session Duration: Sessions last 14 days by default
- Invite Token Expiration: Invite tokens expire after 12 hours (configurable via
INVITE_TOKEN_EXPIRATION_HOURS) - Database: Uses SQLite (
thywill.db) by default - Text Archives: Human-readable data backups stored in
./text_archives/
# Database operations
./thywill backup # Create database backup
./thywill migrate # Run database migrations
./thywill db init # Initialize database (first time only)
# Application management
./thywill start # Start development server
./thywill health # Check application health
./thywill logs # View application logs
# Data management
./thywill import prayers <file> # Import prayer data
./thywill import community <file> # Import community export
# Admin operations
./thywill admin token # Create admin invite token
./thywill admin list # List admin usersWhen updating production:
git pull
./thywill backup # Create backup before changes
./thywill migrate # Apply database migrations
sudo systemctl restart thywill # Restart serviceprompts.yaml- Daily prompts (format:YYYY-MM-DD: "prompt text")
- Main feed:
http://localhost:8000/ - Admin panel:
http://localhost:8000/admin(admin users only) - Activity feed:
http://localhost:8000/activity
- Missing Anthropic API Key: Ensure
ANTHROPIC_API_KEYis set in your.envfile - Port Already in Use: Change the port number in the uvicorn command
- Database Errors: Delete
thywill.dbto reset the database (will lose all data) - Missing Text Archives: Run
python3 heal_prayer_archives.pyto create archives for existing prayers - Migration Issues: Use
./thywill migrateto update database schema
Required:
ANTHROPIC_API_KEY- Your Anthropic API key for prayer generation
Optional:
MULTI_DEVICE_AUTH_ENABLED- Enable/disable multi-device authentication (default: true)REQUIRE_APPROVAL_FOR_EXISTING_USERS- Require approval for existing users on new devices (default: true)PEER_APPROVAL_COUNT- Number of peer approvals needed for authentication (default: 2)REQUIRE_VERIFICATION_CODE- Enhanced security mode for verification codes (default: false)
See .env.example for detailed descriptions of all configuration options.
For development with auto-reload:
uvicorn app:app --reload --host 0.0.0.0 --port 8000uvicorn app:app --reload --host 0.0.0.0 --port 8000- Check for existing service:
sudo systemctl status thywill
sudo systemctl list-units --type=service | grep -i thywill- Create systemd service file:
sudo nano /etc/systemd/system/thywill.service- Service file content:
[Unit]
Description=ThyWill Prayer Platform
After=network.target
[Service]
Type=exec
User=thywill
Group=thywill
WorkingDirectory=/home/thywill/thywill
Environment=PATH=/home/thywill/thywill/venv/bin
ExecStart=/home/thywill/thywill/venv/bin/uvicorn app:app --host 0.0.0.0 --port 8000
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable thywill
sudo systemctl start thywill- Check service status:
sudo systemctl status thywill- Service management commands:
# Start the service
sudo systemctl start thywill
# Stop the service
sudo systemctl stop thywill
# Restart the service
sudo systemctl restart thywill
# View logs
sudo journalctl -u thywill -f- Host Binding: Always use
--host 0.0.0.0for external access, not127.0.0.1 - Port Conflicts: If port 8000 is in use, check for existing services with
sudo lsof -i :8000 - Firewall: Ensure port 8000 is open:
sudo ufw allow 8000 - SSL/Domain: For domains, set up reverse proxy (nginx) and SSL certificates
- Database: Consider PostgreSQL or MySQL for production
- Monitoring: Set up proper logging and monitoring
- Environment: Ensure
.envfile has production-appropriate settings
- Port already in use: Kill existing processes with
sudo fuser -k 8000/tcp - Permission denied: Check user permissions and file ownership
- Service won't start: Check logs with
sudo journalctl -u thywill - External access blocked: Verify firewall and cloud provider security groups