{"id":17343065,"url":"https://github.com/taogeyt/appboot","last_synced_at":"2025-04-14T19:53:40.965Z","repository":{"id":247980233,"uuid":"827332611","full_name":"taogeYT/appboot","owner":"taogeYT","description":"Use FastAPI like Django","archived":false,"fork":false,"pushed_at":"2024-12-26T16:57:44.000Z","size":1524,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T06:36:10.479Z","etag":null,"topics":["application","django-like","fastapi","microservice","pydantic","sqlalchemy"],"latest_commit_sha":null,"homepage":"https://taogeYT.github.io/appboot","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taogeYT.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}},"created_at":"2024-07-11T12:52:00.000Z","updated_at":"2025-01-12T16:24:17.000Z","dependencies_parsed_at":"2024-08-08T15:50:17.649Z","dependency_job_id":"519d94b5-0229-4aab-86f3-bc60f1f6f079","html_url":"https://github.com/taogeYT/appboot","commit_stats":null,"previous_names":["taogeyt/appboot"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Fappboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Fappboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Fappboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Fappboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taogeYT","download_url":"https://codeload.github.com/taogeYT/appboot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248951993,"owners_count":21188421,"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","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":["application","django-like","fastapi","microservice","pydantic","sqlalchemy"],"created_at":"2024-10-15T16:08:14.793Z","updated_at":"2025-04-14T19:53:40.915Z","avatar_url":"https://github.com/taogeYT.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# App Boot\nEnglish | [中文翻译](./README.zh-CN.md)\n\n[AppBoot](https://github.com/taogeYT/appboot) is a FastAPI project template designed to provide a Django-like structure and development experience.\n## Technology Stack\n- Python 3.9+\n- FastAPI\n- SQLAlchemy 2.0+\n- Pydantic\n- Uvicorn\n## Quick Start\n### Start a New Project\n```shell\n# Create the project directory\nmkdir mysite\ncd mysite\n# Create a virtual environment to isolate our package dependencies locally\npython3 -m venv env\nsource env/bin/activate  # On Windows use `env\\\\Scripts\\\\activate`\n# Install appboot and aiosqlite into the virtual environment\npip install appboot aiosqlite\n# Set up a new project with a single application\nappboot startproject mysite .  # Note the trailing '.' character\n# Start the server, application running on http://127.0.0.1:8000\npython manage.py runserver\n```\n### Start a New App 'polls'\n```shell\npython manage.py startapp polls\n```\n### Create a Model\nDefine a `Question` model in `polls/models.py`.\n```python\nfrom datetime import datetime\nfrom sqlalchemy.orm import Mapped\nfrom appboot import models\n\nclass Question(models.Model):\n    question_text: Mapped[str]\n    pub_date: Mapped[datetime]\n```\n### Create a Schema\nDefine a `QuestionSchema` schema in `polls/schema.py`.\n```python\nfrom appboot.schema import ModelSchema\nfrom polls.models import Question\n\nclass QuestionSchema(ModelSchema):\n    class Meta:\n        model = Question\n```\n### Write CRUD API\nWrite the CRUD API in `polls/views.py`.\n```python\nfrom fastapi import APIRouter, Depends\nfrom appboot.db import create_tables\nfrom appboot.params import QuerySchema, QueryDepends, PaginationResult\nfrom polls.models import Question\nfrom polls.schema import QuestionSchema\n\nrouter = APIRouter(dependencies=[Depends(create_tables)])\n\n@router.post('/questions/', response_model=QuestionSchema)\nasync def create_question(question: QuestionSchema):\n    return await question.create()\n\n@router.get('/questions/', response_model=PaginationResult[QuestionSchema])\nasync def query_questions(query: QuerySchema = QueryDepends()):\n    return await query.query_result(Question.objects.clone())\n\n@router.get('/questions/{question_id}', response_model=QuestionSchema)\nasync def get_question(question_id: int):\n    return await Question.objects.get(question_id)\n\n@router.put('/questions/{question_id}', response_model=QuestionSchema)\nasync def update_question(question_id: int, question: QuestionSchema):\n    instance = await Question.objects.get(question_id)\n    return await question.update(instance)\n\n@router.delete('/questions/{question_id}', response_model=QuestionSchema)\nasync def delete_question(question_id: int):\n    instance = await Question.objects.get(question_id)\n    return await instance.delete()\n```\n### Configure API Routes\nWire up the API URLs in `mysite/urls.py`.\n```python\nfrom fastapi import APIRouter\nfrom polls.views import router\n\nroot_router = APIRouter()\nroot_router.include_router(router, prefix='/polls', tags=['polls'])\n```\n### Testing Our API\n```shell\npython manage.py runserver\n```\nWe can now access our API directly through the browser at [http://127.0.0.1:8000/docs/](http://127.0.0.1:8000/docs/).\n![API Documentation](https://github.com/taogeYT/oss/blob/main/resource/appboot/images/polls.png?raw=true)\n### Create Complex Query Schema\nCreate a `QuestionQuerySchema` for complex queries in `polls/schema.py`.\n```python\nfrom typing import Optional\nfrom appboot.params import QuerySchema\nfrom appboot.filters import EqField, ContainsField\n\nclass QuestionQuerySchema(QuerySchema):\n    ids: Optional[list[int]] = EqField(None, alias='pk', columns='id')  # Query questions by ID list\n    question_text: Optional[str] = ContainsField(None)  # Fuzzy query question_text\n```\nReplace `QuerySchema` with `QuestionQuerySchema` in `polls/views.py`, refresh the docs in the browser, and you will see two new query parameters in the query questions API.\n![Complex Query Parameters](https://github.com/taogeYT/oss/blob/main/resource/appboot/images/query.png?raw=true)\n## Try Out Examples\nGo to [Examples](./examples) for more examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaogeyt%2Fappboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaogeyt%2Fappboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaogeyt%2Fappboot/lists"}