Skip to content

Latest commit

 

History

History
126 lines (108 loc) · 4.43 KB

File metadata and controls

126 lines (108 loc) · 4.43 KB

Common Workflows

User Registration & Onboarding

sequenceDiagram
    Client->>API: POST /auth/register
    API->>Database: Create user
    API-->>Client: 201 Created (user data)
    Client->>API: POST /auth/login
    API-->>Client: 200 OK (accessToken, refreshToken)
    Client->>API: GET /users/me (Authorization: Bearer token)
    API-->>Client: 200 OK (profile data)
    Client->>API: PATCH /users/me/preferences
    API-->>Client: 200 OK (preferences updated)
Loading

Steps:

  1. RegisterPOST /auth/register with email, password, and name
  2. LoginPOST /auth/login to receive JWT tokens
  3. Get ProfileGET /users/me with the access token
  4. Set PreferencesPATCH /users/me/preferences for locale, timezone, notifications

Course Creation & Publishing

sequenceDiagram
    Instructor->>API: POST /courses (Create course)
    API-->>Instructor: 201 Created
    Instructor->>API: POST /courses/:id/modules (Add modules)
    API-->>Instructor: 201 Created
    Instructor->>API: POST /courses/:id/modules/:modId/lessons (Add lessons)
    API-->>Instructor: 201 Created
    Instructor->>API: POST /courses/:id/submit-for-review
    API-->>Instructor: 200 OK
    Reviewer->>API: POST /courses/:id/review
    API-->>Reviewer: 200 OK
    Instructor->>API: PATCH /courses/:id (Set status to published)
    API-->>Instructor: 200 OK
Loading

Steps:

  1. Create CoursePOST /courses with title, description, price
  2. Add ModulesPOST /courses/:id/modules for each module
  3. Add LessonsPOST /courses/:id/modules/:modId/lessons for each lesson
  4. Submit for ReviewPOST /courses/:id/submit-for-review
  5. Review — Reviewer calls POST /courses/:id/review
  6. PublishPATCH /courses/:id with status: published

Payment Flow

sequenceDiagram
    Student->>API: POST /payments/intent
    API-->>Student: 200 OK (clientSecret)
    Student->>Stripe: Confirm payment
    Stripe-->>Student: Success
    Student->>API: POST /payments/confirm (paymentIntentId)
    API-->>Student: 200 OK (receipt)
    Student->>API: GET /enrollments (verify enrollment)
    API-->>Student: 200 OK
Loading

Steps:

  1. Create Payment IntentPOST /payments/intent with courseId, amount, currency
  2. Confirm on Client — Use Stripe.js to confirm the payment
  3. Confirm on ServerPOST /payments/confirm with the payment intent ID
  4. Verify EnrollmentGET /enrollments to confirm access

Search & Discovery

sequenceDiagram
    User->>API: GET /search?q=javascript&page=1&limit=20
    API->>Elasticsearch: Forward search query
    Elasticsearch-->>API: Results
    API-->>User: 200 OK (results + pagination)
    User->>API: GET /courses/:id
    API-->>User: 200 OK (course details)
    User->>API: POST /courses/:id/enroll
    API-->>User: 201 Created
Loading

Steps:

  1. SearchGET /search?q=<term> for full-text search
  2. Filter — Add ?category=, ?price[gte]=, ?sort= for refinement
  3. View CourseGET /courses/:id for details
  4. EnrollPOST /courses/:id/enroll

Real-Time Collaboration

sequenceDiagram
    User->>WebSocket: Connect with JWT
    WebSocket-->>User: Connected
    User->>WebSocket: Join session { sessionId, userId, resourceType }
    WebSocket-->>User: Join acknowledged
    User->>WebSocket: Operation { type: 'edit', data: ... }
    WebSocket-->>OtherUsers: Broadcast operation
    User->>API: POST /collaboration/sessions (save snapshot)
    API-->>User: 201 Created
Loading

Steps:

  1. Connect — Open WebSocket connection with JWT in query params
  2. Join — Send JoinSession message to start collaborating
  3. Operate — Send CollaborativeOperation messages in real-time
  4. Save — Periodically save to REST API via POST /collaboration/sessions

Moderation Queue

sequenceDiagram
    User->>API: POST /moderation/reports (Report content)
    API-->>User: 201 Created
    Moderator->>API: GET /moderation/queue (View reports)
    API-->>Moderator: 200 OK (pending reports)
    Moderator->>API: PATCH /moderation/reports/:id/action
    API-->>Moderator: 200 OK
    API->>User: (Optional) Notification of resolution
Loading

Steps:

  1. Report ContentPOST /moderation/reports with resource type, ID, and reason
  2. Review QueueGET /moderation/queue for pending reports (moderator role)
  3. Take ActionPATCH /moderation/reports/:id/action to resolve