From 57dc9847ef0e95ae3425d0a2fa91bd60688266a5 Mon Sep 17 00:00:00 2001
From: Atticuszz <1831768457@qq.com>
Date: Sun, 19 Jan 2025 18:45:13 +0800
Subject: [PATCH] docs: update README.md
---
.env | 2 +-
README.md | 192 +++++--------------------------------
backend/app/alembic/README | 1 +
3 files changed, 27 insertions(+), 168 deletions(-)
create mode 100644 backend/app/alembic/README
diff --git a/.env b/.env
index 4e6e028..e721346 100644
--- a/.env
+++ b/.env
@@ -19,7 +19,7 @@ FIRST_SUPERUSER_PASSWORD=admin12345
# API URL
SUPABASE_URL=http://localhost:54321
# service_role key
-SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
+SUPABASE_KEY=eeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
# Postgres
# DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
diff --git a/README.md b/README.md
index aaf418a..5c7a02a 100644
--- a/README.md
+++ b/README.md
@@ -1,185 +1,43 @@
-
-
-
+# FastAPI Supbase Template
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+## Environment
-# β‘SupaFastβ‘
+### Python
-___
-> supabase & fastapi crud template
+> [uv](https://github.com/astral-sh/uv) is an extremely fast Python package and project manager, written in Rust.
-![supafast.drawio.png](docs/assets/supafast.drawio.png)
-
-## Features π
-
-___
-
-### FastAPI&supabase
-
-1. works of authorization all handled by supabase-py and fastapi **dependency** without any extra code
-2. supabase-py crud integration with **pydantic** model validation
-
-### Pytest
-
-1. pytest integration with **pytest-cov**
-2. pytest **fixtures** for fastapi client and supabase client
-3. pytest **fixtures** for access_token and refresh_token
-4. test for **CRUD** operations
-5. test for **api** operations
-
-### CI/CD
-
-1. **codecov** for coverage report
-2. **poetry** for dependency management and pytest integration
-3. **pre-commit** for code quality
-4. **latest_changes.yml** for auto update README.md
-5. **Semantic Release** for auto release and changelog
-6. **docker** for deployment
-
-## How to use it
-
-___
-![](docs/assets/usage.gif)
-
-1. create your github repo and config it
- 1. allow ci to access your repo
- ![img.png](docs/assets/img.png)
- 2. config ci_tokens
- 1. `CODECOV_TOKEN` for codecov in `.github/workflows/ci.yml` ,`semantic-release` is optional for auto release
- 2. `ATTICUS_PAT`should replace with your GitHub token for latest_changes.yml in `.github/workflows/latest_changes.yml`
- 3. `DOCKER_USERNAME` and `DOCKER_PASSWORD` for docker-image.yml in `.github/workflows/docker-image.yml`
- 4. replace `tags: atticuszhou/supafast:latest` with your docker repo in `.github/workflows/docker-image.yml`
- 3. config fastapi setting in `your_project\src\app\core\config.py`
- 4. config `pyproject.toml` with your project name and description,etc
-
-2. cd your repo and install dependencies with [uv](https://github.com/astral-sh/uv), which is an extremely fast Python package and project manager, written in Rust.
-
-```shell
-uv sync
+```bash
+cd backend
+uv sync --all-groups --dev
```
-3. [start your supabase locally](https://supabase.com/docs/guides/local-development/cli/getting-started?queryGroups=platform&platform=linux&queryGroups=access-method&access-method=postgres)
+### [Supabase](https://supabase.com/docs/guides/local-development/cli/getting-started?queryGroups=platform&platform=linux&queryGroups=access-method&access-method=postgres)
+
+install supabase-cli
```bash
# brew in linux https://brew.sh/
brew install supabase/tap/supabase
-supabase init
-supabase start
```
-4. set your supabase env
+launch supabase docker containers
-```shell
-export SUPABASE_URL=your_supabase_url
-export SUPABASE_KEY=your_supabase_key
-export SUPERUSER_EMAIL=your_superuser_email
-export SUPERUSER_PASSWORD=your_superuser_password
+```bash
+# under repo root dir
+supabase start
```
-5. config fastapi settings
-
-```python
-# src/app/core/config.py
-class Settings(BaseSettings):
- API_V1_STR: str = "/api/v1"
- SUPABASE_URL: str = Field(default_factory=lambda: os.getenv("SUPABASE_URL"))
- SUPABASE_KEY: str = Field(default_factory=lambda: os.getenv("SUPABASE_KEY"))
- SUPERUSER_EMAIL: str = Field(default_factory=lambda: os.getenv("SUPERUSER_EMAIL"))
- SUPERUSER_PASSWORD: str = Field(default=lambda: os.getenv("SUPERUSER_PASSWORD"))
- # SERVER_NAME: str
- SERVER_HOST: AnyHttpUrl = "https://localhost"
- SERVER_PORT: int = 8000
- BACKEND_CORS_ORIGINS: list[AnyHttpUrl] = []
- PROJECT_NAME: str = "fastapi supabase template"
- Config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True)
-```
+> [!NOTE]
+> modify the `.env` from the output of `supabase start` or run `supabase status` manually.
-6. run server
+## Test
-```shell
-uv run uvicorn app.main:app --reload
+```bash
+cd backend
+# test connection of db and migration
+scripts/pre-test.sh
+# unit test
+scripts/test.sh
+# test connection of db and unit test
+scripts/tests-start.sh
```
-
-## Roadmap π«Ά
-
-___
-
-- [x] FastAPI backend
- - [x] **standard** structure
- for **FastAPI** project
-
- ```text
- ββ src
- β βββ app
- β βββ api
- β β βββ api_v1
- β β β βββ endpoints
- β β β β βββ __init__.py
- β β β β βββ items.py
- β β β βββ __init__.py
- β β β βββ api.py
- β β βββ __init__.py
- β β βββ deps.py
- β βββ core
- β β βββ __init__.py
- β β βββ config.py
- β β βββ events.py
- β βββ crud
- β β βββ __init__.py
- β β βββ base.py
- β β βββ crud_item.py
- β βββ schemas
- β β βββ __init__.py
- β β βββ auth.py
- β β βββ base.py
- β β βββ item.py
- β β βββ msg.py
- β βββ services
- β β βββ __init__.py
- β βββ utils
- β β βββ __init__.py
- β βββ __init__.py
- β βββ main.py
- ...
- ```
-
- - [x] **auto-auth** by fastapi dependency with supabase-auth
- - [x] **CRUD** operations pytest
- - [x] **api** requests pytest
-- [ ] Supabase integration
- - [x] crud supabase-postgresql
- - [ ] websocket with supabase-realtime
- - [ ] curd supabase-storage
- - [ ] supafunc integration
-- [x] deployment
- - [x] Full **Docker** integration (Docker based).
-- [ ] clone
- - [ ] cookiecutter
-
-## Release Notes π₯Έ
-
-___
-
-### Latest Changes
-
-## License
-
-This project is licensed under the terms of the MIT license.
diff --git a/backend/app/alembic/README b/backend/app/alembic/README
new file mode 100644
index 0000000..2500aa1
--- /dev/null
+++ b/backend/app/alembic/README
@@ -0,0 +1 @@
+Generic single-database configuration.