Skip to content

Commit 41374f0

Browse files
committed
Placeholdr backend
Signed-off-by: anuunchin <88698977+anuunchin@users.noreply.github.com>
1 parent 85f94ee commit 41374f0

4 files changed

Lines changed: 76 additions & 26 deletions

File tree

CONTRIBUTING.md

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,20 @@ brew install node@20
9999
brew install python@3.11
100100
```
101101

102-
**Go 1.21+** (for WebRTC)
103-
```bash
104-
brew install go@1.21
105-
```
106-
107-
108102
**uv** (Python package manager)
109103
```bash
110104
curl -LsSf https://astral.sh/uv/install.sh | sh
111105
# or on mac
112106
brew install uv
113107
```
114108

115-
**golangci-lint** (Go linter)
109+
**Docker** (for containerization)
116110
```bash
117-
brew install golangci-lint
111+
brew install --cask docker
118112
```
119113

114+
## Development
115+
120116
#### Install dependencies
121117

122118
After installing the tools above, run:
@@ -128,15 +124,50 @@ make dev
128124
This will:
129125
- Install frontend dependencies (npm packages)
130126
- Create Python virtual environment and install backend dependencies
131-
- Download Go modules
132127

133-
#### Running Linters
128+
#### Formatting
129+
130+
Format your code before committing to maintain consistent style:
131+
132+
```bash
133+
make format # Format all code (frontend and backend)
134+
make format-frontend # Format frontend with Prettier
135+
make format-backend # Format backend with Ruff
136+
```
137+
138+
#### Running linters
139+
140+
Linting catches code issues and enforces style guidelines. Always run before pushing:
134141

135142
```bash
136-
make lint # Lint all components
137-
make lint-frontend # Lint frontend only
138-
make lint-backend # Lint backend only
139-
make lint-go # Lint Go code only
143+
make lint # Lint all components (includes type checking)
144+
make lint-frontend # Lint frontend with ESLint
145+
make lint-backend # Lint backend with Ruff
146+
make type-check-backend # Type check backend with mypy
140147
```
141148

142-
Before you push your changes, run the linters above and address lint errors if any.
149+
Before you push your changes, run `make lint` and address any errors.
150+
151+
#### Running tests
152+
153+
```bash
154+
make test # Run all tests (frontend and backend)
155+
make test-frontend # Run frontend tests with Vitest
156+
make test-backend # Run backend tests with pytest
157+
```
158+
159+
#### Docker commands
160+
161+
Build and run Docker containers locally:
162+
163+
```bash
164+
make docker-build # Build all Docker images
165+
make docker-build-frontend # Build frontend image
166+
make docker-build-backend # Build backend image
167+
168+
make docker-run-frontend # Run frontend container (opens browser)
169+
make docker-run-backend # Run backend container (also opens browser)
170+
171+
make docker-stop # Stop all running containers
172+
make docker-clean # Stop containers and remove images
173+
```

Makefile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help lint lint-frontend lint-backend type-check-backend test test-frontend test-backend format format-frontend format-backend docker-build docker-build-frontend docker-build-backend docker-run-frontend docker-run-backend docker-clean
1+
.PHONY: help lint lint-frontend lint-backend type-check-backend test test-frontend test-backend format format-frontend format-backend docker-build docker-build-frontend docker-build-backend docker-run-frontend docker-run-backend docker-stop docker-clean
22

33
help:
44
@echo "make"
@@ -38,12 +38,14 @@ help:
3838
@echo " runs frontend container on port 8080"
3939
@echo " docker-run-backend"
4040
@echo " runs backend container on port 8000"
41+
@echo " docker-stop"
42+
@echo " stops running containers"
4143
@echo " docker-clean"
42-
@echo " removes built Docker images"
44+
@echo " stops containers and removes Docker images"
4345

4446
dev: install
4547

46-
install: install-frontend install-backend install-go
48+
install: install-frontend install-backend
4749

4850
install-frontend:
4951
cd src/frontend && npm install
@@ -97,8 +99,16 @@ docker-run-frontend:
9799
@echo "To stop: docker stop robot-frontend-dev"
98100

99101
docker-run-backend:
100-
docker run --rm -p 8000:8000 robot-backend:latest
102+
@echo "Starting backend container..."
103+
@docker run -d --rm -p 8000:8000 --name robot-backend-dev robot-backend:latest
104+
@sleep 1
105+
@echo "Opening browser at http://localhost:8000"
106+
@open http://localhost:8000 || echo "Please open http://localhost:8000 in your browser"
107+
@echo "To stop: docker stop robot-backend-dev"
108+
109+
docker-stop:
110+
@docker stop robot-frontend-dev robot-backend-dev 2>/dev/null || true
101111

102-
docker-clean:
103-
docker rmi robot-frontend:latest robot-backend:latest || true
112+
docker-clean: docker-stop
113+
@docker rmi robot-frontend:latest robot-backend:latest || true
104114

src/backend/main.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
"""
2-
Minimal placeholder file for CI
3-
"""
1+
"""PLACEHOLDER"""
2+
3+
from http.server import HTTPServer, BaseHTTPRequestHandler
4+
import json
45

56

67
def hello() -> str:
78
return "Hello from backend"
89

910

11+
class Handler(BaseHTTPRequestHandler):
12+
def do_GET(self) -> None:
13+
self.send_response(200)
14+
self.send_header("Content-type", "application/json")
15+
self.end_headers()
16+
response = {"status": "ok", "message": hello()}
17+
self.wfile.write(json.dumps(response).encode())
18+
19+
1020
if __name__ == "__main__":
11-
print(hello())
21+
HTTPServer(("0.0.0.0", 8000), Handler).serve_forever()

src/frontend/eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ export default [
1616
},
1717
},
1818
];
19-

0 commit comments

Comments
 (0)