Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ALwrity ALwrity OnboardingProgressService

From Leeroopedia
Knowledge Sources
Domains Onboarding, Database
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for persisting and resetting a user's onboarding progress in the per-tenant SQLite database provided by the ALwrity onboarding subsystem.

Description

The OnboardingProgressService class wraps the database operations that back the onboarding state machine. It reads the OnboardingSession row for a user (get_onboarding_status, get_completion_data), updates the progress percentage and current step as the user advances, marks onboarding complete (complete_onboarding), and supports both soft and hard reset. A hard reset deletes the session row (which cascades to website analyses, API keys, research preferences, persona data, competitor analyses, and platform integrations) plus all DB-backed scheduled monitoring tasks. A soft reset resets the step counter to 0 and pauses scheduled tasks without deleting artefacts.

Usage

Import this class when:

  • The onboarding initialisation endpoint needs to load or reconcile a user's state.
  • An endpoint completes a step and must update the progress percentage.
  • An admin or user requests an onboarding reset (soft or hard).
  • The system needs to mark onboarding complete after the final step.

Code Reference

Source Location

  • Repository: ALwrity
  • File: backend/services/onboarding/progress_service.py (L17-300)

Signature

class OnboardingProgressService:
    """Service for managing onboarding progress in the database."""

    def get_onboarding_status(self, user_id: str) -> Dict[str, Any]:
        """Return is_completed, current_step, completion_percentage, timestamps."""

    def get_completion_data(self, user_id: str) -> Dict[str, Any]:
        """Return all onboarding artefacts (api_keys, website_analysis, etc.)."""

    def update_progress(self, user_id: str, progress_percentage: float) -> bool:
        """Update the progress percentage for a user."""

    def complete_onboarding(self, user_id: str) -> bool:
        """Mark onboarding as complete (progress=100.0, current_step=6)."""

    def reset_onboarding(self, user_id: str, hard: bool = False) -> bool:
        """Reset onboarding. hard=True deletes all artefacts; hard=False resets step counter."""

Import

from services.onboarding.progress_service import OnboardingProgressService

I/O Contract

Inputs

Name Type Required Description
user_id str Yes Clerk user ID
progress_percentage float Yes (update) 0.0–100.0
hard bool No (reset) True deletes all artefacts; False (default) resets counter

Outputs

Name Type Description
get_onboarding_status Dict[str, Any] is_completed, current_step, completion_percentage, started_at, last_updated, completed_at
get_completion_data Dict[str, Any] api_keys, website_analysis, research_preferences, persona_data
side effect DB Mutates OnboardingSession row and (hard reset) cascades to artefacts and scheduled tasks

Usage Examples

Loading status and finding the next step

from services.onboarding.progress_service import OnboardingProgressService

service = OnboardingProgressService()
status = service.get_onboarding_status("clerk_user_123")
print(f"Step {status['current_step']}/6, {status['completion_percentage']}% complete")

Completing onboarding after the final step

service = OnboardingProgressService()
ok = service.complete_onboarding("clerk_user_123")
assert ok is True

Hard reset (delete all onboarding data)

service = OnboardingProgressService()
service.reset_onboarding("clerk_user_123", hard=True)
# All artefacts and scheduled monitoring tasks are deleted.

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment