Skip to content

Commit f0bca18

Browse files
Merge pull request #1 from sdmunozsierra/claude/python-microservice-template-4cLxL
Refactor: modernize project structure with uv, microservices, and CI
2 parents 215920d + 82b4f45 commit f0bca18

46 files changed

Lines changed: 3164 additions & 121 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.11", "3.12", "3.13"]
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
run: uv python install ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: uv sync --all-extras
25+
26+
- name: Format check
27+
run: uv run ruff format --check src/
28+
29+
- name: Lint
30+
run: uv run ruff check src/
31+
32+
- name: Type check
33+
run: uv run mypy src/myapp/
34+
35+
- name: Tests
36+
run: uv run pytest -v

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6+
# Virtual environments
7+
.venv/
8+
venv/
9+
610
# Unit test / coverage reports
711
htmlcov/
812
.tox/
@@ -15,3 +19,27 @@ coverage.xml
1519
*.cover
1620
.hypothesis/
1721
.pytest_cache/
22+
23+
# Build artifacts
24+
dist/
25+
build/
26+
*.egg-info/
27+
28+
# Runtime data (keep structure, ignore contents)
29+
data/json/*.json
30+
data/db/*.db
31+
data/db/*.db-wal
32+
data/db/*.db-shm
33+
34+
# IDE
35+
.idea/
36+
.vscode/
37+
*.swp
38+
*.swo
39+
40+
# OS
41+
.DS_Store
42+
Thumbs.db
43+
44+
# Logs
45+
*.log

App/main_app.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

Logger/logging_config.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

Logger/main_logger.log

Lines changed: 0 additions & 15 deletions
This file was deleted.

Logger/test_log.log

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,86 @@
1-
# barebones-python-module
2-
Barebones python3 module with testing and logging environment
1+
# myapp
32

4-
## Environment
5-
This repo contains the environment to start coding with an enabled App module (main program), a Logger (logging capabilities), and Tests (using pytest). It has been set up so modules can be imported from anywhere without braking the application.
3+
A fork-ready, microservice-friendly Python template.
64

7-
## Settings
8-
Global settings should be configured in `module_config.py` as it is on the root directory.
5+
Clone, init, test, run — then extend with your own services.
6+
7+
## Quickstart
8+
9+
```bash
10+
just init # install deps, create data dirs, check environment
11+
just test # run all tests
12+
just run # run the default service
13+
```
14+
15+
Requires [uv](https://docs.astral.sh/uv/) and [just](https://github.com/casey/just). See `just doctor` for environment checks.
16+
17+
## What You Get
18+
19+
- **uv-native** workflows — `pyproject.toml` as single source of truth, `uv.lock` committed
20+
- **Microservice architecture** — each service in `src/myapp/services/` with clear boundaries
21+
- **Typed schemas** — Pydantic models at every boundary, versioned with `schema_version`
22+
- **Dual persistence** — JSON (atomic file writes) + SQLite (WAL mode), independent by design
23+
- **CLI** — Click-based, auto-discovers service commands (`project svc <name> <cmd>`)
24+
- **Optional Streamlit UI** — wraps the same service APIs as the CLI
25+
- **Quality gates** — ruff, mypy, pytest, all runnable via `just check`
26+
- **CI** — GitHub Actions running the same gates with uv
27+
28+
## Project Structure
29+
30+
```
31+
src/myapp/
32+
├── cli/ # top-level CLI entrypoint
33+
├── shared/ # config, logging, base schemas, persistence
34+
│ └── persistence/ # BaseStore, JsonStore, SqliteStore
35+
└── services/
36+
└── example/ # example service (copy to create new ones)
37+
├── api.py # public interface
38+
├── schemas.py # I/O models
39+
├── cli.py # service CLI commands
40+
├── storage/ # JSON + SQLite adapters
41+
└── tests/ # service tests
42+
ui/ # optional Streamlit app
43+
data/ # runtime data (gitignored contents)
44+
docs/ # guides and reference
45+
```
46+
47+
## Commands
48+
49+
```bash
50+
just --list # see all available commands
51+
just init # bootstrap project
52+
just doctor # verify environment
53+
just fmt # format code
54+
just lint # lint code
55+
just typecheck # run mypy
56+
just test # run pytest
57+
just check # all quality gates
58+
just run # run default service
59+
just cli <args> # run any CLI command
60+
just ui # launch Streamlit
61+
```
62+
63+
## Documentation
64+
65+
| Guide | Description |
66+
|-------|-------------|
67+
| [Quickstart](docs/quickstart.md) | Get running in 3 commands |
68+
| [Architecture](docs/architecture.md) | Services, boundaries, data flow |
69+
| [CLI Reference](docs/cli-reference.md) | All commands and options |
70+
| [Persistence](docs/persistence.md) | JSON vs SQLite, no-sync explained |
71+
| [Extending](docs/extending.md) | Add services, commands, schemas, UI pages |
72+
73+
## Adding a New Service
74+
75+
```bash
76+
mkdir -p src/myapp/services/myservice/{storage,tests}
77+
# Copy and adapt from services/example/
78+
# The CLI auto-discovers it — no registration needed
79+
project svc myservice --help
80+
```
81+
82+
See [Extending](docs/extending.md) for the full walkthrough.
83+
84+
## License
85+
86+
MIT

Tests/test_main_app.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

__init__.py

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)