Skip to content

Commit 975b292

Browse files
committed
feat: initial scaffold from TechAPI split
Splits the validation, API, dump, and site code out of TechAPI so the upstream repo can hold only the curated dataset. - app/: FastAPI service + validate.py / seed.py / dump.py (merged from the old scripts/ package) - tests/: existing unit + integration suite - site/: Astro intro/playground (Pages deploy target) - docs/: SPEC / DATA_PIPELINE / DEVELOPMENT carried over - workflows/: validate-data (workflow_call), refresh-data (weekly dump), deploy-pages, test — all updated to check out GetTechAPI/TechAPI as a sibling and read data via TECHAPI_DATA_DIR Data path defaults to ../TechAPI/data for local dev; override with the TECHAPI_DATA_DIR environment variable.
0 parents  commit 975b292

72 files changed

Lines changed: 11817 additions & 0 deletions

Some content is hidden

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

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.git
2+
.github
3+
.venv
4+
venv
5+
__pycache__
6+
*.pyc
7+
.pytest_cache
8+
.mypy_cache
9+
.ruff_cache
10+
.coverage
11+
htmlcov
12+
tests
13+
docs
14+
*.db
15+
*.sqlite3
16+
.env
17+
.env.*
18+
!.env.example

.env.example

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# === Database ===
2+
# Local dev defaults to SQLite (no external service needed).
3+
# For Postgres (docker-compose / production), use a postgresql+psycopg URL, e.g.:
4+
# postgresql+psycopg://techapi:techapi@db:5432/techapi
5+
DATABASE_URL=sqlite:///./techapi.db
6+
DATABASE_POOL_SIZE=10
7+
8+
# === Supabase (production Postgres host) ===
9+
SUPABASE_URL=https://xxx.supabase.co
10+
SUPABASE_ANON_KEY=eyJ...
11+
SUPABASE_SERVICE_KEY=eyJ... # secret, never expose to clients
12+
13+
# === API ===
14+
API_HOST=0.0.0.0
15+
API_PORT=8000
16+
API_ENV=development # development | staging | production
17+
API_BASE_URL=http://localhost:8000
18+
19+
# === Security ===
20+
SECRET_KEY=change-me # JWT/session (Phase 4+)
21+
CORS_ORIGINS=http://localhost:3000,https://techpicks.app
22+
23+
# === Logging ===
24+
LOG_LEVEL=INFO
25+
SENTRY_DSN=https://... # optional
26+
27+
# === External Services ===
28+
REDIS_URL=redis://localhost:6379 # optional (Phase 2+)
29+
30+
# === Scoring ===
31+
SCORING_CONFIG_PATH=./config/scoring.yaml

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Default owners for everything in the repo.
2+
# TODO: replace with the maintainer's GitHub handle or org team before Phase 1.
3+
* @GetTechAPI/maintainers
4+
5+
/data/ @GetTechAPI/maintainers
6+
/app/ @GetTechAPI/maintainers
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "🐛 Bug report"
2+
description: Report a bug in the API or tooling
3+
labels: ["type:bug"]
4+
body:
5+
- type: textarea
6+
id: what-happened
7+
attributes:
8+
label: What happened?
9+
description: A clear description of the bug.
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: reproduce
14+
attributes:
15+
label: Steps to reproduce
16+
description: Include the exact request (curl) where possible.
17+
placeholder: |
18+
curl https://api.techapi.dev/v1/smartphones/galaxy-s25
19+
validations:
20+
required: true
21+
- type: textarea
22+
id: expected
23+
attributes:
24+
label: Expected behavior
25+
validations:
26+
required: true
27+
- type: input
28+
id: request-id
29+
attributes:
30+
label: request_id (if any)
31+
description: The `request_id` from the error response helps us trace it.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "📥 Data addition"
2+
description: Request a new device, SoC, or GPU
3+
labels: ["type:data", "data:missing"]
4+
body:
5+
- type: dropdown
6+
id: category
7+
attributes:
8+
label: Category
9+
options:
10+
- smartphone
11+
- soc
12+
- gpu
13+
- brand
14+
validations:
15+
required: true
16+
- type: input
17+
id: name
18+
attributes:
19+
label: Name
20+
placeholder: "Galaxy S25 FE"
21+
validations:
22+
required: true
23+
- type: textarea
24+
id: sources
25+
attributes:
26+
label: Source URLs (at least one)
27+
description: Manufacturer spec sheet preferred (§9.2).
28+
validations:
29+
required: true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "✏️ Data correction"
2+
description: Correct an existing spec value
3+
labels: ["type:data", "data:incorrect"]
4+
body:
5+
- type: input
6+
id: slug
7+
attributes:
8+
label: Resource slug
9+
placeholder: "galaxy-s25"
10+
validations:
11+
required: true
12+
- type: input
13+
id: field
14+
attributes:
15+
label: Field to correct
16+
placeholder: "battery_mah"
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: correction
21+
attributes:
22+
label: Current value → correct value (with source)
23+
placeholder: |
24+
current: 4500
25+
correct: 4000
26+
source: https://www.samsung.com/...
27+
validations:
28+
required: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "✨ Feature request"
2+
description: Propose a new feature or endpoint
3+
labels: ["type:feature"]
4+
body:
5+
- type: textarea
6+
id: problem
7+
attributes:
8+
label: Problem / motivation
9+
description: What are you trying to do? Who benefits?
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: proposal
14+
attributes:
15+
label: Proposed solution
16+
validations:
17+
required: true
18+
- type: checkboxes
19+
id: scope
20+
attributes:
21+
label: Scope check
22+
options:
23+
- label: This is generalizable to all consumers (not TechPicks-specific, see ADR-008).
24+
required: true

