{"id":30695839,"url":"https://github.com/sean-njela/fastapi_demo","last_synced_at":"2026-05-03T22:33:46.563Z","repository":{"id":311359428,"uuid":"1043468613","full_name":"sean-njela/fastapi_demo","owner":"sean-njela","description":"A fully customisable personal implementation of fastAPI designed to highlight professional experience. It offers a seamless integration with modern web technologies.","archived":false,"fork":false,"pushed_at":"2025-08-23T23:26:56.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-02T07:15:26.385Z","etag":null,"topics":["api","devops","django","django-rest-framework","fastapi","python","rest-api","restful-api"],"latest_commit_sha":null,"homepage":"https://github.com/sean-njela/fastapi_demo","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/sean-njela.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":"2025-08-23T23:25:19.000Z","updated_at":"2025-08-23T23:28:53.000Z","dependencies_parsed_at":"2025-08-24T10:39:54.766Z","dependency_job_id":"d52f1307-2738-4f0b-88de-9b41ea9440ae","html_url":"https://github.com/sean-njela/fastapi_demo","commit_stats":null,"previous_names":["sean-njela/fastapi_demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sean-njela/fastapi_demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-njela%2Ffastapi_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-njela%2Ffastapi_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-njela%2Ffastapi_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-njela%2Ffastapi_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sean-njela","download_url":"https://codeload.github.com/sean-njela/fastapi_demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sean-njela%2Ffastapi_demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32587819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","devops","django","django-rest-framework","fastapi","python","rest-api","restful-api"],"created_at":"2025-09-02T07:09:29.037Z","updated_at":"2026-05-03T22:33:46.548Z","avatar_url":"https://github.com/sean-njela.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI Todo Demo\r\n\r\nA tiny CRUD Todo API built with [FastAPI](https://fastapi.tiangolo.com/). It uses an in-memory list for storage (great for learning and demos), showcases middleware, background tasks, and simple filtering.\r\n\r\n## Prerequisites\r\n\r\n* Python 3.9+\r\n* [Poetry](https://python-poetry.org/) for dependency management\r\n* (Optional) [Devbox](https://www.jetify.com/devbox/) for a reproducible shell\r\n\r\n```bash\r\n# enter the dev environment (optional)\r\ndevbox shell\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\n# install dependencies\r\npoetry install\r\n```\r\n\r\n## Running the server\r\n\r\n```bash\r\npoetry run uvicorn app:app --host 127.0.0.1 --port 8080 --reload\r\n# General form: uvicorn \u003cmodule_name\u003e:\u003cfastapi_instance_name\u003e\r\n# Example above assumes a file named app.py with: app = FastAPI()\r\n```\r\n\r\nNow open:\r\n\r\n* Swagger UI (OpenAPI): `http://127.0.0.1:8080/docs`\r\n* ReDoc: `http://127.0.0.1:8080/redoc`\r\n\r\n## API Overview\r\n\r\nBase URL: `http://127.0.0.1:8080`\r\n\r\n### Todo model\r\n\r\n```json\r\n{\r\n  \"id\": 1,\r\n  \"task\": \"Buy milk\",\r\n  \"is_completed\": false\r\n}\r\n```\r\n\r\n### Endpoints\r\n\r\n#### Create\r\n\r\n`POST /todos`\r\n\r\n```bash\r\ncurl -X POST http://127.0.0.1:8080/todos \\\r\n  -H \"Content-Type: application/json\" \\\r\n  -d '{\"task\":\"Buy milk\"}'\r\n```\r\n\r\n#### Read (all, with optional filter)\r\n\r\n`GET /todos?completed=true|false`\r\n\r\n```bash\r\ncurl \"http://127.0.0.1:8080/todos\"\r\ncurl \"http://127.0.0.1:8080/todos?completed=true\"\r\n```\r\n\r\n#### Read (by id)\r\n\r\n`GET /todos/{id}`\r\n\r\n```bash\r\ncurl http://127.0.0.1:8080/todos/1\r\n```\r\n\r\n#### Update\r\n\r\n`PUT /todos/{id}`\r\n\r\n\u003e Send the full Todo object in the body. The id in the path is authoritative.\r\n\r\n```bash\r\ncurl -X PUT http://127.0.0.1:8080/todos/1 \\\r\n  -H \"Content-Type: application/json\" \\\r\n  -d '{\"id\":1,\"task\":\"Buy oat milk\",\"is_completed\":true}'\r\n```\r\n\r\n#### Delete\r\n\r\n`DELETE /todos/{id}`\r\n\r\n```bash\r\ncurl -X DELETE http://127.0.0.1:8080/todos/1\r\n```\r\n\r\n## What the demo shows\r\n\r\n* **FastAPI basics:** Path/verb handlers for CRUD.\r\n* **Pydantic models:** `Todo` for request/response validation.\r\n* **Middleware:** Simple request timing logger.\r\n* **Background tasks:** Simulated email notification after creating a todo.\r\n* **CORS:** Wide-open configuration for local testing.\r\n* **OpenAPI docs:** Auto-generated Swagger UI at `/docs`.\r\n\r\n## Project structure (suggested)\r\n\r\n```\r\n.\r\n├── app.py          # FastAPI app (see snippet below)\r\n├── pyproject.toml  # Poetry config\r\n└── README.md\r\n```\r\n\r\n## Code sample (for reference)\r\n\r\n```python\r\nclass Todo(BaseModel):\r\n    \"\"\"\r\n    Model for Todos.\r\n    Inherits from pydantic's BaseModel (acts like a dataclass with validation).\r\n    \"\"\"\r\n    id: Optional[int] = None            # Optional: DBs usually handle this\r\n    task: str                           # Always use 'str' (not 'string')\r\n    is_completed: bool = False          # Default value\r\n\r\n# CREATE\r\n@app.post(\"/todos\")\r\nasync def add_todo(todo: Todo, background_task: BackgroundTasks):\r\n    todo.id = len(todos_list) + 1\r\n    todos_list.append(todo)\r\n    background_task.add_task(send_email, todo)  # background side-effect\r\n    return todo\r\n```\r\n\r\n## Notes \u0026 gotchas\r\n\r\n* The storage is **in-memory**; data resets when the server restarts.\r\n* Function names in a single Python module should be unique.\r\n* `HTTPException` is used to return proper HTTP status codes.\r\n* For a real app, add a database (e.g., SQLite/Postgres), auth, logging, and tests.\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## Author\r\n\r\nSean Njela","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsean-njela%2Ffastapi_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsean-njela%2Ffastapi_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsean-njela%2Ffastapi_demo/lists"}