Add project scaffolding and documentation

Add .env.example with configuration for database, Redis, security, SMTP, workers, and plugins. Add .gitignore for Python, Node.js, Next.js, Docker volumes, and IDE files. Add MIT License. Update README.md with feature overview, quick start guide, architecture description, plugin system documentation, security details, backup/restore instructions, and developer setup. Add Alembic configuration files and placeholder directories for API, web, worker, and plugin components
This commit is contained in:
2026-06-21 09:31:47 +02:00
parent cfeeccbf53
commit d694c8b8e3
197 changed files with 8583 additions and 56 deletions
@@ -0,0 +1,371 @@
"""initial
Revision ID: 20240620_0001
Revises:
Create Date: 2024-06-20 00:00:00
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = "20240620_0001"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"roles",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("name", sa.String(length=50), nullable=False),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("is_system", sa.Boolean(), nullable=False),
sa.Column("permissions", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name"),
)
op.create_table(
"system_settings",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("key", sa.String(length=100), nullable=False),
sa.Column("value", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("is_sensitive", sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("key"),
)
op.create_table(
"users",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("email", sa.String(length=255), nullable=False),
sa.Column("hashed_password", sa.String(length=255), nullable=False),
sa.Column("first_name", sa.String(length=100), nullable=True),
sa.Column("last_name", sa.String(length=100), nullable=True),
sa.Column("avatar_url", sa.String(length=500), nullable=True),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("is_superuser", sa.Boolean(), nullable=False),
sa.Column("is_owner", sa.Boolean(), nullable=False),
sa.Column("email_verified", sa.Boolean(), nullable=False),
sa.Column("locale", sa.String(length=10), nullable=False),
sa.Column("theme", sa.String(length=20), nullable=False),
sa.Column("timezone", sa.String(length=50), nullable=False),
sa.Column("last_login_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("last_login_ip", sa.String(length=45), nullable=True),
sa.Column("login_attempts", sa.Integer(), nullable=False),
sa.Column("locked_until", sa.DateTime(timezone=True), nullable=True),
sa.Column("invite_token", sa.String(length=255), nullable=True),
sa.Column("invite_token_expires", sa.DateTime(timezone=True), nullable=True),
sa.Column("password_reset_token", sa.String(length=255), nullable=True),
sa.Column("password_reset_expires", sa.DateTime(timezone=True), nullable=True),
sa.Column("preferences", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("role_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(["role_id"], ["roles.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("email"),
)
op.create_index("ix_users_email", "users", ["email"], unique=False)
op.create_index("ix_users_invite_token", "users", ["invite_token"], unique=False)
op.create_index("ix_users_password_reset_token", "users", ["password_reset_token"], unique=False)
op.create_index("ix_users_role_id", "users", ["role_id"], unique=False)
op.create_table(
"api_tokens",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("name", sa.String(length=100), nullable=False),
sa.Column("token_hash", sa.String(length=255), nullable=False),
sa.Column("last_used_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("last_used_ip", sa.String(length=45), nullable=True),
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("scopes", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("token_hash"),
)
op.create_index("ix_api_tokens_user_id", "api_tokens", ["user_id"], unique=False)
op.create_table(
"audit_logs",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("action", sa.String(length=100), nullable=False),
sa.Column("resource_type", sa.String(length=100), nullable=False),
sa.Column("resource_id", sa.String(length=100), nullable=True),
sa.Column("ip_address", sa.String(length=45), nullable=True),
sa.Column("user_agent", sa.Text(), nullable=True),
sa.Column("details", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("severity", sa.String(length=20), nullable=False),
sa.Column("timestamp", sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_audit_logs_action", "audit_logs", ["action"], unique=False)
op.create_index("ix_audit_logs_user_id", "audit_logs", ["user_id"], unique=False)
op.create_table(
"encrypted_secrets",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("name", sa.String(length=200), nullable=False),
sa.Column("owner_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("encrypted_value", sa.Text(), nullable=False),
sa.Column("secret_type", sa.String(length=50), nullable=False),
sa.Column("scope", sa.String(length=100), nullable=False),
sa.Column("metadata", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.ForeignKeyConstraint(["owner_id"], ["users.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_encrypted_secrets_owner_id", "encrypted_secrets", ["owner_id"], unique=False)
op.create_table(
"notifications",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("title", sa.String(length=200), nullable=False),
sa.Column("message", sa.Text(), nullable=True),
sa.Column("type", sa.String(length=50), nullable=False),
sa.Column("is_read", sa.Boolean(), nullable=False),
sa.Column("link", sa.String(length=500), nullable=True),
sa.Column("metadata", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("read_at", sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_notifications_user_id", "notifications", ["user_id"], unique=False)
op.create_table(
"sessions",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("refresh_token_hash", sa.String(length=255), nullable=False),
sa.Column("user_agent", sa.Text(), nullable=True),
sa.Column("ip_address", sa.String(length=45), nullable=True),
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("is_valid", sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("refresh_token_hash"),
)
op.create_index("ix_sessions_user_id", "sessions", ["user_id"], unique=False)
op.create_table(
"plugins",
sa.Column("id", sa.String(length=100), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("name", sa.String(length=200), nullable=False),
sa.Column("version", sa.String(length=50), nullable=False),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("author", sa.String(length=200), nullable=True),
sa.Column("category", sa.String(length=100), nullable=False),
sa.Column("icon", sa.String(length=100), nullable=True),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("is_builtin", sa.Boolean(), nullable=False),
sa.Column("is_installed", sa.Boolean(), nullable=False),
sa.Column("path", sa.String(length=500), nullable=False),
sa.Column("permissions", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("settings_schema", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("credentials_schema", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("widget_types", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("healthcheck_definition", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("api_routes", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("has_frontend", sa.Boolean(), nullable=False),
sa.Column("manifest", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"dashboards",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("title", sa.String(length=200), nullable=False),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("icon", sa.String(length=50), nullable=True),
sa.Column("folder", sa.String(length=100), nullable=False),
sa.Column("is_favorite", sa.Boolean(), nullable=False),
sa.Column("is_public", sa.Boolean(), nullable=False),
sa.Column("owner_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("layout", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("layouts_by_breakpoint", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("refresh_interval_seconds", sa.Integer(), nullable=True),
sa.Column("order_index", sa.Integer(), nullable=False),
sa.Column("tags", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.ForeignKeyConstraint(["owner_id"], ["users.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_dashboards_folder", "dashboards", ["folder"], unique=False)
op.create_index("ix_dashboards_owner_id", "dashboards", ["owner_id"], unique=False)
op.create_table(
"plugin_versions",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("plugin_id", sa.String(length=100), nullable=False),
sa.Column("version", sa.String(length=50), nullable=False),
sa.Column("changelog", sa.String(), nullable=True),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("package_path", sa.String(length=500), nullable=True),
sa.Column("manifest", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.ForeignKeyConstraint(["plugin_id"], ["plugins.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_plugin_versions_plugin_id", "plugin_versions", ["plugin_id"], unique=False)
op.create_table(
"service_connections",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("name", sa.String(length=200), nullable=False),
sa.Column("plugin_id", sa.String(length=100), nullable=False),
sa.Column("base_url", sa.String(length=500), nullable=False),
sa.Column("verify_tls", sa.Boolean(), nullable=False),
sa.Column("timeout_seconds", sa.Integer(), nullable=False),
sa.Column("credentials_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("is_enabled", sa.Boolean(), nullable=False),
sa.Column("health_status", sa.String(length=20), nullable=False),
sa.Column("health_message", sa.Text(), nullable=True),
sa.Column("extra_headers", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.ForeignKeyConstraint(["credentials_id"], ["encrypted_secrets.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(["plugin_id"], ["plugins.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_service_connections_credentials_id", "service_connections", ["credentials_id"], unique=False)
op.create_index("ix_service_connections_plugin_id", "service_connections", ["plugin_id"], unique=False)
op.create_table(
"plugin_instances",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("plugin_id", sa.String(length=100), nullable=False),
sa.Column("service_connection_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("name", sa.String(length=200), nullable=False),
sa.Column("settings", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("is_enabled", sa.Boolean(), nullable=False),
sa.Column("health_status", sa.String(length=20), nullable=False),
sa.Column("health_message", sa.Text(), nullable=True),
sa.Column("last_sync_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("last_error", sa.Text(), nullable=True),
sa.Column("error_count", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(["plugin_id"], ["plugins.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(["service_connection_id"], ["service_connections.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_plugin_instances_plugin_id", "plugin_instances", ["plugin_id"], unique=False)
op.create_index("ix_plugin_instances_service_connection_id", "plugin_instances", ["service_connection_id"], unique=False)
op.create_table(
"background_jobs",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("task_name", sa.String(length=100), nullable=False),
sa.Column("status", sa.String(length=20), nullable=False),
sa.Column("payload", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("result", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("error", sa.Text(), nullable=True),
sa.Column("scheduled_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("started_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("finished_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("worker_id", sa.String(length=100), nullable=True),
sa.Column("plugin_id", sa.String(length=100), nullable=True),
sa.Column("instance_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(["instance_id"], ["plugin_instances.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_background_jobs_instance_id", "background_jobs", ["instance_id"], unique=False)
op.create_index("ix_background_jobs_plugin_id", "background_jobs", ["plugin_id"], unique=False)
op.create_table(
"dashboard_widgets",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("dashboard_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("plugin_id", sa.String(length=100), nullable=False),
sa.Column("widget_type", sa.String(length=100), nullable=False),
sa.Column("title", sa.String(length=200), nullable=False),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("position_x", sa.Integer(), nullable=False),
sa.Column("position_y", sa.Integer(), nullable=False),
sa.Column("width", sa.Integer(), nullable=False),
sa.Column("height", sa.Integer(), nullable=False),
sa.Column("min_width", sa.Integer(), nullable=True),
sa.Column("min_height", sa.Integer(), nullable=True),
sa.Column("max_width", sa.Integer(), nullable=True),
sa.Column("max_height", sa.Integer(), nullable=True),
sa.Column("order_index", sa.Integer(), nullable=False),
sa.Column("settings", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("instance_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("is_visible", sa.Boolean(), nullable=False),
sa.Column("is_static", sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(["dashboard_id"], ["dashboards.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(["instance_id"], ["plugin_instances.id"], ondelete="SET NULL"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_dashboard_widgets_dashboard_id", "dashboard_widgets", ["dashboard_id"], unique=False)
op.create_index("ix_dashboard_widgets_instance_id", "dashboard_widgets", ["instance_id"], unique=False)
op.create_index("ix_dashboard_widgets_plugin_id", "dashboard_widgets", ["plugin_id"], unique=False)
op.create_table(
"plugin_logs",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.Column("plugin_id", sa.String(length=100), nullable=False),
sa.Column("instance_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("level", sa.String(length=20), nullable=False),
sa.Column("message", sa.Text(), nullable=False),
sa.Column("context", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("timestamp", sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(["instance_id"], ["plugin_instances.id"], ondelete="SET NULL"),
sa.ForeignKeyConstraint(["plugin_id"], ["plugins.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_plugin_logs_instance_id", "plugin_logs", ["instance_id"], unique=False)
op.create_index("ix_plugin_logs_plugin_id", "plugin_logs", ["plugin_id"], unique=False)
def downgrade() -> None:
op.drop_table("plugin_logs")
op.drop_table("dashboard_widgets")
op.drop_table("background_jobs")
op.drop_table("plugin_instances")
op.drop_table("service_connections")
op.drop_table("plugin_versions")
op.drop_table("dashboards")
op.drop_table("plugins")
op.drop_table("sessions")
op.drop_table("notifications")
op.drop_table("encrypted_secrets")
op.drop_table("audit_logs")
op.drop_table("api_tokens")
op.drop_table("users")
op.drop_table("system_settings")
op.drop_table("roles")