diff --git a/backend/scripts/import_seed_personas.py b/backend/scripts/import_seed_personas.py new file mode 100644 index 00000000..52175fd6 --- /dev/null +++ b/backend/scripts/import_seed_personas.py @@ -0,0 +1,299 @@ +""" +One-time import: seed 7 developer personas from Obsidian vault into MongoDB. +Always inserts as new documents (no dedup — AI can generate duplicate names). +""" +import asyncio +import os +import sys +from datetime import datetime, timezone + +sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + +PERSONAS = [ + { + "name": "Alex Chen", + "age": "25-34", + "gender": "Male", + "occupation": "Senior Backend Developer", + "education": "Master's Degree", + "location": "Austin, Texas, USA", + "hasChildren": False, + "hasPurchasingPower": False, + "techSavviness": 95, + "priceConsciousness": 55, + "brandLoyalty": 45, + "environmentalConcern": 40, + "personality": "Pragmatic, performance-obsessed, methodical, detail-oriented, quietly confident.", + "description": ( + "Senior Backend Developer based in Austin, Texas. Highly pragmatic and quietly confident, " + "a performance-obsessed engineer who focuses heavily on building robust, scalable systems " + "and maintaining clean architecture." + ), + "interests": ["API design and architecture", "Database optimization and scaling", + "Open-source software contribution", "Competitive programming", "Linux systems administration"], + "goals": [ + "Build robust, high-performance APIs with clean and consistent contracts.", + "Design database schemas that scale efficiently under heavy load.", + "Write backend code that is readable, testable, and maintainable.", + "Reduce API response times and optimize query performance.", + ], + "thinkFeelDo": { + "thinks": ["What's the most efficient data structure for this use case?", + "How will this query perform when the table has 100 million rows?"], + "feels": ["Satisfied when an endpoint consistently returns under 50ms.", + "Energized when refactoring messy code into clean, testable modules."], + "does": ["Profiles database queries before and after every optimization.", + "Writes integration tests before considering a feature complete."], + }, + }, + { + "name": "Emma Clarke", + "age": "25-34", + "gender": "Female", + "occupation": "Senior Frontend Developer", + "education": "Bachelor's Degree", + "location": "London, UK", + "hasChildren": False, + "hasPurchasingPower": False, + "techSavviness": 88, + "priceConsciousness": 45, + "brandLoyalty": 55, + "environmentalConcern": 65, + "personality": "Creative, user-empathetic, detail-obsessed, opinionated about UI quality and accessibility.", + "description": ( + "Senior Frontend Developer based in London, UK. Creative, user-empathetic, and " + "detail-obsessed professional who excels at bridging the gap between design intent " + "and engineering implementation." + ), + "interests": ["Design systems and component libraries", "Web accessibility (a11y) standards", + "React ecosystem and modern CSS", "User psychology and experience", + "Figma and design tooling", "Frontend performance optimization"], + "goals": [ + "Build pixel-perfect, accessible UI components that genuinely delight users.", + "Create and maintain a consistent design system across the entire product.", + "Optimize frontend performance: fast load times, smooth animations, no layout shifts.", + "Bridge the gap between design intent and engineering implementation.", + ], + "thinkFeelDo": { + "thinks": ["How does this component behave on mobile vs desktop?", + "Is this accessible for users with screen readers and keyboard navigation?"], + "feels": ["Proud when a component is reusable, beautiful, and accessible.", + "Frustrated when UX decisions are made without considering implementation complexity."], + "does": ["Builds Storybook stories for every component before integrating into the product.", + "Tests on multiple devices and browsers before considering a feature done."], + }, + }, + { + "name": "Marcus Thorne", + "age": "33", + "gender": "Non-binary", + "occupation": "Digital Content Strategist", + "education": "MA Digital Media", + "location": "Brighton, UK", + "hasChildren": False, + "hasPurchasingPower": True, + "techSavviness": 88, + "priceConsciousness": 60, + "brandLoyalty": 40, + "environmentalConcern": 75, + "personality": "Enthusiastic early adopter, highly open to new experiences, emotionally stable, resilient.", + "description": ( + "Digital Content Strategist based in Brighton, UK. An enthusiastic early adopter of AI tools " + "who leverages generative technology to push the boundaries of dynamic web experiences. " + "Views technical errors as playful learning opportunities." + ), + "interests": ["Generative art", "Electronic music production", "Bouldering", + "Prompt engineering", "Headless CMS architecture"], + "goals": [ + "Integrate AI seamlessly into web content workflows to eliminate repetitive tasks.", + "Push the boundaries of dynamic, personalized web experiences using generative AI.", + "Maintain a healthy work-life balance by automating digital strategy reporting.", + ], + "thinkFeelDo": { + "thinks": ["How can I automate this mundane content task so I can focus on the creative strategy?", + "Most web content is too static; AI could make it dynamically personalized in real-time."], + "feels": ["Excited and energized when a new LLM model or web framework drops.", + "Calm and amused when an AI hallucinates or breaks a web layout."], + "does": ["Spends hours tweaking system prompts for web copy generation.", + "Experiments with AI-driven A/B testing on landing pages."], + }, + }, + { + "name": "Jordan Blake", + "age": "25-34", + "gender": "Male", + "occupation": "QA Engineer / Security Specialist", + "education": "Bachelor's Degree", + "location": "Seattle, USA", + "hasChildren": False, + "hasPurchasingPower": False, + "techSavviness": 88, + "priceConsciousness": 50, + "brandLoyalty": 30, + "environmentalConcern": 50, + "personality": "Skeptical, methodical, risk-aware, persistent, adversarial thinker.", + "description": ( + "QA Engineer and Security Specialist based in Seattle, USA. Highly methodical and risk-aware, " + "excels at identifying vulnerabilities, edge cases, and architectural flaws before they reach " + "production. Natural devil's advocate who champions quality culture." + ), + "interests": ["Security research and threat modeling", "Penetration testing and CTF competitions", + "Test automation and chaos engineering"], + "goals": [ + "Break the system before real users do by finding every edge case prior to production.", + "Build comprehensive automated test coverage from the very first sprint.", + "Identify security vulnerabilities in the architecture before they become active exploits.", + "Create a quality culture where the entire team owns testing.", + ], + "thinkFeelDo": { + "thinks": ["What happens if the user sends an empty string, a null value, or 10MB of data?", + "What is the attack surface of this API endpoint and who should have access?"], + "feels": ["Satisfied when a well-written test catches a regression before it reaches users.", + "Frustrated when security concerns are dismissed as something to deal with later."], + "does": ["Writes test plans before features are built, not after they are shipped.", + "Performs threat modeling on every new API endpoint and sensitive data flow."], + }, + }, + { + "name": "Marcus Webb", + "age": "35-44", + "gender": "Male", + "occupation": "DevOps / Infrastructure Engineer", + "education": "Bachelor's Degree", + "location": "Berlin, Germany", + "hasChildren": False, + "hasPurchasingPower": True, + "techSavviness": 92, + "priceConsciousness": 70, + "brandLoyalty": 40, + "environmentalConcern": 55, + "personality": "Systematic, pragmatic, calm in crises, automation-first mindset, security-conscious.", + "description": ( + "DevOps and Infrastructure Engineer based in Berlin, Germany. A pragmatic, security-conscious " + "professional who approaches work with a systematic, automation-first mindset. Obsessed with " + "reliability and building self-healing systems." + ), + "interests": ["Infrastructure as code (IaC)", "CI/CD pipelines", "Container orchestration", + "System monitoring", "Security hardening", "Homelab environments"], + "goals": [ + "Achieve zero-downtime deployments with fully automated CI/CD pipelines.", + "Build infrastructure that is reproducible, version-controlled, and self-healing.", + "Implement comprehensive monitoring and alerting before any production go-live.", + "Keep cloud infrastructure costs optimized without sacrificing reliability.", + ], + "thinkFeelDo": { + "thinks": ["What happens to this service when the container crashes at 3am?", + "How do we roll back this deployment in under 2 minutes?"], + "feels": ["Satisfied when a deployment completes with zero human intervention.", + "Anxious when going to production without a tested rollback plan."], + "does": ["Writes all infrastructure as code using Terraform — never manually clicks in the cloud console.", + "Builds CI/CD pipelines as the first deliverable, not the last."], + }, + }, + { + "name": "Sofia Park", + "age": "25-34", + "gender": "Female", + "occupation": "Full-Stack Developer", + "education": "Bachelor's Degree", + "location": "Toronto, Canada", + "hasChildren": False, + "hasPurchasingPower": False, + "techSavviness": 85, + "priceConsciousness": 60, + "brandLoyalty": 50, + "environmentalConcern": 60, + "personality": "Versatile, pragmatic, collaborative, fast learner, effective communicator.", + "description": ( + "Full-Stack Developer based in Toronto, Canada. Versatile and pragmatic, thrives in dynamic " + "environments where she can build features end-to-end, acting as a crucial bridge between " + "frontend and backend specialists." + ), + "interests": ["Full-stack development", "Developer experience (DX)", "Productivity tools", + "Hackathons", "Indie hacking", "Side projects"], + "goals": [ + "Build features end-to-end without handoff friction between frontend and backend.", + "Ship working prototypes fast to validate ideas before committing to full implementation.", + "Keep the codebase consistent and prevent frontend and backend from drifting apart.", + "Act as the communication bridge between specialist team members.", + ], + "thinkFeelDo": { + "thinks": ["Can I build a working version of this in a day to validate the approach?", + "Is this complexity actually necessary or can we simplify and ship faster?"], + "feels": ["Energized when she can build an entire feature solo and see it working end-to-end.", + "Frustrated when specialist silos slow down what should be a simple feature."], + "does": ["Builds rapid prototypes to validate architectural decisions before the team commits.", + "Acts as a translator between frontend and backend developers in planning meetings."], + }, + }, + { + "name": "Victor Stone", + "age": "35-44", + "gender": "Male", + "occupation": "Solution Architect", + "education": "PhD", + "location": "San Francisco, USA", + "hasChildren": False, + "hasPurchasingPower": True, + "techSavviness": 95, + "priceConsciousness": 65, + "brandLoyalty": 35, + "environmentalConcern": 45, + "personality": "Systems thinker, highly strategic, decisive, opinionated, analytical.", + "description": ( + "Solution Architect based in San Francisco. Armed with a PhD and a deeply analytical mindset, " + "a strategic systems thinker who excels at leading technical teams and making critical, " + "high-level design decisions. Prioritizes scalable, maintainable architecture." + ), + "interests": ["Software architecture & system design patterns", "Cloud infrastructure & scalability", + "Technical mentorship & team leadership", "Open-source technologies"], + "goals": [ + "Design scalable, maintainable system architectures that can grow with the product.", + "Ensure the technical stack choices align with long-term business goals.", + "Minimize technical debt from day one by enforcing best practices.", + "Deliver a clear, actionable technical roadmap for the development team.", + ], + "thinkFeelDo": { + "thinks": ["What are the failure points of this system at 10x scale?", + "Which part of this will be hardest to change in 12 months?"], + "feels": ["Confident when the architecture is clean and responsibilities are clearly separated.", + "Energized by breaking down complex problems into clear, manageable components."], + "does": ["Draws comprehensive system diagrams before writing a single line of code.", + "Challenges every assumption and asks 'why' at every critical decision point."], + }, + }, +] + +# Admin user_id to assign as creator — set via env or fallback prompt +CREATED_BY = os.environ.get("ADMIN_USER_ID", "") + + +async def main() -> None: + from motor.motor_asyncio import AsyncIOMotorClient + + global CREATED_BY + if not CREATED_BY: + CREATED_BY = input("Enter admin user_id (MongoDB ObjectId string): ").strip() + if not CREATED_BY: + print("ERROR: ADMIN_USER_ID required") + sys.exit(1) + + mongo_uri = os.environ.get("MONGO_URI", "mongodb://localhost:27017/cohorta_db") + db_name = mongo_uri.rstrip("/").split("/")[-1].split("?")[0] or "cohorta_db" + client = AsyncIOMotorClient(mongo_uri) + db = client[db_name] + + now = datetime.now(timezone.utc) + inserted = 0 + for p in PERSONAS: + doc = {**p, "created_by": CREATED_BY, "created_at": now, "folder_ids": []} + result = await db.personas.insert_one(doc) + print(f" INSERT {p['name']} → {result.inserted_id}") + inserted += 1 + + print(f"\nDone: {inserted} personas inserted.") + client.close() + + +if __name__ == "__main__": + asyncio.run(main())