n8n Workflows Collection

repository·main·Indexed 13 days ago

https://github.com/zie619/n8n-workflows

A collection of over 4,300 production-ready n8n automation workflows and 365+ integrations, featuring a high-performance FastAPI and SQLite FTS5 backend for searching and retrieving workflow JSON files.

Tokens
46.9K
Snippets
124
Records
209
Agent score
97%

What's inside n8n-workflows

  1. MEDCARDS.AI Product Overview and Core Experiences

    main

    MEDCARDS.AI is an AI-powered adaptive learning platform designed for medical students. It functions as an intelligent study companion rather than a traditional course platform. The product is built around three primary user experiences:

    1. Battle Dashboard: Provides real-time clinical competency metrics (e.g., "can you diagnose AVC at 85% accuracy?") and gamified progression through specialty mastery levels.
    2. Training Arena: Features adaptive case selection where AI picks the optimal next case, provides immediate feedback on clinical reasoning, and includes graduated hints.
    3. War Room: A personal AI tutor with complete memory of the student's journey, providing data-driven advice, motivational coaching, and conversational learning.

    Key features include real-time adaptation to student weaknesses, personalized AI coaching (powered by Claude), study group connections, and community-contributed content.

  2. MEDCARDS.AI Project Structure

    main

    The project follows a Next.js 14 App Router structure:

    • src/app/: Next.js App Router (auth, dashboard, arena, war-room).
    • src/components/: React components (UI, dashboard, arena, shared).
    • src/lib/: Core business logic:
      • ai/: Claude AI integration (claude.ts).
      • supabase/: Database utilities (client.ts).
      • adaptive/: Adaptive engine logic.
      • gamification/: Badges and progression.
    • supabase/: Database assets (schema.sql, seed-cases.sql, migrations/).
    • prompts/: Markdown files containing specialized AI instructions for the Coach, Feedback, and Tutor systems.
  3. How the Adaptive Engine works

    main

    The Adaptive Engine (located in src/lib/adaptive/engine.ts) selects the optimal next clinical case for each student to maximize learning efficiency.

    The Algorithm Logic:

    1. Competency Calculation: Calculates competency by medical specialty, weighted by recency.
    2. Gap Identification: Identifies specialties where the success_rate is < 65%.
    3. Case Selection Strategy:
      • 60%: Address critical gaps (low success rate).
      • 30%: Reinforce existing strengths.
      • 10%: Explore new areas.
    4. AI Validation: Claude AI validates the selection and prepares specific coaching instructions.
  4. Scale database via User ID Sharding

    main

    When reaching the Scale stage (100k-1M users), implement database sharding by hashing the userId. This distributes the load across multiple Supabase/PostgreSQL instances. Use a routing function to determine which shard connection to use for a given user request.

    // Routing logic
    function getShardForUser(userId: string): number {
      const hash = hashUserId(userId);
      return hash % 4;
    }
    
    const shardConnections = {
      0: createSupabaseClient(SHARD_0_URL),
      1: createSupabaseClient(SHARD_1_URL),
      2: createSupabaseClient(SHARD_2_URL),
      3: createSupabaseClient(SHARD_3_URL),
    };
    
    export function getDbForUser(userId: string) {
      const shard = getShardForUser(userId);
      return shardConnections[shard];
    }
  5. Implement a multi-tier AI response strategy

    main

    To prevent linear cost scaling with the Claude API, implement a three-tier retrieval strategy:

    1. Tier 1 (Pre-computed): Check the database for pre-calculated responses for common case/answer combinations. This is instant and free.
    2. Tier 2 (Cached): Check Redis for recently generated responses. This is fast and cheap.
    3. Tier 3 (Real-time): Call the Claude API only for rare combinations or premium users. Cache the result in Redis immediately after generation.
    // Tier 1: Pre-computed (DB)
    const precomputedFeedback = await db
      .from('precomputed_feedback')
      .select('*')
      .eq('case_id', caseId)
      .eq('selected_answer', answerId)
      .single();
    
    if (precomputedFeedback) return precomputedFeedback;
    
    // Tier 2: Cached (Redis)
    const cached = await redis.get(`feedback:${caseId}:${answerId}`);
    if (cached) return JSON.parse(cached);
    
    // Tier 3: Real-time (Claude API)
    const feedback = await generateWithClaude(context);
    await redis.setex(`feedback:${caseId}:${answerId}`, 86400, JSON.stringify(feedback));
    return feedback;
  6. Template structure and components

    main

    Each template in this repository is organized into a specific structure to ensure ease of deployment. When exploring a template folder, you will find:

    • Template File: The core n8n workflow exported as a JSON file.
    • Documentation: Specific setup instructions and customization guides.
    • Configuration: Details on required environment variables and credentials.
    • Examples: Real-world usage scenarios to guide implementation.
    • Customization Guide: Instructions on how to modify the workflow for specific needs.
  7. Analyze the AI Tutor Input Context Schema

    main

    The AI Tutor receives a structured JSON context object to inform its responses. This context is critical for personalization and includes the following key sections:

    • student_profile: Contains user_id, name, study_goal, days_until_exam, total_study_days, and current_streak.
    • performance_summary: Provides overall_stats (total cases, success rate, etc.), a specialty_breakdown (attempts, success rate, and trends per specialty), and weak_areas (specific clinical algorithms with failure rates).
    • recent_cases: A list of recent attempts including timestamp, case_title, specialty, is_correct, time_seconds, student_reasoning, and ai_feedback_summary.
    • chat_history: Previous messages between the user and assistant.
    • current_message: The latest input from the student.
    • session_context: Real-time metadata like time_of_day, cases_today, and energy_level.
    {
      "student_profile": {
        "user_id": "uuid",
        "name": "João",
        "study_goal": "Aprovação em residência de Clínica Médica 2025",
        "days_until_exam": 87,
        "total_study_days": 45,
        "current_streak": 8
      },
      "performance_summary": {
        "overall_stats": {
          "total_cases": 234,
          "success_rate": 0.71,
          "avg_time_per_case": 185,
          "study_hours_total": 18.5
        },
        "specialty_breakdown": [
          {
            "specialty": "cardiologia",
            "attempts": 67,
            "success_rate": 0.78,
            "trend": "stable",
            "last_practiced": "2024-01-25T10:30:00Z"
          }
        ],
        "weak_areas": [
          {
            "clinical_algorithm": "Diagnóstico diferencial de cefaleia",
            "attempts": 8,
            "success_rate": 0.375,
            "last_error": "2024-01-24T15:20:00Z"
          }
        ]
      }
    }
  8. How the AI Coach System works

    main

    The AI Coach system uses three specialized prompts integrated via src/lib/ai/claude.ts to provide a multi-layered learning experience:

    1. Coach Prompt (prompts/coach-prompt.md):

      • Analyzes student history.
      • Selects the optimal next case.
      • Prepares graduated hints.
      • Returns structured JSON.
    2. Feedback Prompt (prompts/feedback-prompt.md):

      • Analyzes the student's specific answer.
      • Identifies reasoning gaps.
      • Provides detailed clinical explanations.
      • Suggests next practice steps.
    3. Tutor Prompt (prompts/tutor-prompt.md):

      • Provides conversational coaching.
      • Maintains complete memory of the student's journey.
      • Offers data-driven advice and motivational support.
  9. Decision-Making Strategy for Case Selection

    main

    The AI Coach uses a weighted strategy to select the next clinical case:

    1. Identify Critical Gaps (60% weight): Targets specialties with success_rate < 0.65, recurring errors in clinical algorithms, or recent wrong answers (last 7 days). High priority is given to neurologia, pneumologia, and infectologia.
    2. Reinforce Strengths (30% weight): Targets specialties with success_rate between 0.75 and 0.90 to prevent knowledge decay and build confidence.
    3. Explore New Territory (10% weight): Introduces variety by selecting specialties with < 10 attempts to prevent burnout.
    4. Session Context Optimization:
      • If time_available_minutes < 10: Select easier cases (difficulty 1-2).
      • If current_streak >= 5: Select harder cases (difficulty 4-5).
      • If cases_today > 15: Enter intensive mode (prioritize weak areas only).
  10. Configure the AI Tutor Tone and Personality

    main

    To ensure consistent interaction, the AI Tutor must adhere to specific personality traits and language styles:

    Personality Traits:

    • Direct: No fluff; get straight to the point.
    • Motivating: Honest about struggles but always forward-looking.
    • Data-driven: Uses actual student statistics rather than generic encouragement.
    • Clinical: Speaks like a doctor/peer, not a professor.
    • Peer-level: Acts as a senior resident.

    Language Guidelines:

    • DO USE: "Vamos olhar os dados...", "Você errou isso no caso X...", "Faz sentido agora?", "Pegadinha clássica de prova:".
    • AVOID: Overly formal academic language (e.g., "Conforme podemos observar..."), generic advice (e.g., "Estude mais"), or empty encouragement (e.g., "Você consegue!").
  11. MEDCARDS.AI Network Effects and Moats

    main

    The platform's defensibility is built on four primary network effects:

    1. Data Network Effect: Every student interaction trains the AI. As user volume increases, prediction accuracy for case difficulty, next-case selection, and success prediction improves (targeting ~95% accuracy at 100k users).
    2. Content Network Effect: A flywheel where more users lead to more community-contributed cases, creating a large, validated clinical case library in Portuguese.
    3. Social Network Effect: Study groups, leaderboards, and peer challenges create high switching costs as students' social graphs and progress history become embedded in the platform.
    4. Marketplace Network Effect: A two-sided marketplace connecting students and educators. More students attract more educators, which in turn provides more quality content to attract more students.
  12. MEDCARDS.AI Business and Revenue Models

    main

    The platform utilizes a progressive revenue strategy moving from individual SaaS to B2B and Marketplace models:

    Phase 1: Freemium

    • Free: 5 cases/day
    • Premium: $29/month (R$149) - Includes unlimited cases, AI tutor, and study groups.

    Phase 2: Tiered SaaS

    • Free: 5 cases/day
    • Basic: $19/month - 20 cases/day + groups
    • Pro: $39/month - Unlimited + AI tutor + analytics
    • Elite: $79/month - Everything + 1-on-1 mentors + priority

    Phase 3: B2B SaaS (Medical School Plans)

    • 100 students: $999/month
    • Unlimited: $4,999/month
    • White-label: Custom pricing

    Phase 4: Marketplace & API

    • Marketplace: 30% commission on content sales (Educators keep 70%)
    • API Licensing: $0.10 per AI inference to third-party platforms.