shiden 0.1.2

The Shiden Language
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
openapi: 3.0.3
info:
  title: FTPDB Public API
  description: "OpenAPI spec for the FTPDB public JSON API endpoints under /api. Returns project, user, and devlog data sorted by various metrics."
  version: "1.0.0"
servers:
  - url: /api

paths:
  /hot:
    get:
      summary: "Hot projects"
      description: "Returns the top 10 hottest projects sorted by hot_score (trending activity) in descending order."
      tags:
        - Projects
      responses:
        '200':
          description: Success - Returns a map of hot projects keyed by project ID
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  $ref: '#/components/schemas/ProjectWithUser'
              example:
                "123": 
                  id: "123"
                  title: "Awesome Game"
                  banner_url: "https://..."
                  total_hours: 240
                  user_id: "user-1"
                  display_name: "devuser"
                  avatar_url: "https://..."
                  slack_id: "U12345"

  /top_this_week:
    get:
      summary: "Top projects this week"
      description: "Returns the top 10 projects of the current week sorted by weekly rank."
      tags:
        - Projects
      responses:
        '200':
          description: Success - Returns an array of top projects this week
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectWithUserAndRank'
              example:
                - id: "123"
                  title: "Game Mechanics"
                  rank: 1
                  banner_url: "https://..."
                  user_id: "user-1"
                  display_name: "devuser"
                  avatar_url: "https://..."
                  total_hours: 120
                  slack_id: "U12345"

  /fan_favourites:
    get:
      summary: "Fan favourite projects"
      description: "Returns the top 10 fan favourite projects sorted by total likes in descending order."
      tags:
        - Projects
      responses:
        '200':
          description: Success - Returns a map of fan favourite projects keyed by project ID
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  $ref: '#/components/schemas/ProjectWithUser'
              example:
                "123":
                  id: "123"
                  title: "Popular Project"
                  banner_url: "https://..."
                  user_id: "user-1"
                  display_name: "devuser"
                  avatar_url: "https://..."
                  total_hours: 180
                  slack_id: "U12345"

  /top_all_time:
    get:
      summary: "Top projects of all time"
      description: "Returns the top 10 all-time projects sorted by all-time rank."
      tags:
        - Projects
      responses:
        '200':
          description: Success - Returns an array of all-time top projects
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectWithUserAndRank'
              example:
                - id: "456"
                  title: "Classic Project"
                  rank: 1
                  banner_url: "https://..."
                  user_id: "user-2"
                  display_name: "legendary_dev"
                  avatar_url: "https://..."
                  total_hours: 500
                  slack_id: "U67890"

  /most_time_spent:
    get:
      summary: "Users with most time spent"
      description: "Returns the top 10 users sorted by total time spent contributing."
      tags:
        - Users
      responses:
        '200':
          description: Success - Returns an array of top contributors by time spent
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
              example:
                - id: "user-1"
                  display_name: "prolific_dev"
                  avatar_url: "https://..."
                  total_hours: 1200

  /random_projects:
    get:
      summary: "Random projects"
      description: "Returns a random selection of projects. Optionally filter by stat type to delegate to other endpoints."
      tags:
        - Projects
      parameters:
        - in: query
          name: filter
          required: false
          schema:
            type: string
            enum: [stat_hot_score, stat_total_likes, stat_total_duration_seconds]
          description: |
            Optional filter parameter:
            - `stat_hot_score` delegates to /hot
            - `stat_total_likes` delegates to /fan_favourites
            - `stat_total_duration_seconds` delegates to /most_time_spent
            - Omit for truly random selection
      responses:
        '200':
          description: Success - Returns an array of random projects
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectWithStats'

  /random_devlogs:
    get:
      summary: "Random devlogs"
      description: "Returns up to 10 random devlogs weighted towards recent updates. Devlogs are selected with exponential bias towards newer entries."
      tags:
        - Devlogs
      responses:
        '200':
          description: Success - Returns an array of random devlogs
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DevlogWithProject'

  /devlogs/{id}:
    get:
      summary: "Get devlogs for a project"
      description: "Returns all devlogs for a specific project, sorted by creation date (newest first)."
      tags:
        - Devlogs
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
          description: Project ID
      responses:
        '200':
          description: Success - Returns an array of devlogs for the project
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Devlog'
        '404':
          description: Project not found or has no devlogs

  /project_info/{id}:
    get:
      summary: "Get detailed project information"
      description: "Returns comprehensive information about a specific project including description, links, and statistics."
      tags:
        - Projects
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
          description: Project ID
      responses:
        '200':
          description: Success - Returns detailed project information
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectFull'
        '404':
          description: Project not found

  /user_info/{id}:
    get:
      summary: "Get user information"
      description: "Returns profile information for a specific user."
      tags:
        - Users
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
          description: User ID
      responses:
        '200':
          description: Success - Returns user information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserWithTime'
        '404':
          description: User not found

  /user_projects/{user_id}:
    get:
      summary: "Get projects for a user"
      description: "Returns all projects created by a specific user, sorted by total time spent in descending order."
      tags:
        - Users
      parameters:
        - in: path
          name: user_id
          required: true
          schema:
            type: string
          description: User ID
      responses:
        '200':
          description: Success - Returns an array of user's projects
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectBasic'
        '404':
          description: User not found or has no projects

