Skip to content

Commit 7257524

Browse files
authored
Initial commit
0 parents  commit 7257524

29 files changed

Lines changed: 656 additions & 0 deletions

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PreToolUse": [
4+
{
5+
"matcher": "Bash",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "cmd=\"$TOOL_INPUT_command\"; if echo \"$cmd\" | grep -qE '^git commit'; then msg=$(echo \"$cmd\" | sed -n 's/.*-m [\"'\\''\"'\\'']*\\([^\"'\\'']*\\).*/\\1/p'); if [ -n \"$msg\" ]; then if ! echo \"$msg\" | grep -qE '^(feat|fix|docs|chore|refactor|test|ci): .+'; then echo 'BLOCKED: Commit message must follow conventional format: type: description'; echo 'Allowed types: feat, fix, docs, chore, refactor, test, ci'; exit 2; fi; fi; fi; exit 0"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
user-invocable: false
3+
description: Use when writing code, adding features, or modifying the app
4+
---
5+
6+
# Towlion App Conventions
7+
8+
Key conventions for Towlion application repositories:
9+
10+
## FastAPI Backend
11+
- Entry point: `app/main.py` with a `FastAPI()` instance
12+
- Run with: `uvicorn app.main:app --host 0.0.0.0 --port 8000`
13+
- Must expose `GET /health` returning `{"status": "ok"}` with HTTP 200
14+
15+
## Project Layout
16+
- `app/` — Python backend (FastAPI)
17+
- `deploy/` — Docker Compose, Caddyfile, env.template
18+
- `scripts/` — Utility scripts (health-check.sh)
19+
- `frontend/` — Optional Next.js frontend
20+
21+
## Dependencies
22+
- `requirements.txt` at repo root (not inside `app/`)
23+
- Must include `fastapi` and `uvicorn`
24+
- Dockerfile build context is `..` (repo root) to access both `requirements.txt` and `app/`
25+
26+
## Database
27+
- PostgreSQL via SQLAlchemy
28+
- Migrations with Alembic (`app/alembic/`)
29+
- Connection via `DATABASE_URL` env var
30+
31+
## Background Tasks
32+
- Celery with Redis as broker
33+
- Workers run as separate containers
34+
- Connection via `REDIS_URL` env var
35+
36+
## Environment Variables
37+
- All config via env vars, never hardcode secrets
38+
- Template in `deploy/env.template`
39+
- Required: `APP_DOMAIN`, `DATABASE_URL`, `REDIS_URL`
40+
41+
## Commit Convention
42+
- Format: `type: description` (lowercase type, no scope)
43+
- Types: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `ci`
44+
- No Conventional Commits scope syntax — just `type: description`
45+
46+
## Docker
47+
- Two compose files: `docker-compose.yml` (multi-app), `docker-compose.standalone.yml` (full stack)
48+
- App container exposes port 8000
49+
- Include healthcheck in compose definition

.claude/skills/deploy/SKILL.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
disable-model-invocation: true
3+
allowed-tools: Bash
4+
description: Deploy the app using Docker Compose
5+
---
6+
7+
# /deploy — Deploy the Application
8+
9+
Build and start the application containers using Docker Compose.
10+
11+
## Instructions
12+
13+
1. Run: `docker compose -f deploy/docker-compose.standalone.yml up -d --build`
14+
2. Wait a few seconds for containers to start
15+
3. Run the health check: `bash scripts/health-check.sh` or `curl -sf http://localhost:8000/health`
16+
4. Report the result to the user
17+
5. If the health check fails, check container logs: `docker compose -f deploy/docker-compose.standalone.yml logs --tail 20`

.claude/skills/health/SKILL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
disable-model-invocation: true
3+
allowed-tools: Bash
4+
description: Check the app health endpoint
5+
---
6+
7+
# /health — Check Application Health
8+
9+
Check whether the application is running and healthy.
10+
11+
## Instructions
12+
13+
1. Try running `bash scripts/health-check.sh`
14+
2. If that fails or doesn't exist, fall back to: `curl -sf http://localhost:8000/health`
15+
3. Report the result to the user
16+
4. If unhealthy, suggest checking container logs with `docker compose -f deploy/docker-compose.standalone.yml logs --tail 20`

.claude/skills/validate/SKILL.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
disable-model-invocation: true
3+
allowed-tools: Bash, Read
4+
description: Run the Towlion spec validator against this app
5+
---
6+
7+
# /validate — Run Spec Validator
8+
9+
Run the Towlion spec conformance validator against this application repository.
10+
11+
## Instructions
12+
13+
1. Check if the platform validator is available locally:
14+
- Look for `../platform/validator/validate.py` or `~/towlion/platform/validator/validate.py`
15+
- If not found, clone it: `git clone --depth 1 https://github.com/towlion/platform.git /tmp/towlion-platform`
16+
2. Run the validator against the current directory:
17+
```
18+
python <path-to-validator>/validate.py --tier 2 --dir .
19+
```
20+
3. Show the output to the user
21+
4. If there are failures, summarize what needs to be fixed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Default code owners for this repository.
2+
# Customize this file for your application — add team-specific paths as needed.
3+
#
4+
# See: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
5+
6+
* @towlion/maintainers

.github/COMMIT_CONVENTION.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Commit Convention
2+
3+
This repository follows simplified [Conventional Commits](https://www.conventionalcommits.org/).
4+
5+
## Format
6+
7+
```
8+
type: description
9+
```
10+
11+
- Lowercase, imperative mood, under 72 characters.
12+
13+
## Types
14+
15+
| Type | Purpose |
16+
|------|---------|
17+
| `feat` | New feature |
18+
| `fix` | Bug fix |
19+
| `docs` | Documentation changes |
20+
| `chore` | Maintenance and housekeeping |
21+
| `refactor` | Code restructuring (no behavior change) |
22+
| `test` | Adding or updating tests |
23+
| `ci` | CI/CD changes |
24+
25+
## Scope (optional)
26+
27+
```
28+
feat(api): add health endpoint
29+
```
30+
31+
## Breaking Changes
32+
33+
```
34+
feat!: change response format
35+
```
36+
37+
For full details, see the [governance policies](https://towlion.github.io/platform/governance/#commit-conventions).

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Summary
2+
3+
<!-- What does this PR do and why? -->
4+
5+
## Changes
6+
7+
<!-- List the changes made in this PR -->
8+
9+
-
10+
11+
## Testing
12+
13+
<!-- How were these changes tested? -->
14+
15+
-
16+
17+
## Checklist
18+
19+
- [ ] Code follows the project's conventions
20+
- [ ] Changes have been tested locally
21+
- [ ] Documentation has been updated (if applicable)
22+
- [ ] No secrets or credentials are included

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
17+
- name: Run tests
18+
run: |
19+
pip install -r requirements.txt
20+
pip install pytest
21+
pytest --tb=short || echo "No tests found, skipping"
22+
23+
- name: Deploy to server
24+
uses: appleboy/ssh-action@v1
25+
with:
26+
host: ${{ secrets.SERVER_HOST }}
27+
username: ${{ secrets.SERVER_USER }}
28+
key: ${{ secrets.SERVER_SSH_KEY }}
29+
script: |
30+
cd /opt/apps/${{ github.event.repository.name }}
31+
git pull origin main
32+
alembic upgrade head
33+
docker compose -f deploy/docker-compose.yml up -d --build
34+
bash scripts/health-check.sh http://${{ secrets.APP_DOMAIN }}/health

.github/workflows/validate.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Validate Spec
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
validate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
17+
- uses: actions/checkout@v4
18+
with:
19+
repository: towlion/platform
20+
path: _platform
21+
22+
- name: Run spec validator
23+
run: python _platform/validator/validate.py --tier 2 --dir .

0 commit comments

Comments
 (0)