.github/pull_request_template.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- PR title must follow Conventional Commits (§14.5), e.g. feat(api): add /compare endpoint -->
2+
3+
## What & why
4+
5+
<!-- What does this change and why? Link issues with "Closes #123". -->
6+
7+
## How
8+
9+
<!-- Key implementation notes. -->
10+
11+
## Testing
12+
13+
<!-- How was this verified? Paste test output or screenshots. -->
14+
15+
## Checklist
16+
17+
- [ ] Type hints on all new functions (§0.5.4)
18+
- [ ] Tests added/updated (§15)
19+
- [ ] `ruff check` and `pytest` pass locally
20+
- [ ] Data changes pass `python -m app.validate`
21+
- [ ] SPEC/README updated if behavior changed (§0.5.4)

.github/workflows/deploy-pages.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: deploy-pages
2+
3+
# Builds the Astro site (intro homepage + OpenAPI docs) together with the static
4+
# JSON data dump and deploys everything to GitHub Pages. The dataset does not need
5+
# to be complete — whatever is curated in data/ is published.
6+
# Enable once: Settings → Pages → Source = GitHub Actions.
7+
on:
8+
push:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/checkout@v4
28+
with:
29+
repository: GetTechAPI/TechAPI
30+
path: TechAPI
31+
32+
- uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.12"
35+
cache: pip
36+
37+
- name: Install Python deps
38+
run: pip install -e .
39+
40+
- name: Validate curated data
41+
env:
42+
TECHAPI_DATA_DIR: ${{ github.workspace }}/TechAPI/data
43+
run: python -m app.validate
44+
45+
- name: Generate static JSON dump + openapi.json
46+
env:
47+
TECHAPI_DATA_DIR: ${{ github.workspace }}/TechAPI/data
48+
run: python -m app.dump --output dump
49+
50+
- uses: actions/setup-node@v4
51+
with:
52+
node-version: "22"
53+
cache: npm
54+
cache-dependency-path: site/package-lock.json
55+
56+
- name: Build Astro site
57+
run: |
58+
cd site
59+
npm ci
60+
npm run build
61+
62+
- name: Assemble site (Astro dist + JSON data dump)
63+
run: |
64+
mkdir -p _site
65+
cp -r site/dist/. _site/
66+
cp -r dump/. _site/
67+
touch _site/.nojekyll
68+
69+
- uses: actions/upload-pages-artifact@v3
70+
with:
71+
path: _site
72+
73+
deploy:
74+
needs: build
75+
runs-on: ubuntu-latest
76+
environment:
77+
name: github-pages
78+
url: ${{ steps.deployment.outputs.page_url }}
79+
steps:
80+
- id: deployment
81+
uses: actions/deploy-pages@v4

.github/workflows/refresh-data.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: refresh-data
2+
3+
# Static-dump refresh (PokeAPI api-data style + git-scraping pattern).
4+
# Pulls the latest TechAPI data, validates, regenerates dump/.
5+
# - weekly schedule keeps the static dump fresh
6+
# - manual trigger for on-demand rebuilds
7+
on:
8+
schedule:
9+
- cron: "17 6 * * 1" # Mondays 06:17 UTC (offset minute is polite, per git-scraping)
10+
push:
11+
branches: [main]
12+
paths:
13+
- "app/**"
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
dump:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/checkout@v4
26+
with:
27+
repository: GetTechAPI/TechAPI
28+
path: TechAPI
29+
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.12"
33+
cache: pip
34+
35+
- name: Install
36+
run: pip install -e .
37+
38+
- name: Validate curated data
39+
env:
40+
TECHAPI_DATA_DIR: ${{ github.workspace }}/TechAPI/data
41+
run: python -m app.validate
42+
43+
- name: Generate static dump
44+
env:
45+
TECHAPI_DATA_DIR: ${{ github.workspace }}/TechAPI/data
46+
run: python -m app.dump
47+
48+
- name: Upload static dump artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: techapi-static-dump
52+
path: dump/
53+
54+
# To serve a public static API, enable Pages and swap the step above for:
55+
# - uses: actions/upload-pages-artifact@v3
56+
# with: { path: dump/ }
57+
# - uses: actions/deploy-pages@v4
58+
# (requires `permissions: pages: write, id-token: write` and Settings → Pages → GitHub Actions)

0 commit comments

Comments
 (0)