@@ -163,6 +163,100 @@ In development the email lands in [Mailpit](http://localhost:8025); the
163163end-to-end journey (request, email, link, new password) is covered by
164164` PasswordResetFlowTest ` .
165165
166+ ##### Domain Lifecycles
167+
168+ The state diagrams below (designed in issue
169+ [ #42 ] ( https://github.com/ebouchut/learn-dev/issues/42 ) ) describe how a
170+ student progresses through a course, and how a course and a lesson move
171+ between their editorial states. They drive the ` status ` columns of the
172+ ` enrollments ` , ` courses ` , and ` lessons ` tables.
173+
174+ Not every state is persisted in v1:
175+
176+ - * BrowsingCourses* and * ViewingCourseDetails* are plain navigation, not
177+ stored state.
178+ - * EnrollmentPending* / * EnrollmentFailed* (prerequisites) are ** future** :
179+ v1 has no prerequisites, so enrolling succeeds synchronously and
180+ * Enrolled* / * NotStarted* collapse into the ` ENROLLED ` status.
181+ - * CourseUpdated* / * LessonUpdated* are transient editing views of
182+ ` PUBLISHED ` , not a stored status.
183+ - * CourseDeleted* / * LessonDeleted* are ** future** : v1 models removal as
184+ ` ARCHIVED ` (nothing destructive), so the stored statuses are ` DRAFT ` ,
185+ ` PUBLISHED ` , and ` ARCHIVED ` .
186+
187+ ###### Student Course Progress Lifecycle
188+
189+ The state diagram below shows the student lifecycle from enrollment to the
190+ end of the course.
191+
192+ ``` mermaid
193+ stateDiagram-v2
194+ [*] --> BrowsingCourses
195+
196+ BrowsingCourses --> ViewingCourseDetails: View course overview
197+ ViewingCourseDetails --> EnrollmentPending: Click "Enroll" to sign up
198+
199+ EnrollmentPending --> Enrolled: Enrollment successful
200+ EnrollmentPending --> EnrollmentFailed: Prerequisites missing
201+ EnrollmentFailed --> ViewingCourseDetails: Try again / choose another course
202+
203+ Enrolled --> NotStarted: Course access granted
204+
205+ NotStarted --> InProgress: Start first lesson
206+ InProgress --> InProgress: Complete lesson
207+ InProgress --> Completed: All required lessons completed
208+ InProgress --> Dropped: Drop/withdraw from course
209+
210+ NotStarted --> Dropped: Drop/withdraw before starting
211+
212+ Completed --> [*]
213+ Dropped --> [*]
214+ ```
215+
216+ ###### Course Lifecycle
217+
218+ ``` mermaid
219+ stateDiagram-v2
220+ [*] --> CourseDraft
221+
222+ CourseDraft --> CoursePublished: Publish course
223+ CourseDraft --> CourseArchived: Archive course
224+
225+ CoursePublished --> CourseDraft: Unpublish for editing (optional)
226+ CoursePublished --> CourseUpdated: Update course
227+ CoursePublished --> CourseArchived: Archive course
228+
229+ CourseUpdated --> CoursePublished: Re-publish course
230+ CourseUpdated --> CourseArchived: Archive course
231+
232+ CourseArchived --> CourseDraft: Restore / re-open (optional)
233+ CourseArchived --> CourseDeleted: Delete course
234+
235+ CourseDeleted --> [*]
236+ ```
237+
238+ ###### Lesson Lifecycle
239+
240+ ``` mermaid
241+ stateDiagram-v2
242+ [*] --> LessonDraft
243+
244+ LessonDraft --> LessonPublished: Publish lesson
245+ LessonDraft --> LessonArchived: Archive lesson
246+
247+ LessonPublished --> LessonDraft: Unpublish for editing (optional)
248+ LessonPublished --> LessonUpdated: Update lesson
249+ LessonPublished --> LessonArchived: Archive lesson
250+
251+ LessonUpdated --> LessonPublished: Re-publish lesson
252+ LessonUpdated --> LessonArchived: Archive lesson
253+
254+ LessonArchived --> LessonDraft: Restore / re-open (optional)
255+ LessonArchived --> LessonDeleted: Delete lesson
256+
257+ LessonDeleted --> [*]
258+ ```
259+
166260#### Design: Mockups and Wireframes
167261
168262The frontend look and feel is specified before code:
0 commit comments