Files
Learn_System/backend
Maxim Dolgolyov f6fbe922a9 feat(shop): 9 premium animated backgrounds
Doubles the bg catalogue from 10 to 19 with richer multi-layer
animations. Every keyframe pack is CSS-only and respects the existing
prefers-reduced-motion fallback.

  sunset       550   slow hue cycle through warm palette
  rain         650   2-layer vertical streaks at different speeds
  snow         700   3-layer drifting flakes pattern
  clouds       750   drifting white blobs on day sky (only LIGHT one)
  fireflies    800   pulsing glowing dots, opposing drift
  cyber-grid   850   neon grid scrolling down with vignette
  kaleidoscope 1000  two huge conic-gradients in opposite rotation
  ocean        1100  layered blobs drift like undulating waves
  aurora-dance 1500  multi-band aurora — new premium top-tier

Tonal classification mirrored in api.js DARK_BG_SLUGS so the veil
picks the right contrast: clouds is light, the other 8 join the dark
set (alongside dark, stars, aurora, nebula, grid).

Each background also gains a matching .bg-preview.bg-<slug> rule that
reuses the same animation at the shop's 90px swatch — WYSIWYG.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 21:35:59 +03:00
..

LearnSpace Backend — Фаза 1

Быстрый старт

cd backend
npm install

# 1. Скопировать и заполнить переменные окружения
cp .env.example .env

# 2. Создать базу данных в PostgreSQL
createdb learnspace

# 3. Применить миграции (создать таблицы)
npm run migrate

# 4. Загрузить тестовые вопросы
npm run seed

# 5. Запустить сервер
npm run dev

API

Auth

Метод URL Тело Описание
POST /api/auth/register { email, password, name } Регистрация
POST /api/auth/login { email, password } Вход
GET /api/auth/me Текущий пользователь

Предметы

Метод URL Описание
GET /api/subjects Список предметов
GET /api/subjects/:slug/topics Темы предмета

Сессии тестирования

Метод URL Тело Описание
POST /api/sessions { subject_slug, mode, count, topic_id? } Начать тест
POST /api/sessions/:id/answer { question_id, option_id, time_spent_sec? } Отправить ответ
POST /api/sessions/:id/finish Завершить тест + разбор
GET /api/sessions/:id/result Результат завершённого теста
GET /api/sessions/history История тестов

Все /api/sessions/* требуют заголовок:

Authorization: Bearer <token>

Добавление вопросов

Создать JSON-файл в data/ по образцу questions-bio.json:

{
  "subject": "chem",
  "topics": [{ "name": "Органическая химия", "order": 1 }],
  "questions": [
    {
      "topic": "Органическая химия",
      "difficulty": 2,
      "text": "Текст вопроса",
      "options": ["А", "Б", "В", "Г"],
      "answer": 0,
      "explanation": "Объяснение правильного ответа"
    }
  ]
}

Затем повторно запустить npm run seed.

Структура проекта

backend/
├── data/                     ← JSON с вопросами
├── src/
│   ├── server.js             ← точка входа
│   ├── middleware/auth.js    ← JWT верификация
│   ├── db/
│   │   ├── pool.js           ← соединение с PostgreSQL
│   │   ├── migrate.js        ← запуск миграций
│   │   ├── seed.js           ← загрузка вопросов
│   │   └── migrations/       ← SQL-файлы схемы
│   ├── routes/               ← маршруты
│   └── controllers/          ← бизнес-логика
└── .env.example