{"id":18725030,"url":"https://github.com/studentiunimi/backend","last_synced_at":"2025-10-28T16:33:50.444Z","repository":{"id":38079607,"uuid":"389346424","full_name":"StudentiUniMi/backend","owner":"StudentiUniMi","description":"Backend code used by StudentiUniMi to operate its website and Telegram groups.","archived":false,"fork":false,"pushed_at":"2024-09-14T10:15:36.000Z","size":523,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T15:59:52.823Z","etag":null,"topics":["django","python","telegram","unimi","university"],"latest_commit_sha":null,"homepage":"https://api.studentiunimi.it","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StudentiUniMi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-25T12:50:52.000Z","updated_at":"2025-02-09T18:32:28.000Z","dependencies_parsed_at":"2022-09-01T18:50:40.339Z","dependency_job_id":"13100401-cd1c-49c4-bb3b-ec17257cfc28","html_url":"https://github.com/StudentiUniMi/backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/StudentiUniMi/backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudentiUniMi%2Fbackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudentiUniMi%2Fbackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudentiUniMi%2Fbackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudentiUniMi%2Fbackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StudentiUniMi","download_url":"https://codeload.github.com/StudentiUniMi/backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StudentiUniMi%2Fbackend/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267527835,"owners_count":24102019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","python","telegram","unimi","university"],"created_at":"2024-11-07T14:08:52.304Z","updated_at":"2025-10-28T16:33:50.376Z","avatar_url":"https://github.com/StudentiUniMi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StudentiUniMi backend\n\n## What is this?\nThis is the official repository for the backend code used by [StudentiUniMi](https://studentiunimi.it) \nto operate its website and Telegram groups.\nThe project is mainly written in Python (\u003e=3.11) and uses [Django](https://www.djangoproject.com) and \n[python-telegram-bot](https://python-telegram-bot.readthedocs.io/en/stable/) as helper frameworks.\n\nThe code is released under MIT license, and the copyright holder is StudentiUniMi.\n\n## Features\n\n### Website API\n[Currently](https://github.com/StudentiUniMi/website/tree/master/src/data),\n[studentiunimi.it](https://github.com/StudentiUniMi/website) uses a series of .json files as the only data source.\nThe goal is to completely replace that unreliable system with \na new one supported by a dynamic and more manageable database.\nDjango is the perfect choice because it's easy, and gives a user-friendly admin interface without too many headaches. \n\nWe choose to communicate to the frontend with a simple, read-only, JSON, REST API developed with\n[django-rest-framework](https://www.django-rest-framework.org/) module.\nA model is converted to JSON through a serializer as described \n[here](https://www.django-rest-framework.org/api-guide/serializers/) and implemented \n[here](https://github.com/StudentiUniMi/backend/blob/master/university/serializers.py).\n\nHere's an incomplete list of features:\n\n- [ ] University data API\n  - [x] Departments\n    - [x] List API\n    - [x] Verbose details API\n    - [x] Representatives\n  - [ ] Degrees\n    - [x] List API\n    - [x] Verbose details API\n    - [x] Representatives\n    - [ ] External links\n    - [x] Degree general Telegram group  \n  - [x] Courses\n    - [x] List (by degree) API\n    - [x] Verbose details API\n    - [x] External links\n  - [ ] External links\n  - ...\n    \n- ...\n\n### Telegram bot\nStudentiUniMi has hundreds of Telegram groups, connected with hundreds of courses and \ndozens of degrees and departments. \n[Currently, it's a mess](https://github.com/StudentiUniMi/website/blob/6253d1d4fd41370b5f668b428d4c1cdad61eb986/src/data/Data.json). \n\nThe goal is to create a platform to manage Telegram groups. \nThis includes individual user management, special users (e.g. administrators, professors, representatives, ...),\nwelcome messages and CAPTCHAs,  permissions, moderation (global ban, ban, kick, mute, warn, ...), chat statistics, \ninformation gathering and automated group creation.\n\nThe [Bot API](https://core.telegram.org/bots/api) has [two ways](https://core.telegram.org/bots/api#getting-updates) \nto receive updates: we choose to use [webhooks](https://core.telegram.org/bots/api#setwebhook) because they can work\nwell with Django.\n**TL;DR**: when an event (like a new message) occurs, Telegram will send a POST request to \nthe already specified endpoint with one (or more) [Update](https://core.telegram.org/bots/api#update) as content.\nDjango will then process the request with a view (`TelegramBotWebhookView`) that will dispatch the Update with a \n[`telegram.ext.Disptacher`](https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.dispatcher.html).\n\nFor security reasons, every authorized bot will have a different endpoint URL ending with its `?token=XXXXX`.\nBefore doing any processing, the specified token must match an instance of the `TelegramBot` model.\n\nOnce again, here's an incomplete list of features:\n\n- [ ] Architecture\n  - [x] Webhook endpoint\n  - [x] Ignore request if the bot is not recognized\n  - [x] Update dispatcher\n  - [ ] Translations (i18n)\n\n- [ ] Information gathering\n  - [x] Users\n    - [x] Gather and update general information\n    - [x] Update sent message count\n    - [x] Update group membership\n  - [x] Groups\n    - [x] Update, if different, chat title \n    - [x] Periodically update chat photo, description, ...\n\n- [ ] Groups\n  - [ ] Welcome messages\n    - [x] Greet the user \n    - [x] Per-group customized welcome message\n    - [ ] CAPTCHA and rules acceptance for new users\n  - [x] Moderation\n    - [x] Auto-ban globally banned users \n    - [x] Global ban (temporary and permanent)\n    - [x] Group ban (temporary and permanent)\n    - [x] Group mute (temporary and permanent)\n    - [x] Group kick\n    - [x] Global warn\n    - [x] Moderation logging\n    - [x] Info command for administrators\n  - [x] Special users\n    - [x] Recognize special users permissions scope\n    - [x] Automatically set special user permissions and custom titles\n  - [x] Auto-delete welcome and moderation messages\n  - [x] Automatic group creation\n  - ...\n\n## Deployment\nWe use Docker Swarm to deploy this project on our systems. Tune your settings by editing `.env` and \n`docker-compose.yml` files, then run `./deploy.sh`. \nIt's highly recommended using a reverse proxy to run the application in production, like \n[Traefik](https://github.com/traefik/traefik).\n\nYou can use the automatically updated \n[`ghcr.io/studentiunimi/backend:latest`](https://github.com/StudentiUniMi/backend/pkgs/container/backend)\nDocker image if you want the latest version available on the master branch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudentiunimi%2Fbackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudentiunimi%2Fbackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudentiunimi%2Fbackend/lists"}