Skip to content

feat: add sharing FastAPI and Django server#2

Draft
Lenochxd wants to merge 1 commit into
mainfrom
sharing-server
Draft

feat: add sharing FastAPI and Django server#2
Lenochxd wants to merge 1 commit into
mainfrom
sharing-server

Conversation

@Lenochxd
Copy link
Copy Markdown
Collaborator

This pull request introduces a new FastAPI-based public upload/download API for ShareMii .ltd files, including image preview support, rate limiting, and MySQL-backed metadata storage. It also adds a Django UI server, comprehensive configuration, and documentation. The changes are organized into API implementation, configuration, database and file handling, and developer tooling.

API Implementation and Core Features:

  • Introduced a FastAPI app (src/app/main.py) with endpoints for uploading .ltd files (with optional metadata and up to 5 compressed preview images), downloading files and images, and retrieving Mii metadata by share code. All endpoints are rate-limited per client and validate file types, sizes, and identifiers. [1] [2] [3] [4] [5]
  • Added in-memory byte-based rate limiting for uploads and downloads, keyed by client IP hash, with 429 responses and retry headers.

Database, File, and Image Handling:

  • Added MySQL integration for storing and retrieving Mii metadata and image paths, with initialization from init_db.sql. Image uploads are compressed to JPEG and stored in storage/images. Unique 6-character share codes are generated and validated. [1] [2]
  • Added robust file and image validation, including allowed extensions, file size limits, and secure filename checks. [1] [2]

Configuration and Setup:

  • Centralized all API, Django, and MySQL configuration in config.json and loaded settings in src/app/settings.py. [1] [2]
  • Added a main entrypoint (main.py) that launches both the FastAPI API and the Django UI server concurrently, with proper process management. [1] [2]

Documentation and Developer Tooling:

  • Added a detailed API.md with endpoint documentation, usage examples, and configuration notes. Updated the preview image path in README.md. [1] [2]
  • Added .gitattributes for line ending normalization and VSCode settings for Python analysis. [1] [2]

Django UI Server:

  • Added Django ASGI setup and management scripts for the ShareMii web UI, integrated with the FastAPI backend. [1] [2]

These changes together provide a robust, configurable, and well-documented backend for ShareMii file sharing, supporting both programmatic API access and a web UI.

(PR description written by copilot)

@Lenochxd Lenochxd self-assigned this Apr 17, 2026
@Lenochxd
Copy link
Copy Markdown
Collaborator Author

Lenochxd commented Apr 17, 2026

Todo:

  • (CI)/CD
  • remove github pages
  • configure cloudflare

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.

1 participant