Skip to content

Commit 2728931

Browse files
authored
Merge pull request #4 from kamini08/feature/web-interface
feat(web): FastAPI backend + Next.js frontend with CLI-API parity
2 parents 7d28362 + 93e1781 commit 2728931

36 files changed

Lines changed: 13660 additions & 87 deletions

.coverage

-52 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ jobs:
4848
- name: Type check - mypy
4949
run: mypy --ignore-missing-imports .
5050

51-
- name: Run tests
51+
- name: Run tests (CLI only)
5252
env:
5353
PYTHONPATH: .
54-
run: python -m pytest -q --cov=edgeflowc --cov-report=xml --cov-fail-under=90
54+
run: python -m pytest -q tests --cov=edgeflowc --cov-report=xml --cov-fail-under=90
5555

5656
- name: Generate coverage badge
5757
run: genbadge coverage -i coverage.xml -o coverage.svg

.github/workflows/web-ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Web Stack CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
backend:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-python@v5
11+
with:
12+
python-version: '3.11'
13+
- name: Install backend deps
14+
run: |
15+
python -m pip install --upgrade pip
16+
pip install -r backend/requirements.txt
17+
- name: Lint
18+
run: |
19+
black --check backend
20+
isort --profile black --check-only backend
21+
flake8 backend
22+
mypy --ignore-missing-imports backend
23+
- name: Test backend
24+
env:
25+
PYTHONPATH: .
26+
run: pytest -q --cov=backend --cov-report=xml --cov-fail-under=85
27+
- name: Bandit security scan
28+
run: bandit -r backend -x backend/tests -q
29+
30+
frontend:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: '18'
37+
- name: Install and lint
38+
working-directory: frontend
39+
run: |
40+
npm ci || npm install
41+
npm run lint
42+
npm run type-check
43+
- name: Test
44+
working-directory: frontend
45+
run: npm test -- --coverage --passWithNoTests
46+
- name: E2E placeholder
47+
working-directory: frontend
48+
run: npm run test:e2e
49+
- name: Build
50+
working-directory: frontend
51+
run: npm run build
52+
53+
integration:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Compose build
58+
run: |
59+
docker compose version || true
60+
docker compose build || docker-compose build
61+
- name: Compose up
62+
run: docker compose up -d || docker-compose up -d
63+
- name: Wait for backend
64+
run: |
65+
for i in {1..30}; do curl -sf http://localhost:8000/api/health && break || sleep 2; done
66+
- name: Smoke API
67+
run: |
68+
curl -sf http://localhost:8000/api/version
69+
- name: Compose down
70+
if: always()
71+
run: docker compose down -v || docker-compose down -v

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ parser/.antlr/
88
.coverage
99
coverage.xml
1010
coverage.svg
11+
coverage/
12+
frontend/coverage/
13+
backend/coverage/
14+
htmlcov/
15+
.pytest_cache/
16+
.mypy_cache/
17+
backend/.pytest_cache/
18+
backend/.mypy_cache/

