Migrate project to uv and add Docker CI
This commit is contained in:
77
README.md
77
README.md
@@ -2,21 +2,67 @@
|
||||
|
||||
A simple internal API to track shopping list items using SQLite and FastAPI.
|
||||
|
||||
## Setup
|
||||
## Tech Stack
|
||||
|
||||
- Python 3.12
|
||||
- FastAPI
|
||||
- SQLite
|
||||
- `uv` for dependency management and local workflows
|
||||
- Docker for container packaging
|
||||
- Gitea Actions for CI
|
||||
|
||||
## Local Development
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- `uv` installed: https://docs.astral.sh/uv/
|
||||
- Python 3.12 available locally
|
||||
|
||||
### Install dependencies
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
uv sync --dev
|
||||
```
|
||||
|
||||
# Run the server
|
||||
uvicorn main:app --reload
|
||||
### Run the server
|
||||
|
||||
```bash
|
||||
uv run uvicorn main:app --reload
|
||||
```
|
||||
|
||||
The API will be available at http://localhost:8000.
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
Tests cover:
|
||||
- Root endpoint
|
||||
- Product CRUD
|
||||
- List CRUD
|
||||
- List items management (add, update, delete, cascade)
|
||||
|
||||
## Docker
|
||||
|
||||
### Build the image
|
||||
|
||||
```bash
|
||||
docker build -t shopping-list-api:local .
|
||||
```
|
||||
|
||||
### Run the container
|
||||
|
||||
```bash
|
||||
docker run --rm -p 8000:8000 -v "$PWD/data:/app/data" -e DB_PATH=/app/data/shopping.db shopping-list-api:local
|
||||
```
|
||||
|
||||
This stores the SQLite database on the host under `./data/shopping.db`.
|
||||
|
||||
## Database
|
||||
|
||||
SQLite database file: `shopping.db` (created automatically on first startup).
|
||||
SQLite database file: `shopping.db` by default (created automatically on first startup).
|
||||
|
||||
Schema:
|
||||
|
||||
@@ -132,19 +178,16 @@ curl -X DELETE http://localhost:8000/lists/1/items/2
|
||||
curl -X DELETE http://localhost:8000/lists/1
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
## CI
|
||||
|
||||
```bash
|
||||
pytest test_main.py
|
||||
```
|
||||
The repository includes a Gitea Actions workflow at `.gitea/workflows/ci.yml` that:
|
||||
|
||||
Tests cover:
|
||||
- Root endpoint
|
||||
- Product CRUD
|
||||
- List CRUD
|
||||
- List items management (add, update, delete, cascade)
|
||||
1. installs Python 3.12 and `uv`
|
||||
2. syncs locked dependencies
|
||||
3. runs the test suite
|
||||
4. builds the Docker image
|
||||
|
||||
## Notes
|
||||
|
||||
- This is an internal API; security/auth not implemented.
|
||||
- For production use, add proper error handling, validation, and possibly a connection pool.
|
||||
- This is an internal API; security/auth is not implemented.
|
||||
- For production use, consider adding stronger validation, structured logging, and a non-SQLite database if concurrency requirements grow.
|
||||
|
||||
Reference in New Issue
Block a user