{ "_meta": { "name": "SysAnal" }, "elements": [ { "id": "header", "type": "card", "title": "WellNuo — System Analysis", "borderColor": "purple", "tags": ["overview"], "description": "**Elderly Care Monitoring App**\n\nМобильное приложение для удалённого мониторинга пожилых родственников через бесконтактные датчики.\n\n---\n\n**Ключевые термины:**\n\n• **Caretaker** — ты (следишь за родственником)\n• **Beneficiary** — бабушка/дедушка (за кем следят)\n• **Sensors** — датчики движения, двери\n• **Hub** — устройство, собирает данные с датчиков\n\n---\n\n**Принцип:**\nОдин beneficiary = один набор датчиков = одна покупка.", "x": 400, "y": 100 }, { "id": "tech-stack", "type": "card", "title": "Tech Stack", "borderColor": "gray", "tags": ["overview"], "description": "**Frontend:**\n• React Native 0.81.5\n• Expo SDK 54\n• Expo Router 6.x\n\n**Backend (hybrid):**\n• Node.js + Supabase (auth, users, orders)\n• eluxnetworks.net (sensor data, AI)\n\n**Payments:** Stripe\n**Email:** Brevo\n**Push:** Expo Notifications\n\n**Repository:** Gitea `sergei_t/WellNuo`", "x": 700, "y": 100 }, { "id": "section-env", "type": "card", "title": "═══ CREDENTIALS ═══", "borderColor": "cyan", "tags": ["env"], "description": "**ВСЕ КЛЮЧИ НАСТРОЕНЫ ✅**\n\n• Backend → Supabase\n• Payments → Stripe\n• Admin Panel → готов\n\n**Backend URL:**\n`https://wellnuo.smartlaunchhub.com`\n\n**Server:**\n`91.98.205.156` (PM2: wellnuo-api)\n\nПодробнее: 01_ENV_Credentials.json", "x": 100, "y": 300 }, { "id": "env-available", "type": "card", "title": "Credentials ✅ Backend", "borderColor": "green", "tags": ["env"], "description": "**SUPABASE_URL** ✅\n`https://bfzizknbxbsfrffqityf.supabase.co`\n\n**SUPABASE_SERVICE_KEY** ✅\n`sb_secret_N7TN930UzzXGgFgrAaozqA_Y4b0DKlM`\n\n**SUPABASE_DB_PASSWORD** ✅\n`Orelkosyak5!`\n\n**JWT_SECRET** ✅\n`wellnuo_jwt_secret_key_2024`\n\n**BREVO_API_KEY** ✅\n`xkeysib-0dfc4f8...g80C4A1OgUEs5j64`\n\n**OLD_API_URL** ✅\n`https://eluxnetworks.net/function/well-api/api`", "x": 100, "y": 450 }, { "id": "env-stripe", "type": "card", "title": "Credentials ✅ Stripe", "borderColor": "green", "tags": ["env"], "description": "**TEST MODE KEYS:**\n\n**STRIPE_PUBLISHABLE_KEY** ✅\n`pk_test_51P3kdqP0gvUw6M9C7ixPQHq...`\n\n**STRIPE_SECRET_KEY** ✅\n`sk_test_51P3kdqP0gvUw6M9CFhALbFx...`\n\n**STRIPE_WEBHOOK_SECRET** ✅\n`whsec_dstl9fzDY3Qj79xvKIlGr1GtExdFfV1Q`\n\n---\n\n**Stripe Products:**\n• Starter Kit: `prod_TdC4ZH4AojGoEp`\n• Premium: `prod_TdC47FEL4oFT3b`\n\n**Stripe Prices:**\n• Kit $249: `price_1SfvfxP0gvUw6M9CLbeGH9mr`\n• Premium $9.99/mo: `price_1SfvfxP0gvUw6M9CO5JxxqHR`\n\n**Webhook URL:**\n`https://wellnuo.smartlaunchhub.com/api/webhook/stripe`", "x": 100, "y": 650 }, { "id": "env-admin", "type": "card", "title": "Credentials ✅ Admin", "borderColor": "green", "tags": ["env"], "description": "**ADMIN_API_KEY** ✅\n`wn_admin_secret_2024_xK9mP2nQ`\n\n---\n\n**Admin Panel:**\nhttps://wellnuo.smartlaunchhub.com/admin\n\n**Admin API:**\nHeader: `x-admin-key: wn_admin_secret_2024_xK9mP2nQ`\n\n**Endpoints:**\n• GET `/api/admin/stats`\n• GET `/api/admin/orders`\n• PATCH `/api/admin/orders/:id`\n• GET `/api/admin/users`\n• POST `/api/admin/refund`", "x": 100, "y": 900 }, { "id": "section-flows", "type": "card", "title": "═══ USER FLOWS ═══", "borderColor": "blue", "tags": ["flow"], "description": "Все пути пользователя в приложении.\n\nКаждый flow описан пошагово:\n• Что видит пользователь\n• Какие API вызываются\n• Что происходит на backend", "x": 400, "y": 300 }, { "id": "flow-1-start", "type": "card", "title": "FLOW 1: App Start", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/_layout.tsx`\n\n**Что происходит:**\n1. Пользователь открывает приложение\n2. Показывается Splash Screen\n3. Проверяем: есть ли сохранённый токен?\n\n```javascript\nconst token = await SecureStore\n .getItemAsync('accessToken')\n```\n\n**Если токен есть** → Dashboard\n**Если нет** → Login Screen", "x": 400, "y": 450 }, { "id": "flow-1-token-check", "type": "condition", "title": "Token exists?", "borderColor": "yellow", "tags": ["flow", "frontend"], "description": "```javascript\nif (token) {\n // Проверяем валидность\n const valid = await validateToken(token)\n if (valid) → Dashboard\n else → Login\n} else {\n → Login\n}\n```", "x": 700, "y": 450 }, { "id": "flow-2-header", "type": "card", "title": "FLOW 2: Registration", "borderColor": "blue", "tags": ["flow"], "description": "**Новый пользователь регистрируется**\n\nЭто первый шаг для нового клиента.", "x": 400, "y": 600 }, { "id": "flow-2-register", "type": "card", "title": "2.1 Register Screen", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/(auth)/register.tsx`\n\n**Поля:**\n• Full Name\n• Email\n• Password\n• Confirm Password\n\n**Кнопки:**\n• [Create Account]\n• \"Already have account? Sign In\"", "x": 700, "y": 600 }, { "id": "flow-2-api", "type": "card", "title": "2.2 API: Register", "borderColor": "green", "tags": ["flow", "backend"], "description": "**POST** `/auth/register`\n\n**Request:**\n```json\n{\n \"name\": \"John Smith\",\n \"email\": \"john@example.com\",\n \"password\": \"secret123\"\n}\n```\n\n**Response 201:**\n```json\n{\n \"user\": { \"id\": \"uuid\", \"name\": \"...\" },\n \"access_token\": \"jwt...\"\n}\n```\n\n**Error 409:** Email already exists", "x": 1000, "y": 600 }, { "id": "flow-2-email", "type": "card", "title": "2.3 Welcome Email", "borderColor": "orange", "tags": ["flow", "external"], "description": "**Brevo отправляет email:**\n\n```\nSubject: Welcome to WellNuo!\n\nHi John,\n\nThank you for joining WellNuo...\n```\n\n**Template ID:** welcome_email", "x": 1000, "y": 750 }, { "id": "flow-3-header", "type": "card", "title": "FLOW 3: Login", "borderColor": "blue", "tags": ["flow"], "description": "**Существующий пользователь входит**", "x": 400, "y": 900 }, { "id": "flow-3-login", "type": "card", "title": "3.1 Login Screen", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/(auth)/login.tsx`\n\n**Поля:**\n• Email\n• Password\n\n**Кнопки:**\n• [Sign In]\n• [Forgot Password?]\n• \"Don't have account? Register\"", "x": 700, "y": 900 }, { "id": "flow-3-api", "type": "card", "title": "3.2 API: Login", "borderColor": "green", "tags": ["flow", "backend"], "description": "**POST** `/auth/login`\n\n**Request:**\n```json\n{\n \"email\": \"john@example.com\",\n \"password\": \"secret123\"\n}\n```\n\n**Response 200:**\n```json\n{\n \"access_token\": \"jwt...\",\n \"user\": {\n \"id\": \"uuid\",\n \"name\": \"John\",\n \"email\": \"...\"\n }\n}\n```\n\n**Error 401:** Invalid credentials", "x": 1000, "y": 900 }, { "id": "flow-3-save", "type": "card", "title": "3.3 Save Token", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**После успешного логина:**\n\n```javascript\nawait SecureStore.setItemAsync(\n 'accessToken', \n response.access_token\n)\n\nawait SecureStore.setItemAsync(\n 'userId',\n response.user.id\n)\n\nrouter.replace('/(tabs)')\n```", "x": 1000, "y": 1050 }, { "id": "flow-4-header", "type": "card", "title": "FLOW 4: Onboarding", "borderColor": "blue", "tags": ["flow"], "description": "**После регистрации — первый вопрос**\n\nОпределяем: новый клиент или приглашённый.", "x": 400, "y": 1200 }, { "id": "flow-4-question", "type": "condition", "title": "4.1 \"Do you have sensors?\"", "borderColor": "yellow", "tags": ["flow", "frontend"], "description": "**Файл:** `app/onboarding/index.tsx`\n\n**Экран:**\n\"Do you already have WellNuo sensors or an invitation code?\"\n\n**[Yes, I have a code]**\n→ Enter Code screen\n\n**[No, I want to buy]**\n→ Add Beneficiary screen", "x": 700, "y": 1200 }, { "id": "flow-4-code", "type": "card", "title": "4.2a Enter Code", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Если есть код приглашения:**\n\nПоле: `ABC-123-XYZ`\n\n**API:** `POST /invitations/redeem`\n\n```json\n{ \"code\": \"ABC-123-XYZ\" }\n```\n\n**Response:** Добавляет beneficiary в аккаунт\n\n→ Dashboard", "x": 1000, "y": 1100 }, { "id": "flow-4-buy", "type": "card", "title": "4.2b Want to Buy", "borderColor": "orange", "tags": ["flow", "frontend"], "description": "**Если хочет купить:**\n\n→ Переходит в FLOW 5: Purchase", "x": 1000, "y": 1300 }, { "id": "flow-5-header", "type": "card", "title": "FLOW 5: Purchase ⭐", "borderColor": "orange", "tags": ["flow", "purchase"], "description": "**ГЛАВНЫЙ FLOW — Покупка датчиков**\n\nПользователь добавляет beneficiary и покупает датчики.\n\nОдин beneficiary = одна покупка.", "x": 400, "y": 1450 }, { "id": "flow-5-add-beneficiary", "type": "card", "title": "5.1 Add Beneficiary", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/beneficiary/add.tsx`\n\n**\"Let's add your loved one\"**\n\n**Поля:**\n• Name (\"Grandma Mary\")\n• Photo (optional)\n• Address (where sensors will be)\n• Phone\n• Notes (\"lives alone, has a cat\")\n\n[Continue] →", "x": 700, "y": 1450 }, { "id": "flow-5-select-plan", "type": "card", "title": "5.2 Select Plan", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/beneficiary/plan.tsx`\n\n**\"Sensors are required\"**\n\n**Starter Kit — $249**\n• 2× Motion sensor\n• 1× Door sensor\n• 1× Hub\n\n---\n\n**Subscription:**\n○ Free — basic monitoring\n● Premium $9.99/mo — AI Julia\n\n[Continue] →", "x": 700, "y": 1600 }, { "id": "flow-5-checkout", "type": "card", "title": "5.3 Checkout", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/checkout/index.tsx`\n\n**Order Summary:**\n```\nGrandma Mary\nStarter Kit $249\nPremium $9.99/mo\n─────────────────────\nShipping: [Your address]\nDelivery: Standard (Free)\n─────────────────────\nTODAY: $258.99\n```\n\n[Pay $258.99] →", "x": 700, "y": 1750 }, { "id": "flow-5-stripe", "type": "card", "title": "5.4 Stripe Payment", "borderColor": "orange", "tags": ["flow", "external"], "description": "**Stripe Checkout или Payment Sheet**\n\n**Методы:**\n• Credit/Debit Card\n• Apple Pay\n• Google Pay\n\n**После оплаты:**\nStripe отправляет webhook → backend\n\n**Events:**\n• `checkout.session.completed`\n• `payment_intent.succeeded`", "x": 1000, "y": 1750 }, { "id": "flow-5-api-order", "type": "card", "title": "5.5 API: Create Order", "borderColor": "green", "tags": ["flow", "backend"], "description": "**POST** `/orders`\n\n**Request:**\n```json\n{\n \"beneficiary\": {\n \"name\": \"Grandma Mary\",\n \"address\": \"123 Oak St\"\n },\n \"items\": [\"KIT-STARTER\"],\n \"subscription\": \"premium\",\n \"shipping_address\": \"...\",\n \"stripe_session_id\": \"cs_xxx\"\n}\n```\n\n**Response 201:**\n```json\n{\n \"order_id\": \"WN-2025-0042\",\n \"status\": \"paid\",\n \"delivery_date\": \"Dec 20-22\"\n}\n```", "x": 1000, "y": 1900 }, { "id": "flow-5-confirmation", "type": "card", "title": "5.6 Order Confirmed", "borderColor": "green", "tags": ["flow", "frontend"], "description": "**Файл:** `app/checkout/success.tsx`\n\n**\"Order Confirmed!\"**\n\n```\nOrder #WN-2025-0042\n\n✓ Payment successful\n\nStatus: Preparing to ship\nDelivery: Dec 20-22\n\nConfirmation email sent.\n```\n\n[Go to App] → Dashboard", "x": 700, "y": 1900 }, { "id": "flow-5-email", "type": "card", "title": "5.7 Order Email", "borderColor": "orange", "tags": ["flow", "external"], "description": "**Brevo отправляет:**\n\n```\nSubject: Order #WN-2025-0042 Confirmed\n\nThank you for your order!\n\nItems:\n• Starter Kit ($249)\n• Premium subscription ($9.99/mo)\n\nShipping to:\n456 Pine Ave...\n\nTrack your order: [link]\n```", "x": 1000, "y": 2050 }, { "id": "flow-6-header", "type": "card", "title": "FLOW 6: Waiting & Tracking", "borderColor": "gray", "tags": ["flow"], "description": "**Пользователь ждёт доставку**\n\nМожет отслеживать посылку в приложении.", "x": 400, "y": 2200 }, { "id": "flow-6-waiting", "type": "card", "title": "6.1 Dashboard (Waiting)", "borderColor": "gray", "tags": ["flow", "frontend"], "description": "**Файл:** `app/(tabs)/index.tsx`\n\n**Пока датчики не доставлены:**\n\n```\n┌─────────────────────────┐\n│ 📦 Grandma Mary │\n│ Status: Awaiting sensors│\n│ Delivery: Dec 20 │\n│ [Track Package] │\n└─────────────────────────┘\n```\n\n*Нельзя смотреть активность — датчиков ещё нет*", "x": 700, "y": 2200 }, { "id": "flow-6-tracking", "type": "card", "title": "6.2 Track Package", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**При нажатии [Track Package]:**\n\nОткрывается WebView или deep link:\n`https://fedex.com/track/123456789`\n\n**API:** `GET /orders/:id`\n\n```json\n{\n \"tracking_number\": \"123456789\",\n \"carrier\": \"FedEx\",\n \"status\": \"in_transit\",\n \"estimated_delivery\": \"Dec 20\"\n}\n```", "x": 1000, "y": 2200 }, { "id": "flow-6-delivered", "type": "card", "title": "6.3 Delivered Push", "borderColor": "green", "tags": ["flow", "frontend"], "description": "**Когда посылка доставлена:**\n\n**Push notification:**\n\"Your sensors have been delivered! Time to set them up.\"\n\n**В приложении:**\nСтатус меняется на \"Ready to Install\"\n\n[Start Setup] →", "x": 700, "y": 2350 }, { "id": "flow-7-header", "type": "card", "title": "FLOW 7: Setup Wizard ⭐", "borderColor": "teal", "tags": ["flow", "setup"], "description": "**Пошаговая установка датчиков**\n\nПриложение ведёт пользователя шаг за шагом.\nНикаких технических знаний не нужно.", "x": 400, "y": 2500 }, { "id": "flow-7-intro", "type": "card", "title": "7.1 Setup Intro", "borderColor": "teal", "tags": ["flow", "frontend"], "description": "**Файл:** `app/setup/index.tsx`\n\n**\"Let's set up sensors for Grandma Mary\"**\n\n**What you'll need:**\n• Sensors from the box\n• Power outlets in each room\n• 15-20 minutes\n• Your phone near the Hub\n\n[Start Setup] →", "x": 700, "y": 2500 }, { "id": "flow-7-hub", "type": "card", "title": "7.2 Connect Hub", "borderColor": "teal", "tags": ["flow", "frontend"], "description": "**\"Step 1: Plug in the Hub\"**\n\n[Illustration: Hub plugged into outlet]\n\n1. Take Hub from box\n2. Plug into outlet in central location\n3. Wait for blue light (30 sec)\n\n⏳ Searching for Hub...\n✓ Hub found!\n\n[Next] →", "x": 1000, "y": 2500 }, { "id": "flow-7-hub-api", "type": "card", "title": "7.2a API: Register Hub", "borderColor": "green", "tags": ["flow", "backend"], "description": "**Приложение сканирует Bluetooth/WiFi**\n\n**POST** `/devices/register`\n\n```json\n{\n \"device_type\": \"hub\",\n \"serial\": \"HUB-12345\",\n \"beneficiary_id\": \"uuid\"\n}\n```\n\n**Response 201:**\n```json\n{\n \"device_id\": \"uuid\",\n \"status\": \"online\"\n}\n```", "x": 1000, "y": 2650 }, { "id": "flow-7-sensors", "type": "card", "title": "7.3 Connect Sensors", "borderColor": "teal", "tags": ["flow", "frontend"], "description": "**\"Step 2: Motion Sensors\"**\n\n**Sensor 1 — Bedroom**\n[Illustration: sensor in outlet]\nPlug into outlet, 30-50cm from floor\n⏳ Searching... ✓ Found!\n\n**Sensor 2 — Kitchen**\nPlug near entrance\n⏳ Searching... ✓ Found!\n\n**Tips:**\n• Don't block with furniture\n• Avoid direct sunlight\n• Keep outlet always on", "x": 700, "y": 2700 }, { "id": "flow-7-door", "type": "card", "title": "7.4 Door Sensor", "borderColor": "teal", "tags": ["flow", "frontend"], "description": "**\"Step 3: Door Sensor\"**\n\n[Illustration: door sensor on frame]\n\n1. Stick main part on door frame\n2. Stick magnet on door (opposite)\n3. Gap between: less than 1cm\n\n⏳ Testing...\nOpen and close the door\n✓ Working!\n\n[Next] →", "x": 700, "y": 2850 }, { "id": "flow-7-complete", "type": "card", "title": "7.5 Setup Complete", "borderColor": "green", "tags": ["flow", "frontend"], "description": "**\"All Done!\"** 🎉\n\n**Sensors installed for Grandma Mary:**\n\n✓ Hub — online\n✓ Bedroom — online\n✓ Kitchen — online\n✓ Front door — online\n\nData will start flowing in 5-10 minutes.\n\n[Go to Dashboard] →", "x": 700, "y": 3000 }, { "id": "flow-8-header", "type": "card", "title": "FLOW 8: Daily Use", "borderColor": "blue", "tags": ["flow", "daily"], "description": "**Ежедневное использование**\n\nПосле установки датчиков — пользователь просто открывает приложение и смотрит как дела у бабушки.", "x": 400, "y": 3150 }, { "id": "flow-8-dashboard", "type": "card", "title": "8.1 Dashboard", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Файл:** `app/(tabs)/index.tsx`\n\n**Главный экран:**\n\n```\n┌─────────────────────────┐\n│ 👵 Grandma Mary [●] │\n│ Last activity: │\n│ Kitchen, 5 min ago │\n│ All good ✓ │\n└─────────────────────────┘\n\n[+ Add Beneficiary]\n```\n\n[●] = online, all sensors working", "x": 700, "y": 3150 }, { "id": "flow-8-detail", "type": "card", "title": "8.2 Beneficiary Detail", "borderColor": "blue", "tags": ["flow", "frontend"], "description": "**Тап на карточку beneficiary:**\n\n**Today:**\n• Woke up: 7:15 AM\n• Activity: normal\n• Rooms: bedroom → kitchen → bathroom\n\n**Sensors:**\n✓ Bedroom — online\n✓ Kitchen — online\n✓ Front door — 2 exits today\n\n**Temperature:** 72°F\n\n[Ask Julia] [Weekly Report]", "x": 1000, "y": 3150 }, { "id": "flow-8-api", "type": "card", "title": "8.3 API: Get Activity", "borderColor": "green", "tags": ["flow", "backend"], "description": "**GET** `/beneficiaries/:id/activity`\n\n**Response:**\n```json\n{\n \"beneficiary_id\": \"uuid\",\n \"last_activity\": {\n \"room\": \"kitchen\",\n \"time\": \"2025-12-18T10:30:00Z\"\n },\n \"today\": {\n \"wake_time\": \"07:15\",\n \"door_exits\": 2,\n \"rooms_visited\": [\"bedroom\", \"kitchen\"]\n },\n \"sensors\": [\n {\"name\": \"Bedroom\", \"status\": \"online\"},\n {\"name\": \"Kitchen\", \"status\": \"online\"}\n ]\n}\n```", "x": 1000, "y": 3300 }, { "id": "flow-9-header", "type": "card", "title": "FLOW 9: AI Julia Chat", "borderColor": "pink", "tags": ["flow", "premium"], "description": "**Premium функция**\n\nЧат с AI-ассистентом Julia.\nМожно спросить \"как дела у бабушки?\" и получить понятный ответ.", "x": 400, "y": 3450 }, { "id": "flow-9-chat", "type": "card", "title": "9.1 Chat Screen", "borderColor": "pink", "tags": ["flow", "frontend"], "description": "**Файл:** `app/chat/index.tsx`\n\n**UI:**\n• Chat bubbles (user/assistant)\n• Text input + Send button\n• Typing indicator\n\n**Example:**\n\n👤 \"How is grandma doing?\"\n\n🤖 \"Grandma Mary is doing well today! She woke up at 7:15 AM, had breakfast in the kitchen, and went out for a walk at 11 AM...\"", "x": 700, "y": 3450 }, { "id": "flow-9-api", "type": "card", "title": "9.2 API: voice_ask", "borderColor": "green", "tags": ["flow", "backend"], "description": "**POST** `eluxnetworks.net/.../api`\n\n**Request:**\n```\nfunction=voice_ask\nuser_name=john\ntoken=jwt_token\nquestion=How is grandma doing?\ndeployment_id=21\n```\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"response\": {\n \"body\": \"Grandma Mary is doing well...\",\n \"language\": \"English\"\n }\n}\n```\n\n*Backend использует OpenAI GPT*", "x": 1000, "y": 3450 }, { "id": "flow-10-header", "type": "card", "title": "FLOW 10: Push Notifications", "borderColor": "red", "tags": ["flow"], "description": "**Уведомления о важных событиях**\n\nПриложение присылает push когда что-то не так.", "x": 400, "y": 3650 }, { "id": "flow-10-types", "type": "card", "title": "10.1 Notification Types", "borderColor": "red", "tags": ["flow", "frontend"], "description": "**🔴 Urgent (немедленно):**\n\"Grandma Mary: no activity for 6+ hours\"\n\"Sensor offline: Bedroom\"\n\n**🟡 Important (важно):**\n\"Unusual late wake-up (10:30 AM)\"\n\"Grandma hasn't left home in 3 days\"\n\n**🟢 Info (информация):**\n\"Weekly report ready\"\n\"All sensors online\"", "x": 700, "y": 3650 }, { "id": "flow-10-api", "type": "card", "title": "10.2 Push Token Registration", "borderColor": "green", "tags": ["flow", "backend"], "description": "**При первом запуске:**\n\n```javascript\nconst token = await Notifications\n .getExpoPushTokenAsync()\n```\n\n**POST** `/push-tokens`\n\n```json\n{\n \"token\": \"ExponentPushToken[xxx]\",\n \"platform\": \"ios\"\n}\n```\n\n**Backend отправляет через Expo Push API**", "x": 1000, "y": 3650 }, { "id": "flow-11-header", "type": "card", "title": "FLOW 11: Add Another", "borderColor": "orange", "tags": ["flow", "purchase"], "description": "**Добавить ещё одного beneficiary**\n\nТот же flow что и первая покупка.", "x": 400, "y": 3850 }, { "id": "flow-11-add", "type": "card", "title": "11.1 From Dashboard", "borderColor": "orange", "tags": ["flow", "frontend"], "description": "**На Dashboard:**\n\n[+ Add Beneficiary]\n\n**или**\n\n**Profile → My Beneficiaries → [+]**\n\n---\n\n→ Переходит в FLOW 5: Purchase\n\n*Каждый beneficiary = отдельный заказ*\n*Можно добавить сколько угодно*", "x": 700, "y": 3850 }, { "id": "section-api", "type": "card", "title": "═══ API REFERENCE ═══", "borderColor": "green", "tags": ["api"], "description": "Все API endpoints проекта.\n\n**Наш backend (Supabase):**\nAuth, users, orders, beneficiaries\n\n**Old API (eluxnetworks.net):**\nSensor data, AI chat", "x": 1400, "y": 100 }, { "id": "api-auth", "type": "card", "title": "API: Auth", "borderColor": "green", "tags": ["api", "backend"], "description": "**POST** `/auth/register`\n→ Create new user\n\n**POST** `/auth/login`\n→ Login, get token\n\n**POST** `/auth/forgot-password`\n→ Send reset email\n\n**POST** `/auth/reset-password`\n→ Set new password\n\n**POST** `/auth/refresh`\n→ Refresh token", "x": 1400, "y": 250 }, { "id": "api-beneficiaries", "type": "card", "title": "API: Beneficiaries", "borderColor": "green", "tags": ["api", "backend"], "description": "**GET** `/beneficiaries`\n→ List my beneficiaries\n\n**POST** `/beneficiaries`\n→ Add new beneficiary\n\n**GET** `/beneficiaries/:id`\n→ Get details\n\n**PATCH** `/beneficiaries/:id`\n→ Update info\n\n**GET** `/beneficiaries/:id/activity`\n→ Get sensor activity\n\n**GET** `/beneficiaries/:id/history`\n→ Get history (day/week/month)", "x": 1400, "y": 450 }, { "id": "api-orders", "type": "card", "title": "API: Orders", "borderColor": "green", "tags": ["api", "backend"], "description": "**POST** `/orders`\n→ Create order (after payment)\n\n**GET** `/orders`\n→ List my orders\n\n**GET** `/orders/:id`\n→ Order details + tracking\n\n**Order statuses:**\n• `paid` — payment received\n• `preparing` — packing\n• `shipped` — in transit\n• `delivered` — at address\n• `installed` — sensors set up", "x": 1400, "y": 700 }, { "id": "api-subscriptions", "type": "card", "title": "API: Subscriptions", "borderColor": "green", "tags": ["api", "backend"], "description": "**POST** `/subscriptions`\n→ Create subscription\n\n**GET** `/subscriptions`\n→ List my subscriptions\n\n**PATCH** `/subscriptions/:id`\n→ Change plan (free ↔ premium)\n\n**DELETE** `/subscriptions/:id`\n→ Cancel subscription\n\n**Managed via Stripe Billing Portal**", "x": 1400, "y": 950 }, { "id": "api-devices", "type": "card", "title": "API: Devices", "borderColor": "green", "tags": ["api", "backend"], "description": "**POST** `/devices/register`\n→ Register new device (hub/sensor)\n\n**GET** `/devices`\n→ List devices for beneficiary\n\n**GET** `/devices/:id/status`\n→ Check if online\n\n**DELETE** `/devices/:id`\n→ Remove device", "x": 1400, "y": 1150 }, { "id": "api-stripe", "type": "card", "title": "API: Stripe Webhooks", "borderColor": "orange", "tags": ["api", "external"], "description": "**POST** `/webhooks/stripe`\n\n**Events we handle:**\n\n• `checkout.session.completed`\n → Create order, send email\n\n• `invoice.paid`\n → Renew subscription\n\n• `invoice.payment_failed`\n → Notify user, retry\n\n• `customer.subscription.deleted`\n → Downgrade to free", "x": 1400, "y": 1350 }, { "id": "api-old", "type": "card", "title": "API: Old Backend (eluxnetworks)", "borderColor": "gray", "tags": ["api", "backend"], "description": "**URL:** `https://eluxnetworks.net/function/well-api/api`\n\n**Format:** POST x-www-form-urlencoded\n\n---\n\n**function=credentials**\n→ Login (legacy)\n\n**function=voice_ask**\n→ AI chat with Julia\n\n**function=get_activity**\n→ Sensor data\n\n**function=get_deployments**\n→ List of monitored homes\n\n*Наш backend проксирует эти запросы*", "x": 1400, "y": 1550 }, { "id": "section-db", "type": "card", "title": "═══ DATABASE ═══", "borderColor": "teal", "tags": ["database"], "description": "**Supabase PostgreSQL**\n\nПодробная схема: 05_Database_Schema.json", "x": 1700, "y": 100 }, { "id": "db-tables", "type": "card", "title": "Main Tables", "borderColor": "teal", "tags": ["database"], "description": "**users**\nid, email, name, password_hash\n\n**beneficiaries**\nid, user_id, name, address, photo_url\n\n**orders**\nid, user_id, beneficiary_id, status, tracking\n\n**subscriptions**\nid, user_id, beneficiary_id, plan, stripe_id\n\n**devices**\nid, beneficiary_id, type, serial, status\n\n**push_tokens**\nid, user_id, token, platform", "x": 1700, "y": 250 }, { "id": "section-design", "type": "card", "title": "═══ DESIGN ═══", "borderColor": "pink", "tags": ["design"], "description": "UI/UX guidelines", "x": 1700, "y": 450 }, { "id": "design-colors", "type": "card", "title": "Colors", "borderColor": "pink", "tags": ["design"], "description": "**Primary:**\n• `#4A90D9` — Primary Blue\n• `#2E5C8A` — Primary Dark\n\n**Status:**\n• `#5AC8A8` — Success/Online\n• `#F5A623` — Warning\n• `#D0021B` — Error/Urgent\n\n**Neutral:**\n• `#FFFFFF` — Background\n• `#F5F7FA` — Surface\n• `#333333` — Text", "x": 1700, "y": 600 }, { "id": "design-typography", "type": "card", "title": "Typography", "borderColor": "pink", "tags": ["design"], "description": "**Font:** Inter\n\n**Sizes:**\n• xs: 12px\n• sm: 14px\n• base: 16px\n• lg: 18px\n• xl: 20px\n• 2xl: 24px\n\n**Weights:**\n• 400 — Regular\n• 500 — Medium\n• 600 — Semibold\n• 700 — Bold", "x": 1700, "y": 800 }, { "id": "section-admin", "type": "card", "title": "═══ ADMIN & OPERATIONS ═══", "borderColor": "red", "tags": ["admin"], "description": "**Административная часть**\n\nКак обрабатывать заказы, управлять доставкой, работать с клиентами.\n\n**Кто:**\n• Owner (ты) — все операции\n• Support — помощь клиентам\n\n**Где:**\n• Supabase Dashboard (данные)\n• Stripe Dashboard (платежи)\n• Brevo (emails)\n• Admin Panel (будущее)", "x": 2000, "y": 100 }, { "id": "admin-dashboard", "type": "card", "title": "Admin Dashboard", "borderColor": "red", "tags": ["admin", "operations"], "description": "**Что нужно видеть:**\n\n**Сегодня:**\n• Новые заказы: 3\n• Ожидают отправки: 5\n• Доставлены сегодня: 2\n\n**Метрики:**\n• Всего пользователей: 150\n• Активных beneficiaries: 120\n• Premium подписок: 80\n• MRR: $799\n\n**Алерты:**\n⚠️ 2 заказа ждут 3+ дней\n⚠️ Sensor kit stock: 15 осталось", "x": 2000, "y": 300 }, { "id": "admin-orders", "type": "card", "title": "Order Management", "borderColor": "red", "tags": ["admin", "operations"], "description": "**Список заказов:**\n\n```\n#WN-2025-0042 | $258.99\nJohn Smith → Grandma Mary\nStatus: PAID ⏳\nAddress: 123 Oak St, Boston\nItems: Starter Kit + Premium\nPaid: Dec 18, 10:30 AM\n[Mark as Preparing] [View Details]\n```\n\n**Фильтры:**\n• По статусу (paid, preparing, shipped...)\n• По дате\n• Поиск по имени/email", "x": 2000, "y": 500 }, { "id": "admin-order-flow", "type": "card", "title": "Order Processing Flow", "borderColor": "red", "tags": ["admin", "operations"], "description": "**Статусы заказа:**\n\n**1. PAID** ← Stripe webhook\n↓ [Mark as Preparing]\n\n**2. PREPARING**\n• Проверить stock\n• Собрать kit в коробку\n• Напечатать label\n↓ [Add Tracking & Ship]\n\n**3. SHIPPED**\n• Tracking: 1Z999AA10123456784\n• Carrier: UPS\n• Email клиенту отправлен\n↓ Автоматически (webhook от carrier)\n\n**4. DELIVERED**\n• Push notification клиенту\n• Статус в app: \"Ready to Install\"\n↓ После setup wizard\n\n**5. INSTALLED**\n• Датчики онлайн\n• Мониторинг активен", "x": 2000, "y": 750 }, { "id": "admin-shipping", "type": "card", "title": "Shipping Integration", "borderColor": "red", "tags": ["admin", "operations"], "description": "**Варианты интеграции:**\n\n**Option 1: Manual (старт)**\n1. Заказать pickup на UPS/FedEx сайте\n2. Получить tracking number\n3. Ввести в admin panel\n4. Email отправляется автоматически\n\n**Option 2: ShipStation ($9/mo)**\n• Интеграция с Stripe orders\n• Автогенерация labels\n• Tracking sync\n• Multi-carrier rates\n\n**Option 3: Shippo API**\n• Программная интеграция\n• Генерация labels из backend\n• Webhook на delivery events\n\n---\n\n**Наш план:**\nНачать с Manual → ShipStation когда >20 заказов/месяц", "x": 2000, "y": 1050 }, { "id": "admin-inventory", "type": "card", "title": "Inventory Management", "borderColor": "red", "tags": ["admin", "operations"], "description": "**Starter Kit состоит из:**\n\n• Hub × 1\n• Motion Sensor × 2\n• Door Sensor × 1\n• Cables, manual\n\n**Где хранить:**\n• Дома (первые 50 заказов)\n• 3PL warehouse (потом)\n\n**Tracking:**\n```\nComponent | In Stock | Ordered | ETA\n-------------|----------|---------|--------\nHub | 25 | 50 | Dec 25\nMotion | 48 | 100 | Dec 25\nDoor Sensor | 30 | 50 | Dec 25\nBoxes | 20 | 0 | -\n```\n\n**Alert когда:**\n• Stock < 10 units\n• Reorder point reached", "x": 2000, "y": 1350 }, { "id": "admin-tools", "type": "card", "title": "Admin Tools", "borderColor": "red", "tags": ["admin"], "description": "**Инструменты для работы:**\n\n**Supabase Dashboard**\nhttps://app.supabase.com\n• Таблицы: users, orders, beneficiaries\n• SQL queries\n• Logs\n\n**Stripe Dashboard**\nhttps://dashboard.stripe.com\n• Платежи и refunds\n• Subscriptions\n• Invoices\n\n**Brevo**\nhttps://app.brevo.com\n• Email templates\n• Sent emails log\n• Transactional stats\n\n**eluxnetworks (Old API)**\n• Sensor data\n• Deployments\n• AI Julia stats", "x": 2300, "y": 300 }, { "id": "admin-support", "type": "card", "title": "Customer Support", "borderColor": "red", "tags": ["admin", "operations"], "description": "**Частые запросы:**\n\n**\"Датчик offline\"**\n1. Проверить power\n2. Перезагрузить Hub\n3. Проверить WiFi\n4. Замена если не помогло\n\n**\"Не пришла посылка\"**\n1. Проверить tracking\n2. Связаться с carrier\n3. Переотправить если lost\n\n**\"Хочу отменить\"**\n1. Если не shipped → refund\n2. Если shipped → return policy\n3. Stripe → Refund\n\n**\"Добавить родственника\"**\n1. Объяснить [+ Add Beneficiary]\n2. Новый заказ = новая покупка\n\n---\n\n**Каналы:**\n• Email: support@wellnuo.com\n• In-app chat (будущее)", "x": 2300, "y": 550 }, { "id": "admin-api", "type": "card", "title": "Admin API Endpoints", "borderColor": "green", "tags": ["admin", "api"], "description": "**Только для админов:**\n\n**GET** `/admin/orders`\n→ Все заказы (с фильтрами)\n\n**PATCH** `/admin/orders/:id`\n→ Изменить статус\n```json\n{\n \"status\": \"shipped\",\n \"tracking_number\": \"1Z999AA1\",\n \"carrier\": \"UPS\"\n}\n```\n\n**GET** `/admin/users`\n→ Список пользователей\n\n**GET** `/admin/stats`\n→ Dashboard метрики\n\n**POST** `/admin/refund`\n→ Refund через Stripe\n\n**Авторизация:**\n`role: admin` в JWT token", "x": 2300, "y": 850 }, { "id": "admin-emails", "type": "card", "title": "Email Templates", "borderColor": "orange", "tags": ["admin", "external"], "description": "**Автоматические emails (Brevo):**\n\n**1. Welcome**\nТриггер: После регистрации\n\n**2. Order Confirmation**\nТриггер: После оплаты\nИнфо: Order #, items, address\n\n**3. Order Shipped**\nТриггер: Статус → shipped\nИнфо: Tracking link\n\n**4. Order Delivered**\nТриггер: Статус → delivered\nИнфо: Setup instructions\n\n**5. Weekly Report**\nТриггер: Каждое воскресенье\nИнфо: Активность beneficiary\n\n**6. Payment Failed**\nТриггер: invoice.payment_failed\nИнфо: Update payment method", "x": 2300, "y": 1100 }, { "id": "admin-roadmap", "type": "card", "title": "Admin Panel Roadmap", "borderColor": "purple", "tags": ["admin"], "description": "**Phase 1: MVP (сейчас)**\n• Supabase Dashboard\n• Stripe Dashboard\n• Manual order processing\n• Email через Brevo\n\n**Phase 2: Basic Admin Panel**\n• Web dashboard (Next.js)\n• Order list + status change\n• Basic stats\n• Hosted на Vercel\n\n**Phase 3: Full Admin**\n• Inventory management\n• ShipStation integration\n• Customer lookup\n• Refund processing\n• Analytics dashboard\n\n**Phase 4: Automation**\n• Auto-label printing\n• Warehouse integration\n• Predictive reordering", "x": 2300, "y": 1350 } ], "connections": [ {"from": "header", "to": "tech-stack"}, {"from": "header", "to": "section-env"}, {"from": "header", "to": "section-flows"}, {"from": "header", "to": "section-api"}, {"from": "header", "to": "section-db"}, {"from": "header", "to": "section-admin"}, {"from": "section-env", "to": "env-available"}, {"from": "section-env", "to": "env-stripe"}, {"from": "section-env", "to": "env-admin"}, {"from": "section-flows", "to": "flow-1-start"}, {"from": "flow-1-start", "to": "flow-1-token-check"}, {"from": "flow-1-token-check", "to": "flow-3-login", "label": "No token"}, {"from": "flow-1-token-check", "to": "flow-8-dashboard", "label": "Has token"}, {"from": "flow-2-header", "to": "flow-2-register"}, {"from": "flow-2-register", "to": "flow-2-api"}, {"from": "flow-2-api", "to": "flow-2-email"}, {"from": "flow-2-email", "to": "flow-4-question"}, {"from": "flow-3-header", "to": "flow-3-login"}, {"from": "flow-3-login", "to": "flow-3-api"}, {"from": "flow-3-api", "to": "flow-3-save"}, {"from": "flow-3-save", "to": "flow-8-dashboard"}, {"from": "flow-4-header", "to": "flow-4-question"}, {"from": "flow-4-question", "to": "flow-4-code", "label": "Has code"}, {"from": "flow-4-question", "to": "flow-4-buy", "label": "Want to buy"}, {"from": "flow-4-code", "to": "flow-8-dashboard"}, {"from": "flow-4-buy", "to": "flow-5-add-beneficiary"}, {"from": "flow-5-header", "to": "flow-5-add-beneficiary"}, {"from": "flow-5-add-beneficiary", "to": "flow-5-select-plan"}, {"from": "flow-5-select-plan", "to": "flow-5-checkout"}, {"from": "flow-5-checkout", "to": "flow-5-stripe"}, {"from": "flow-5-stripe", "to": "flow-5-api-order"}, {"from": "flow-5-api-order", "to": "flow-5-confirmation"}, {"from": "flow-5-confirmation", "to": "flow-5-email"}, {"from": "flow-5-confirmation", "to": "flow-6-waiting"}, {"from": "flow-6-header", "to": "flow-6-waiting"}, {"from": "flow-6-waiting", "to": "flow-6-tracking"}, {"from": "flow-6-waiting", "to": "flow-6-delivered"}, {"from": "flow-6-delivered", "to": "flow-7-intro"}, {"from": "flow-7-header", "to": "flow-7-intro"}, {"from": "flow-7-intro", "to": "flow-7-hub"}, {"from": "flow-7-hub", "to": "flow-7-hub-api"}, {"from": "flow-7-hub", "to": "flow-7-sensors"}, {"from": "flow-7-sensors", "to": "flow-7-door"}, {"from": "flow-7-door", "to": "flow-7-complete"}, {"from": "flow-7-complete", "to": "flow-8-dashboard"}, {"from": "flow-8-header", "to": "flow-8-dashboard"}, {"from": "flow-8-dashboard", "to": "flow-8-detail"}, {"from": "flow-8-detail", "to": "flow-8-api"}, {"from": "flow-8-dashboard", "to": "flow-9-chat", "label": "Ask Julia"}, {"from": "flow-8-dashboard", "to": "flow-11-add", "label": "+ Add"}, {"from": "flow-9-header", "to": "flow-9-chat"}, {"from": "flow-9-chat", "to": "flow-9-api"}, {"from": "flow-10-header", "to": "flow-10-types"}, {"from": "flow-10-types", "to": "flow-10-api"}, {"from": "flow-11-header", "to": "flow-11-add"}, {"from": "flow-11-add", "to": "flow-5-add-beneficiary", "label": "Same flow"}, {"from": "section-api", "to": "api-auth"}, {"from": "api-auth", "to": "api-beneficiaries"}, {"from": "api-beneficiaries", "to": "api-orders"}, {"from": "api-orders", "to": "api-subscriptions"}, {"from": "api-subscriptions", "to": "api-devices"}, {"from": "api-devices", "to": "api-stripe"}, {"from": "api-stripe", "to": "api-old"}, {"from": "section-db", "to": "db-tables"}, {"from": "section-design", "to": "design-colors"}, {"from": "design-colors", "to": "design-typography"}, {"from": "section-admin", "to": "admin-dashboard"}, {"from": "admin-dashboard", "to": "admin-orders"}, {"from": "admin-orders", "to": "admin-order-flow"}, {"from": "admin-order-flow", "to": "admin-shipping"}, {"from": "admin-shipping", "to": "admin-inventory"}, {"from": "section-admin", "to": "admin-tools"}, {"from": "admin-tools", "to": "admin-support"}, {"from": "admin-support", "to": "admin-api"}, {"from": "admin-api", "to": "admin-emails"}, {"from": "admin-emails", "to": "admin-roadmap"} ], "tagsDictionary": [ {"name": "overview", "color": "purple"}, {"name": "env", "color": "cyan"}, {"name": "flow", "color": "blue"}, {"name": "frontend", "color": "blue"}, {"name": "backend", "color": "green"}, {"name": "external", "color": "orange"}, {"name": "purchase", "color": "orange"}, {"name": "setup", "color": "teal"}, {"name": "daily", "color": "blue"}, {"name": "premium", "color": "pink"}, {"name": "api", "color": "green"}, {"name": "database", "color": "teal"}, {"name": "design", "color": "pink"}, {"name": "admin", "color": "red"}, {"name": "operations", "color": "red"} ] }