Agents.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# EdgeFlow Development Agents & Rules
2+
3+
## CRITICAL RULES - MUST BE FOLLOWED
4+
5+
### Rule 1: CLI-API Parity (STRICTLY ENFORCED)
6+
Every CLI command MUST have a corresponding API endpoint. NO EXCEPTIONS.
7+
8+
| CLI Command | API Endpoint | Status |
9+
|------------|--------------|--------|
10+
| `python edgeflowc.py config.ef` | `POST /api/compile` ||
11+
| `python edgeflowc.py config.ef --verbose` | `POST /api/compile/verbose` ||
12+
| `python edgeflowc.py --version` | `GET /api/version` ||
13+
| `python edgeflowc.py --help` | `GET /api/help` ||
14+
15+
Enforcement:
16+
- PR will be REJECTED if CLI functionality exists without API endpoint
17+
- PR will be REJECTED if API endpoint exists without CLI equivalent (except /health)
18+
19+
### Rule 2: Pre-PR Checklist (MANDATORY)
20+
Before raising ANY PR:
21+
22+
- [ ] Run `make lint-backend` - MUST PASS
23+
- [ ] Run `make lint-frontend` - MUST PASS
24+
- [ ] Run `make test-backend` - MUST PASS (target ≥90% coverage)
25+
- [ ] Run `make test-frontend` - MUST PASS (target ≥80% coverage)
26+
- [ ] Run `make pre-commit` - ALL CHECKS MUST PASS
27+
- [ ] Update API documentation if endpoints changed
28+
- [ ] Update Agents.md if new CLI commands added
29+
30+
Evidence Required in PR:
31+
```
32+
make pre-commit
33+
```
34+
35+
### Rule 3: Documentation Requirements
36+
Every PR must include:
37+
1. Updated OpenAPI spec (auto-generated by FastAPI)
38+
2. Updated README if user-facing changes
39+
3. Docstrings/JSDoc for all new functions
40+
4. Updated Agents.md for new features
41+
42+
## Development Agents
43+
44+
### Backend Agent
45+
- Maintains API server
46+
- Ensures CLI wrapper functions work correctly
47+
- Responsible for backend tests
48+
- Reviews: API design, security, performance
49+
50+
### Frontend Agent
51+
- Maintains UI components
52+
- Ensures API integration works
53+
- Responsible for frontend tests
54+
- Reviews: UX, accessibility, browser compatibility
55+
56+
### Integration Agent
57+
- Maintains docker-compose setup
58+
- Ensures frontend-backend communication
59+
- Responsible for E2E tests
60+
- Reviews: System integration, deployment
61+
62+
## Workflow
63+
64+
1. Feature development
65+
```
66+
git checkout -b feature/your-feature
67+
# Make changes
68+
make pre-commit # MUST PASS
69+
git add .
70+
git commit -m "feat: your feature"
71+
git push origin feature/your-feature
72+
```
73+
74+
2. PR Template
75+
```
76+
## Changes
77+
- [ ] Added CLI command: `___`
78+
- [ ] Added API endpoint: `___`
79+
- [ ] CLI-API parity maintained
80+
81+
## Testing
82+
- [ ] Backend tests pass
83+
- [ ] Frontend tests pass
84+
- [ ] E2E tests pass
85+
- [ ] Pre-commit checks pass
86+
87+
## Evidence
88+
```
89+
make pre-commit
90+
```
91+
```
92+
93+
## Monitoring
94+
95+
Dashboard tracking:
96+
- CLI commands without API endpoints: 0 (MUST be 0)
97+
- API endpoints without CLI commands: 1 (/health only)
98+
- Test coverage: Backend >90%, Frontend >80%
99+
- Lint violations: 0
100+

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: pre-commit lint-backend lint-frontend test-backend test-frontend run-local
2+
3+
pre-commit: lint-backend lint-frontend test-backend test-frontend
4+
5+
lint-backend:
6+
cd backend && black --check . && isort --profile black --check-only . && flake8 . && mypy --ignore-missing-imports .
7+
8+
lint-frontend:
9+
cd frontend && npm run lint && npm run type-check
10+
11+
test-backend:
12+
cd backend && pytest --cov=backend --cov-report=term-missing -q
13+
14+
test-frontend:
15+
cd frontend && npm test -- --coverage
16+
17+
run-local:
18+
docker-compose up --build
19+

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,30 @@ GitHub Actions runs on pushes and PRs for Python 3.11:
145145
- Tests with coverage (fail below 90%)
146146
- Coverage badge artifact generated via `genbadge`
147147

148+
Web Interface
149+
-------------
150+
Backend (FastAPI):
151+
- App entry: `backend/app.py`
152+
- Endpoints with strict CLI parity:
153+
- `POST /api/compile` (maps to `python edgeflowc.py config.ef`)
154+
- `POST /api/compile/verbose` (maps to `--verbose`)
155+
- `POST /api/optimize` (optimization phase)
156+
- `POST /api/benchmark` (benchmarking)
157+
- `GET /api/version` (maps to `--version`)
158+
- `GET /api/help` (maps to `--help`)
159+
- `GET /api/health` (health check)
160+
161+
Frontend (Next.js + TS):
162+
- Components under `frontend/src/components` and pages under `frontend/src/pages`
163+
- API client in `frontend/src/services/api.ts`
164+
165+
Local run (Docker):
166+
```
167+
docker-compose up --build
168+
# Backend: http://localhost:8000/docs
169+
# Frontend: http://localhost:3000
170+
```
171+
148172
Contributing
149173
------------
150174
- Open a PR with a focused set of changes

backend/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
COPY requirements.txt /app/requirements.txt
5+
RUN pip install --no-cache-dir -r /app/requirements.txt
6+
7+
COPY . /app/backend
8+
9+
EXPOSE 8000
10+
CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "8000"]

backend/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)