docs(openapi): draft openapi specs and scaffold api project

This commit is contained in:
kiskaadee committed 2026-05-30 14:32:58 -05:00
1 parent b6ecdede37
commit 5bab3ebf68
17 files changed
+129 -1091

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
# --- Local Environments & Secrets ---
.venv/
.env
__pycache__/
*.pyc
.pytest_cache/
.mypy_cache/
.env
.env.*
!.env.example # Keep templates tracked
*.pem
*.key
client_secret*.json
# --- Python & Build ---
__pycache__/
*.pyc
.mypy_cache/
.pytest_cache/
build/
dist/
# --- IDE & Editor Settings ---
.vscode/
.idea/
.DS_Store
# --- Agentic & Cloud CLI Tools ---
# Global/Local agent configuration & memory files
.claude/
.gemini/
.cursor/
.windsurf/
.aider*/
.codex/
.antigravity*/
# Tool-specific session/memory/metadata
*.session
*.log
memory.json
agents.json
MCP/
+1
View File
@@ -0,0 +1 @@
source .venv/bin/activate
+1
View File
@@ -0,0 +1 @@
3.14
View File
Whitespace-only changes.
+6
View File
@@ -0,0 +1,6 @@
def main():
print("Hello from api!")
if __name__ == "__main__":
main()
+7
View File
@@ -0,0 +1,7 @@
[project]
name = "api"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = []
+69
View File
@@ -0,0 +1,69 @@
services:
pg_database:
image: postgres:17
container_name: postgres_db
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
ports:
- "5050:80"
depends_on:
- pg_database
healthcheck:
test: ["CMD", "wget", "-O", "-", "http://localhost:80/misc/ping"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
api:
build:
context: ./
dockerfile: api/Dockerfile
container_name: fastapi_api
restart: always
environment:
- DATABASE_URL=postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@pg_database:5432/${POSTGRES_DB}
- JWT_SECRET=${JWT_SECRET}
- JWT_ALGORITHM=${JWT_ALGORITHM}
- ACCESS_TOKEN_EXPIRE_MINUTES=${ACCESS_TOKEN_EXPIRE_MINUTES}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
- GOOGLE_REDIRECT_URI=${GOOGLE_REDIRECT_URI}
depends_on:
pg_database:
condition: service_healthy
ui:
build:
context: ./
dockerfile: ui/Dockerfile
container_name: nginx_ui
restart: always
ports:
- "8000:80"
depends_on:
- api
volumes:
postgres_data:
@@ -1,163 +0,0 @@
User:
type: object
required:
- id
- name
- email
- trust_score
- captured_count
properties:
id:
type: string
format: uuid
name:
type: string
example: Juan Perez
email:
type: string
format: email
example: juan.perez@gmail.com
trust_score:
type: number
format: float
description: Reputational metric scaling from 0.0 (untrusted) to 1.0 (highly reliable).
example: 0.85
captured_count:
type: integer
description: Total number of unique sculptures verified.
example: 12
Sculpture:
type: object
required:
- id
- name
- artist
- year
- latitude
- longitude
- status
properties:
id:
type: string
format: uuid
name:
type: string
example: La Novia Dulce
artist:
type: string
example: Lorena Espitia
year:
type: integer
example: 2006
latitude:
type: number
format: float
example: 3.450143
longitude:
type: number
format: float
example: -76.533282
status:
type: string
enum: [on-site, moved, missing]
description: Operational status of the sculpture.
example: on-site
SculptureDetails:
allOf:
- $ref: '#/Sculpture'
- type: object
properties:
description:
type: string
example: Decorated with sweets and candies representing Cali's culinary traditions.
audio_url:
type: string
format: uri
example: https://cdn.gatos.cali.gov.co/audio/novia_dulce.mp3
unlocked_content:
type: string
description: Extended history/curation (hidden until captured).
example: This sculpture was crafted in tribute to the traditional festival of Macetas.
CheckInRecord:
type: object
required:
- sculpture_id
- unlocked_at
- similarity_score
properties:
sculpture_id:
type: string
format: uuid
unlocked_at:
type: string
format: date-time
example: 2026-05-30T10:15:30Z
checkin_photo_url:
type: string
format: uri
example: https://cdn.gatos.cali.gov.co/uploads/checkin_9823.jpg
similarity_score:
type: number
format: float
example: 0.92
Ticket:
type: object
required:
- id
- reporter_id
- sculpture_id
- latitude
- longitude
- reported_status
- status
- created_at
properties:
id:
type: string
format: uuid
reporter_id:
type: string
format: uuid
sculpture_id:
type: string
format: uuid
latitude:
type: number
format: float
example: 3.4515
longitude:
type: number
format: float
example: -76.5320
reported_status:
type: string
enum: [moved, missing, on-site]
photo_url:
type: string
format: uri
nullable: true
example: https://cdn.gatos.cali.gov.co/uploads/report_8321.jpg
description:
type: string
example: Under construction for street repairs. Pedestal is empty.
status:
type: string
enum: [pending, approved, rejected]
example: pending
created_at:
type: string
format: date-time
example: 2026-05-30T11:00:00Z
resolved_at:
type: string
format: date-time
nullable: true
example: null
notes:
type: string
nullable: true
example: Verified via municipal service coordinates.
-50
View File
@@ -1,50 +0,0 @@
openapi: 3.0.3
info:
title: Novias del Gato API - Modular
description: |
Modular, service-oriented API contract for the "Novias del Gato" digital ecosystem in Cali, Colombia.
This specification splits paths and components into separate domain files for enhanced maintainability.
version: 1.0.0
servers:
- url: https://api.gatos.cali.gov.co/v1
description: Production Server
- url: http://localhost:8000/v1
description: Local Development Server
paths:
/auth/login:
$ref: 'paths/auth.yaml'
/users/me:
$ref: 'paths/users.yaml#/me'
/users/me/collection:
$ref: 'paths/users.yaml#/collection'
/sculptures:
$ref: 'paths/sculptures.yaml#/list'
/sculptures/{id}:
$ref: 'paths/sculptures.yaml#/detail'
/sculptures/{id}/check-in:
$ref: 'paths/checkin.yaml'
/reports:
$ref: 'paths/reports.yaml#/collection'
/reports/{id}/verify:
$ref: 'paths/reports.yaml#/verify'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
responses:
Unauthorized:
description: Authentication token missing or expired.
Forbidden:
description: Insufficient permissions for this action.
-39
View File
@@ -1,39 +0,0 @@
post:
summary: Google SSO Authentication
description: Exchange a Google OAuth ID token for a system-issued JWT access token.
operationId: loginUser
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id_token
properties:
id_token:
type: string
description: The ID token returned by Google OAuth.
responses:
'200':
description: Successful authentication
content:
application/json:
schema:
type: object
required:
- access_token
- token_type
- expires_in
properties:
access_token:
type: string
description: JWT access token for subsequent requests.
token_type:
type: string
example: Bearer
expires_in:
type: integer
description: Token lifetime in seconds.
'401':
description: Invalid token provided.
-70
View File
@@ -1,70 +0,0 @@
post:
summary: Capture / Check-in to a Sculpture
description: |
Perform physical verification by sending the explorer's current GPS location and a freshly captured photo.
The Recognition Service verifies the photo matches the sculpture model embeddings within proximity.
operationId: checkInSculpture
security:
- BearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- photo
- latitude
- longitude
properties:
photo:
type: string
format: binary
description: Sighting image file (JPEG/PNG) to analyze.
latitude:
type: number
format: float
minimum: -90
maximum: 90
example: 3.4501
longitude:
type: number
format: float
minimum: -180
maximum: 180
example: -76.5332
responses:
'200':
description: Verification outcome
content:
application/json:
schema:
type: object
required:
- success
- similarity_score
properties:
success:
type: boolean
description: True if the image embedding matched and location was within threshold.
similarity_score:
type: number
format: float
description: Visual confidence score (0.0 to 1.0).
unlocked_content:
type: string
description: Cultural facts or reward text if successfully captured for the first time.
reward_badge:
type: string
description: Name of the badge unlocked, if any.
'400':
description: Invalid coordinates or image file format.
'401':
description: Authentication token missing or expired.
-130
View File
@@ -1,130 +0,0 @@
collection:
post:
summary: Submit a Sculpture Location Report
description: |
Allows citizens to report if a sculpture is missing, undergoing maintenance, or has been relocated.
Supplying GPS coordinates and an optional photo helps update the status map via the weighted consensus engine.
operationId: submitReport
security:
- BearerAuth: []
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- sculpture_id
- latitude
- longitude
- reported_status
properties:
sculpture_id:
type: string
format: uuid
latitude:
type: number
format: float
example: 3.4515
longitude:
type: number
format: float
example: -76.5320
reported_status:
type: string
enum: [moved, missing, on-site]
description: The observed state of the sculpture.
photo:
type: string
format: binary
description: Optional verification photo of empty pedestal or relocated site.
description:
type: string
maxLength: 500
description: Context about the change.
responses:
'201':
description: Report ticket successfully created
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/Ticket'
'401':
description: Authentication token missing or expired.
get:
summary: List Crowdsourced Reports (Moderator Only)
description: Retrieve reports/tickets submitted by users, filterable by status for verification.
operationId: listReports
security:
- BearerAuth: []
parameters:
- name: status
in: query
required: false
schema:
type: string
enum: [pending, approved, rejected]
- name: sculpture_id
in: query
required: false
schema:
type: string
format: uuid
responses:
'200':
description: Array of reports
content:
application/json:
schema:
type: array
items:
$ref: '../components/schemas.yaml#/Ticket'
'401':
description: Authentication token missing or expired.
'403':
description: Insufficient permissions for this action.
verify:
put:
summary: Resolve Location Ticket (Moderator Only)
description: Manually accept or reject a user report. Approving a report updates the location oracle and recalculates user trust scores.
operationId: verifyReport
security:
- BearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- status
properties:
status:
type: string
enum: [approved, rejected]
notes:
type: string
maxLength: 300
description: Review notes explaining the resolution.
responses:
'200':
description: Ticket resolved successfully
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/Ticket'
'401':
description: Authentication token missing or expired.
'403':
description: Insufficient permissions for this action.
'404':
description: Ticket not found.
@@ -1,36 +0,0 @@
list:
get:
summary: List All Cat Sculptures
description: Returns list of all sculptures with names, locations, and current status (Single Source of Truth).
operationId: listSculptures
responses:
'200':
description: List of sculptures
content:
application/json:
schema:
type: array
items:
$ref: '../components/schemas.yaml#/Sculpture'
detail:
get:
summary: Get Sculpture Details
description: Detailed information about a sculpture, historical context, artist, and unlockable audio guides.
operationId: getSculptureById
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Detailed sculpture object
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/SculptureDetails'
'404':
description: Sculpture not found.
-35
View File
@@ -1,35 +0,0 @@
me:
get:
summary: Retrieve Current User Profile
description: Get details about the authenticated user, including their community trust score.
operationId: getMyProfile
security:
- BearerAuth: []
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '../components/schemas.yaml#/User'
'401':
description: Authentication token missing or expired.
collection:
get:
summary: Get User's Unlocked Sculptures
description: Returns the user's progress tracking which cat sculptures they have successfully captured.
operationId: getMyCollection
security:
- BearerAuth: []
responses:
'200':
description: List of check-ins / captures
content:
application/json:
schema:
type: array
items:
$ref: '../components/schemas.yaml#/CheckInRecord'
'401':
description: Authentication token missing or expired.
@@ -1,313 +0,0 @@
openapi: 3.0.3
info:
title: Novias del Gato API - Collector
description: |
Authenticated API contract for collectors and contributors. Contains operations for
social check-ins, location status reporting, and user profiles.
version: 1.0.0
servers:
- url: https://api.gatos.cali.gov.co/v1
description: Production Server
paths:
/auth/login:
post:
summary: Google SSO Authentication
description: Exchange a Google OAuth ID token for a system-issued JWT access token.
operationId: loginUser
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id_token
properties:
id_token:
type: string
description: The ID token returned by Google OAuth.
responses:
'200':
description: Successful authentication
content:
application/json:
schema:
type: object
required:
- access_token
- token_type
- expires_in
properties:
access_token:
type: string
token_type:
type: string
example: Bearer
expires_in:
type: integer
'401':
description: Invalid token.
/users/me:
get:
summary: Retrieve Current User Profile
description: Get details about the authenticated user, including their community trust score.
operationId: getMyProfile
security:
- BearerAuth: []
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'401':
$ref: '#/components/responses/Unauthorized'
/users/me/collection:
get:
summary: Get User's Unlocked Sculptures
description: Returns the user's progress tracking which cat sculptures they have successfully captured.
operationId: getMyCollection
security:
- BearerAuth: []
responses:
'200':
description: List of check-ins / captures
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CheckInRecord'
'401':
$ref: '#/components/responses/Unauthorized'
/sculptures/{id}/check-in:
post:
summary: Capture / Check-in to a Sculpture
description: |
Perform physical verification by sending the explorer's current GPS location and a freshly captured photo.
The Recognition Service verifies the photo matches the sculpture model embeddings within proximity.
operationId: checkInSculpture
security:
- BearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- photo
- latitude
- longitude
properties:
photo:
type: string
format: binary
latitude:
type: number
format: float
minimum: -90
maximum: 90
example: 3.4501
longitude:
type: number
format: float
minimum: -180
maximum: 180
example: -76.5332
responses:
'200':
description: Verification outcome
content:
application/json:
schema:
type: object
required:
- success
- similarity_score
properties:
success:
type: boolean
similarity_score:
type: number
format: float
unlocked_content:
type: string
reward_badge:
type: string
'400':
description: Invalid coordinates or photo format.
'401':
$ref: '#/components/responses/Unauthorized'
/reports:
post:
summary: Submit a Sculpture Location Report
description: |
Allows citizens to report if a sculpture is missing, undergoing maintenance, or has been relocated.
Supplying GPS coordinates and an optional photo helps update the status map via the weighted consensus engine.
operationId: submitReport
security:
- BearerAuth: []
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- sculpture_id
- latitude
- longitude
- reported_status
properties:
sculpture_id:
type: string
format: uuid
latitude:
type: number
format: float
longitude:
type: number
format: float
reported_status:
type: string
enum: [moved, missing, on-site]
photo:
type: string
format: binary
description:
type: string
maxLength: 500
responses:
'201':
description: Report ticket successfully created
content:
application/json:
schema:
$ref: '#/components/schemas/Ticket'
'401':
$ref: '#/components/responses/Unauthorized'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
responses:
Unauthorized:
description: Authentication token missing or expired.
schemas:
User:
type: object
required:
- id
- name
- email
- trust_score
- captured_count
properties:
id:
type: string
format: uuid
name:
type: string
example: Juan Perez
email:
type: string
format: email
example: juan.perez@gmail.com
trust_score:
type: number
format: float
example: 0.85
captured_count:
type: integer
example: 12
CheckInRecord:
type: object
required:
- sculpture_id
- unlocked_at
- similarity_score
properties:
sculpture_id:
type: string
format: uuid
unlocked_at:
type: string
format: date-time
example: 2026-05-30T10:15:30Z
checkin_photo_url:
type: string
format: uri
example: https://cdn.gatos.cali.gov.co/uploads/checkin_9823.jpg
similarity_score:
type: number
format: float
example: 0.92
Ticket:
type: object
required:
- id
- reporter_id
- sculpture_id
- latitude
- longitude
- reported_status
- status
- created_at
properties:
id:
type: string
format: uuid
reporter_id:
type: string
format: uuid
sculpture_id:
type: string
format: uuid
latitude:
type: number
format: float
longitude:
type: number
format: float
reported_status:
type: string
enum: [moved, missing, on-site]
photo_url:
type: string
format: uri
nullable: true
description:
type: string
status:
type: string
enum: [pending, approved, rejected]
created_at:
type: string
format: date-time
resolved_at:
type: string
format: date-time
nullable: true
notes:
type: string
nullable: true
@@ -1,103 +0,0 @@
openapi: 3.0.3
info:
title: Novias del Gato API - Explorer (Public)
description: |
Public, read-only API contract for tourists and citizens exploring Cali's public cat sculptures.
Does not require authentication.
version: 1.0.0
servers:
- url: https://api.gatos.cali.gov.co/v1
description: Production Server
paths:
/sculptures:
get:
summary: List All Cat Sculptures
description: Returns list of all sculptures with names, locations, and current status (Single Source of Truth).
operationId: listSculptures
responses:
'200':
description: List of sculptures
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Sculpture'
/sculptures/{id}:
get:
summary: Get Sculpture Details
description: Detailed information about a sculpture, historical context, artist, and unlockable audio guides.
operationId: getSculptureById
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Detailed sculpture object
content:
application/json:
schema:
$ref: '#/components/schemas/SculptureDetails'
'404':
description: Sculpture not found.
components:
schemas:
Sculpture:
type: object
required:
- id
- name
- artist
- year
- latitude
- longitude
- status
properties:
id:
type: string
format: uuid
name:
type: string
example: La Novia Dulce
artist:
type: string
example: Lorena Espitia
year:
type: integer
example: 2006
latitude:
type: number
format: float
example: 3.450143
longitude:
type: number
format: float
example: -76.533282
status:
type: string
enum: [on-site, moved, missing]
description: Operational status of the sculpture.
example: on-site
SculptureDetails:
allOf:
- $ref: '#/components/schemas/Sculpture'
- type: object
properties:
description:
type: string
example: Decorated with sweets and candies representing Cali's culinary traditions.
audio_url:
type: string
format: uri
example: https://cdn.gatos.cali.gov.co/audio/novia_dulce.mp3
unlocked_content:
type: string
description: Extended history/curation (hidden until captured).
example: This sculpture was crafted in tribute to the traditional festival of Macetas.
@@ -1,152 +0,0 @@
openapi: 3.0.3
info:
title: Novias del Gato API - Moderator (Backoffice)
description: |
Backoffice API contract for administrators and cultural moderators.
Enables tracking and resolving disputed location reports.
version: 1.0.0
servers:
- url: https://api.gatos.cali.gov.co/v1
description: Production Server
paths:
/reports:
get:
summary: List Crowdsourced Reports
description: Retrieve reports/tickets submitted by users, filterable by status for verification.
operationId: listReports
security:
- BearerAuth: []
parameters:
- name: status
in: query
required: false
schema:
type: string
enum: [pending, approved, rejected]
- name: sculpture_id
in: query
required: false
schema:
type: string
format: uuid
responses:
'200':
description: Array of reports
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Ticket'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
/reports/{id}/verify:
put:
summary: Resolve Location Ticket
description: Manually accept or reject a user report. Approving a report updates the location oracle and recalculates user trust scores.
operationId: verifyReport
security:
- BearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- status
properties:
status:
type: string
enum: [approved, rejected]
notes:
type: string
maxLength: 300
description: Review notes explaining the resolution.
responses:
'200':
description: Ticket resolved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Ticket'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
description: Ticket not found.
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
responses:
Unauthorized:
description: Authentication token missing or expired.
Forbidden:
description: Insufficient permissions for this action.
schemas:
Ticket:
type: object
required:
- id
- reporter_id
- sculpture_id
- latitude
- longitude
- reported_status
- status
- created_at
properties:
id:
type: string
format: uuid
reporter_id:
type: string
format: uuid
sculpture_id:
type: string
format: uuid
latitude:
type: number
format: float
longitude:
type: number
format: float
reported_status:
type: string
enum: [moved, missing, on-site]
photo_url:
type: string
format: uri
nullable: true
description:
type: string
status:
type: string
enum: [pending, approved, rejected]
created_at:
type: string
format: date-time
resolved_at:
type: string
format: date-time
nullable: true
notes:
type: string
nullable: true