Post Status Lifecycle
Posts transition through various states based on user actions and system rules.
stateDiagram-v2
[*] --> draft: User starts post
draft --> pending_approval: Minor submits
draft --> scheduled: Adult schedules
draft --> active: Adult submits immediately
pending_approval --> active: Guardian approves
pending_approval --> deleted: Guardian denies
scheduled --> active: Scheduled time passes
scheduled --> deleted: User cancels
active --> hidden: User hides
active --> deleted: User deletes
active --> reported: 3+ reports
hidden --> active: User unhides
reported --> active: Moderator clears
reported --> deleted: Moderator removes
Create Post Flow
The complete flow for creating posts with all features.
flowchart TB
subgraph User["User Actions"]
A["Open Create Post Modal"]
B["Select Post Type"]
C["Add Content"]
D["Attach Location?"]
E["Schedule Delay?"]
F["Post as Pet?"]
G["Submit"]
end
subgraph Validation["Backend Validation"]
V1["Validate Family Membership"]
V2["Validate Media Ownership"]
V3["Validate Pet Ownership"]
V4["Check if User is Minor"]
end
subgraph Status["Status Determination"]
S1{"Is Minor?"}
S2{"Has Schedule?"}
S3["Status: pending_approval"]
S4["Status: scheduled"]
S5["Status: active"]
end
subgraph Storage["Data Storage"]
DB["DynamoDB\nFamilyPost"]
GSI2["GSI2: Scheduled Posts\nSCHEDULED_POST#date"]
end
subgraph Notifications["Notifications"]
N1["Notify Guardians"]
N2["Notify Family Members"]
end
A --> B --> C --> D --> E --> F --> G
G --> V1 --> V2 --> V3 --> V4
V4 --> S1
S1 -->|Yes| S3
S1 -->|No| S2
S2 -->|Yes| S4
S2 -->|No| S5
S3 --> DB
S4 --> DB
S4 --> GSI2
S5 --> DB
S3 --> N1
S5 --> N2
Guardian Approval Flow
Minors' posts require guardian approval before becoming visible.
sequenceDiagram
participant Minor as Minor User
participant System as System
participant Guardian as Guardian
participant Family as Family Members
Minor->>System: Create post
System->>System: Detect isMinor(user)
System->>System: Set status: pending_approval
System->>Guardian: Push notification
Note right of Guardian: "Post Approval Required"
Guardian->>System: View pending posts
System-->>Guardian: List of pending posts
alt Approve
Guardian->>System: Approve post
System->>System: Set status: active
System->>Minor: Notification: Approved
System->>Family: New post in feed
else Deny
Guardian->>System: Deny post (with reason)
System->>System: Set status: deleted
System->>Minor: Notification: Denied + reason
end
Delayed Posting (5-Minute Cooling-Off)
Users can enable a delay to prevent regrettable posts.
sequenceDiagram
participant User as User
participant App as Mobile App
participant API as API
participant DB as DynamoDB
participant EB as EventBridge
participant Pub as Publisher Lambda
User->>App: Enable "5-min delay"
App->>App: Calculate scheduledAt = now + 5 min
App->>API: POST /posts (with scheduledAt)
API->>DB: Save post (status: scheduled)
API->>DB: Index in GSI2 (SCHEDULED_POST#date)
API-->>App: Created (status: scheduled)
App-->>User: Show "Scheduled" banner
Note over User,App: User can edit/delete during delay
EB->>Pub: Trigger every minute
Pub->>DB: Query GSI2 for due posts
Pub->>DB: Update status to active
Pub->>User: Notify: Post published
Pub->>User: Notify family members
Pet Posting
Users can post on behalf of family pets.
flowchart LR
subgraph Owner["Pet Owner"]
O["User creates post"]
S["Selects 'Post as Pet'"]
P["Chooses pet"]
end
subgraph Validation["Backend"]
V["Verify pet belongs to family"]
C["Verify user is pet's creator"]
end
subgraph Storage["Post Data"]
D["postAsType: 'pet'\npostAsPetId: pet_xyz"]
end
subgraph Display["Feed Display"]
A["Pet avatar"]
N["Pet name"]
I["'via Owner' indicator"]
end
O --> S --> P --> V --> C --> D
D --> A
D --> N
D --> I
Location Sharing
Posts can include the creator's location.
flowchart TB
subgraph Mobile["Mobile App"]
T["Toggle 'Share Location'"]
P["Request Permission"]
G["Get GPS Coordinates"]
R["Reverse Geocode"]
D["Display Preview"]
end
subgraph Data["Location Data"]
L["PostLocation:\n- latitude: 40.7128\n- longitude: -74.0060\n- address: '123 Main St'\n- name: 'Central Park'"]
end
subgraph Feed["Feed Display"]
Tag["Location tag"]
Map["Map preview"]
end
T -->|Granted| P
P --> G
G --> R
R --> D
D --> L
L --> Tag
L --> Map
Post Data Model
DynamoDB key structure for posts.
flowchart TB
subgraph Keys["Primary Keys"]
PK["PK: FAMILY#{familyId}"]
SK["SK: POST#{timestamp}#{postId}"]
end
subgraph GSI1["GSI1 - By Creator"]
G1PK["GSI1PK: USER#{creatorId}"]
G1SK["GSI1SK: POST#{timestamp}"]
end
subgraph GSI2["GSI2 - Scheduled Posts"]
G2PK["GSI2PK: SCHEDULED_POST#{date}"]
G2SK["GSI2SK: POST#{scheduledAt}#{postId}"]
end
subgraph Queries["Common Queries"]
Q1["Family Feed:\nPK = FAMILY#xyz\nSK begins_with POST#"]
Q2["User's Posts:\nGSI1PK = USER#abc"]
Q3["Due Scheduled Posts:\nGSI2PK = SCHEDULED_POST#2026-05-26\nscheduledAt <= now"]
end
Keys --> Q1
GSI1 --> Q2
GSI2 --> Q3
Post Types
| Type | Required Fields | Limits |
|---|---|---|
| text | textContent | Max 2000 characters |
| image | mediaIds (1+) | Max 4 images |
| video | mediaIds (1) | 1 video per post |
| link | linkUrl | Auto-generated preview |
Post Status Values
| Status | Description | Visible in Feed |
|---|---|---|
| draft | Saved but not submitted | No (creator only) |
| pending_approval | Awaiting guardian approval | No (creator + guardians only) |
| scheduled | Will publish at scheduledAt | No (creator only) |
| active | Published and visible | Yes |
| hidden | User-hidden from feed | No |
| deleted | Soft-deleted | No |
| reported | Under moderation review | No |
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /posts | Create new post |
| GET | /posts/{postId} | Get single post |
| PUT | /posts/{postId} | Update post (author only) |
| DELETE | /posts/{postId} | Delete post |
| GET | /families/{familyId}/feed | Get family feed |
| POST | /posts/{postId}/like | Toggle like |
| POST | /posts/{postId}/comments | Add comment |
| POST | /posts/{postId}/report | Report post |
Guardian Approval Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /guardian/posts/pending | Get posts awaiting approval |
| POST | /guardian/posts/{postId}/approve | Approve minor's post |
| POST | /guardian/posts/{postId}/deny | Deny minor's post (with reason) |
Security Considerations
| Concern | Implementation |
|---|---|
| Authorization | Only family members can view/create posts in a family |
| Edit Rights | Only post author can edit their post |
| Delete Rights | Only author or family admin can delete |
| Minor Protection | Posts by users under 16 require guardian approval |
| Content Validation | Text limited to 2000 chars, media ownership verified |
| Pet Verification | Only pet creator can post as that pet |
| Location Privacy | Location is opt-in, user must explicitly enable |