This repository contains the backend server for the FamilyNestWeb application. It is built with Flask and integrates deeply with Supabase for database management, authentication, and file storage.
- User Management: Secure user registration and login handled by Supabase Auth.
- Tree Management: Create, delete, and manage multiple family trees per user.
- Collaboration:
- Share trees with other users via email with role-based permissions (owner, editor, viewer).
- Generate secure, time-limited, and usage-capped invitation links.
- Data Operations: Atomic batch updates for person data (add, modify, delete) using a PostgreSQL function to prevent race conditions with optimistic locking (versioning).
- Secure File Handling:
- Upload images and documents to a private Supabase Storage bucket.
- On-the-fly image compression and optimization.
- Serve files securely using temporary signed URLs.
- Multi-language Support: Built-in translation system to support multiple languages.
- Backend: Flask
- Database & Auth: Supabase (Supabase API)
- Python Libraries:
Flask-Minifyfor minifying HTML, CSS, and JS.Flask-Compressfor GZip compression.Flask-Talismanfor enforcing HTTPS and Content Security Policy.Flask-WTFfor Flask-WTF forms and CSRF protection.supabase-pyfor Supabase interaction.Pillowfor image processing.python-dotenvfor environment variable management.
Here's an overview of the key files and directories in this project:
main.py: The entry point for the Flask application.fromdist.py: A utility script designed to automate the process of updating the FamilyNest front-end. It takes the compiled output fromtrunk(thedistdirectory), reorganizes files, updates asset paths, and merges new translations, simplifying version migrations.app/: This directory contains the core application logic, organized into blueprints for better modularity.sql/: This directory contains all the necessary SQL scripts to set up the Supabase database. This includes table creation (trees,persons, etc.) and the definitions of PostgreSQL functions used by the application (e.g., for batch operations).static/: Contains all static assets for both the FamilyNest interface and the server's own pages. This includes CSS, JavaScript, images, and locale files for translations.internal/: Holds static files that are specific to this server implementation (like custom styles or scripts for the home page). This separation makes it easier to update the core FamilyNest front-end without overwriting custom modifications. Thefromdist.pyscript handles merging these files during an update.templates/: This directory holds the HTML templates rendered by Flask.tree.html: The main single-page application for the FamilyNest editor. It's the entry point for the family tree interface.- Other
.htmlfiles: These are the templates for the server's own pages, such as the landing page, login, user dashboard (home.html), etc.
- Python 3.8+
- A Supabase account (you can create one here)
-
Clone the repository:
git clone https://github.com/PaulExplorer/FamilyNestWebSupabase.git cd FamilyNestWebSupabase -
Create and activate a virtual environment:
python -m venv venv # On Windows .\venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your Supabase project:
- Create a new project on the Supabase Dashboard.
- Go to the SQL Editor in your project dashboard.
- Run all the SQL queries located in the
sql/directory of this repository. This will create the necessary tables (trees,persons,tree_invitations) and database functions. - Go to Storage and create a new private bucket named
tree_files.
-
Configure environment variables:
- Create a
.envfile in the root of the project by copying the example:cp .env.example .env
- Fill in the
.envfile with your Supabase project URL andanonkey. You can find these in your Supabase project's "API" settings.SUPABASE_URL="YOUR_SUPABASE_URL" SUPABASE_KEY="YOUR_SUPABASE_ANON_KEY" FLASK_SECRET_KEY="a-strong-and-random-secret-key" DEMO_TREE_ID="YOUR_DEMO_TREE_ID" # should be a public tree and in demo mode SUPPORT_EMAIL="your.email@support.com" ENV="development" # or production
- Create a
-
Start the server:
python main.py
Contributions are welcome! Please feel free to submit a Pull Request or open an issue for any bugs or feature requests.
This project is licensed under the AGPLv3 License.