components:
  schemas:
    ProjectBasic:
      type: object
      properties:
        id:
          type: string
          description: Unique project identifier
        title:
          type: string
          description: Project title
        banner_url:
          type: string
          nullable: true
          description: URL to project banner/thumbnail image
        total_hours:
          type: integer
          description: Total development time in hours
        total_likes:
          type: integer
          description: Total community likes/votes
      required:
        - id
        - title
      example:
        id: "proj-123"
        title: "Cool Game Prototype"
        banner_url: "https://example.com/banner.jpg"
        total_hours: 120
        total_likes: 45

    ProjectWithUser:
      allOf:
        - $ref: '#/components/schemas/ProjectBasic'
        - type: object
          properties:
            user_id:
              type: string
              description: ID of the project creator
            display_name:
              type: string
              description: Creator's display name
            avatar_url:
              type: string
              nullable: true
              description: Creator's avatar image URL
            slack_id:
              type: string
              nullable: true
              description: Creator's Slack user ID
          required:
            - user_id
            - display_name

    ProjectWithUserAndRank:
      allOf:
        - $ref: '#/components/schemas/ProjectWithUser'
        - type: object
          properties:
            rank:
              type: integer
              description: Ranking position (weekly or all-time)

    ProjectWithStats:
      allOf:
        - $ref: '#/components/schemas/ProjectWithUser'
        - type: object
          properties:
            hot_score:
              type: number
              description: Hot score metric (trending activity)
            likes:
              type: integer
              description: Total likes (alternative field name)

    ProjectFull:
      allOf:
        - $ref: '#/components/schemas/ProjectWithUser'
        - type: object
          properties:
            description:
              type: string
              nullable: true
              description: Full project description
            repo_url:
              type: string
              nullable: true
              description: Repository URL
            demo_url:
              type: string
              nullable: true
              description: Live demo URL
            ship_status:
              type: string
              nullable: true
              description: Project status (e.g., "shipped", "in-progress", "idea")

    User:
      type: object
      properties:
        id:
          type: string
          description: Unique user identifier
        display_name:
          type: string
          description: User's display name
        avatar_url:
          type: string
          nullable: true
          description: User's avatar image URL
        total_hours:
          type: integer
          description: Total time contributed in hours
      required:
        - id
        - display_name
      example:
        id: "user-123"
        display_name: "awesome_dev"
        avatar_url: "https://example.com/avatar.jpg"
        total_hours: 450

    UserWithTime:
      allOf:
        - $ref: '#/components/schemas/User'
        - type: object
          properties:
            slack_id:
              type: string
              nullable: true
              description: User's Slack ID

    Devlog:
      type: object
      properties:
        body:
          type: string
          description: Devlog content/description
        total_hours:
          type: integer
          description: Time spent in this devlog session, in hours
        comments_count:
          type: integer
          description: Number of comments on this devlog
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of devlog creation
        media_urls:
          type: array
          items:
            type: string
          description: Array of media file URLs (images, videos, etc.)
      required:
        - body
        - total_hours
        - created_at
      example:
        body: "Implemented player movement and collision detection"
        total_hours: 4
        comments_count: 12
        created_at: "2024-02-15T10:30:00Z"
        media_urls: ["https://example.com/screenshot.png"]

    DevlogWithProject:
      allOf:
        - $ref: '#/components/schemas/Devlog'
        - type: object
          properties:
            id:
              type: string
              description: Devlog ID
            project_id:
              type: string
              description: Associated project ID
            project_title:
              type: string
              description: Associated project title
            user_id:
              type: string
              description: Creator user ID
            user_display_name:
              type: string
              description: Creator's display name
            user_avatar:
              type: string
              nullable: true
              description: Creator's avatar URL