Skip to content

feat: add FastAPI backend and API documentation#5

Merged
recursivezero merged 16 commits intomainfrom
features/RTY-260001
Jan 19, 2026
Merged

feat: add FastAPI backend and API documentation#5
recursivezero merged 16 commits intomainfrom
features/RTY-260001

Conversation

@harshmishra2701
Copy link
Contributor

@harshmishra2701 harshmishra2701 commented Jan 7, 2026

🚀 Summary

This PR introduces a FastAPI-based REST API alongside the existing Flask UI.

Key additions:

  • FastAPI backend for URL shortening
  • /api/shorten and /api/version endpoints
  • Swagger / OpenAPI documentation
  • Dark-themed API landing page
  • CLI commands to run UI or API (tiny dev, tiny api)
  • Reuse existing short URLs to avoid duplication
  • Improved UX messaging in UI
  • Added curl-based API verification
  • Updated README with API usage, CLI commands, and new features
    Fixes ❇️ [RTY-260001]: add/api on cli #4

🧪 How to Run dev

poetry run tiny dev

open

http://127.0.0.1:8000
Screenshot 2026-01-07 142915

🧪 How to Run API

poetry run tiny api

open

http://127.0.0.1:8001
Screenshot 2026-01-07 150233

API Test (curl)

▶️ Step 1: Start the FastAPI server

poetry run tiny api

Server will start at:
(http://127.0.0.1:8001)

▶️ Step 2: Create request folder:

In request folder Create a file named input.json in the project root:

{
  "url": "https://recursivezero.com"
}

▶️ Step 3: Send request using curl (Windows PowerShell)

$body = Get-Content .\request\input.json -Raw

Invoke-RestMethod `
  -Uri "http://127.0.0.1:8001/api/shorten" `
  -Method POST `
  -ContentType "application/json" `
  -Body $body

▶️ Step 4: Expected Response

{
  "short_url": "http://127.0.0.1:8001/abc123",
  "original_url": "https://example.com"
}
Screenshot 2026-01-06 222351

how to Run lint

poetry run lint
Screenshot 2026-01-07 162527

🧩 Related Issue
Issue #4

Test Configuration:

  • Browser: Chrome
  • Device: Laptop
  • Toolchain:
  • Python 3.10 / 3.11
  • Flask
  • FastAPI
  • MongoDB
  • Poetry

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@harshmishra2701
Copy link
Contributor Author

API running with curlScreenshot 2026-01-06 222351

@recursivezero recursivezero self-assigned this Jan 7, 2026
@harshmishra2701 harshmishra2701 marked this pull request as ready for review January 9, 2026 17:29
@recursivezero recursivezero merged commit 7325dae into main Jan 19, 2026
@recursivezero recursivezero deleted the features/RTY-260001 branch February 16, 2026 15:00
This was referenced Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

❇️ [RTY-260001]: add/api on cli

2 participants