Skip to content

Commit 4b7365c

Browse files
Merge pull request #18 from Rich-T-kid/feature/http-web-server
Integrate the frontend http server into pre-release
2 parents fea2b2d + a32b366 commit 4b7365c

35 files changed

Lines changed: 1256 additions & 12 deletions

.env

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Server Configuration
2+
PORT=8000
3+
HOST=0.0.0.0
4+
5+
# Logging Configuration
6+
# Options: prod, info, debug
7+
LOGGING_MODE=info
8+
9+
# Testing Configuration
10+
TEST_SERVER_URL=http://localhost:8000

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Server Configuration
2+
PORT=8000
3+
HOST=0.0.0.0
4+
5+
# Logging Configuration
6+
# Options: prod, info, debug
7+
LOGGING_MODE=info
8+
9+
# Testing Configuration
10+
TEST_SERVER_URL=http://localhost:8000
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Frontend Tests
2+
3+
on:
4+
push:
5+
branches: [ main, pre-release ]
6+
paths:
7+
- 'src/FrontEnd/**'
8+
- '.github/workflows/frontend-test.yml'
9+
pull_request:
10+
branches: [ main, pre-release ]
11+
paths:
12+
- 'src/FrontEnd/**'
13+
- '.github/workflows/frontend-test.yml'
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python 3.12
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -r src/FrontEnd/requirements.txt
31+
32+
- name: Run tests
33+
run: |
34+
cd src/FrontEnd
35+
pytest -v -m "not integration"

CONTRIBUTING.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ We use a Makefile to simplify common development tasks. All commands should be r
3232
make rust-test
3333
```
3434

35-
### Run All Tests (Go + Rust)
35+
### Frontend Tests
36+
- Run all tests
37+
```bash
38+
make frontend-test
39+
```
40+
41+
### Run All Tests (Go + Rust + Frontend)
3642
- Run tests for both backends
3743
```bash
3844
make test-all
@@ -116,6 +122,11 @@ make go-run
116122
make rust-run
117123
```
118124
125+
### Build and Run Frontend
126+
```bash
127+
make frontend-run
128+
```
129+
119130
### Run All Tests
120131
```bash
121132
make test-all
@@ -125,6 +136,7 @@ Or run individually:
125136
```bash
126137
make go-test
127138
make rust-test
139+
make frontend-test
128140
```
129141
130142
### Run Linters

Makefile

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help go-test rust-test go-run rust-run go-lint rust-lint go-fmt rust-fmt test-all lint-all fmt-all pre-push
1+
.PHONY: help go-test rust-test go-run rust-run go-lint rust-lint go-fmt rust-fmt frontend-test frontend-run frontend-docker-build frontend-docker-run frontend-docker-down frontend-setup test-all lint-all fmt-all pre-push
22

33
# Default target
44
help:
@@ -11,7 +11,13 @@ help:
1111
@echo " make rust-lint - Run Rust linter and formatter check"
1212
@echo " make go-fmt - Format Go code"
1313
@echo " make rust-fmt - Format Rust code"
14-
@echo " make test-all - Run all tests (Go + Rust)"
14+
@echo " make frontend-test - Run Python/Frontend tests"
15+
@echo " make frontend-run - Run Frontend server (without Docker)"
16+
@echo " make frontend-setup - Setup Python virtual environment and install dependencies"
17+
@echo " make frontend-docker-build - Build Frontend Docker image"
18+
@echo " make frontend-docker-run - Run Frontend using Docker Compose"
19+
@echo " make frontend-docker-down - Stop Frontend Docker containers"
20+
@echo " make test-all - Run all tests (Go + Rust + Frontend)"
1521
@echo " make lint-all - Run all linters (Go + Rust)"
1622
@echo " make fmt-all - Format all code (Go + Rust)"
1723
@echo " make pre-push - Run fmt, lint, and test (use before pushing)"
@@ -70,8 +76,47 @@ rust-fmt-check:
7076
@echo "Checking Rust formatting..."
7177
cd src/Backend/opti-sql-rs && cargo fmt --check
7278

79+
# Frontend targets
80+
frontend-setup:
81+
@echo "Setting up Python virtual environment..."
82+
rm -rf src/FrontEnd/venv
83+
cd src/FrontEnd && python3.12 -m venv --without-pip venv
84+
@echo "Installing pip..."
85+
cd src/FrontEnd && . venv/bin/activate && curl -sS https://bootstrap.pypa.io/get-pip.py | python
86+
@echo "Installing dependencies..."
87+
cd src/FrontEnd && . venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt
88+
@echo "Frontend setup completed! Activate with: cd src/FrontEnd && source venv/bin/activate"
89+
90+
frontend-test: frontend-setup
91+
@echo "Running Frontend/Python tests..."
92+
cd src/FrontEnd && . venv/bin/activate && pytest -m "not integration"
93+
94+
frontend-run:
95+
@echo "Running Frontend server..."
96+
cd src/FrontEnd && . venv/bin/activate && python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8005
97+
98+
frontend-docker-build:
99+
@echo "Building Frontend Docker image..."
100+
@if [ ! -f src/FrontEnd/.env ]; then \
101+
echo "Creating .env file from root .env..."; \
102+
cp .env src/FrontEnd/.env; \
103+
fi
104+
cd src/FrontEnd && docker compose build
105+
106+
frontend-docker-run:
107+
@echo "Running Frontend with Docker Compose..."
108+
@if [ ! -f src/FrontEnd/.env ]; then \
109+
echo "Creating .env file from root .env..."; \
110+
cp .env src/FrontEnd/.env; \
111+
fi
112+
cd src/FrontEnd && docker compose up -d
113+
114+
frontend-docker-down:
115+
@echo "Stopping Frontend Docker containers..."
116+
cd src/FrontEnd && docker compose down
117+
73118
# Combined targets
74-
test-all: go-test rust-test
119+
test-all: go-test rust-test frontend-test
75120
@echo "All tests completed!"
76121

77122
lint-all: go-lint rust-lint

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A high-performance, in-memory query execution engine.
44

55
![Go Tests](https://github.com/Rich-T-kid/OptiSQL/actions/workflows/go-test.yml/badge.svg)
66
![Rust Tests](https://github.com/Rich-T-kid/OptiSQL/actions/workflows/rust-test.yml/badge.svg)
7+
![Frontend Tests](https://github.com/Rich-T-kid/OptiSQL/actions/workflows/frontend-test.yml/badge.svg)
8+
79

810
## Overview
911

@@ -20,6 +22,8 @@ OptiSQL is a custom in-memory query execution engine. The backend (physical exec
2022
- Go 1.24+
2123
- Rust 1.70+
2224
- C++23
25+
- Python 3.11+
26+
- Docker 29+
2327
- Make
2428
- git
2529

@@ -36,6 +40,13 @@ make go-run
3640
# Build and run Rust backend
3741
make rust-run
3842

43+
# Frontend setup and run
44+
make frontend-setup # Create venv and install dependencies
45+
make frontend-run # Run locally without Docker
46+
# OR with Docker
47+
make frontend-docker-build
48+
make frontend-docker-run
49+
3950
# Run all tests
4051
make test-all
4152

@@ -58,7 +69,10 @@ OptiSQL/
5869
│ │ └── opti-sql-rs/ # Rust implementation (Go clone for learning)
5970
│ │ ├── src/project/ # Core project logic
6071
│ │ └── src/ # Query processing modules
61-
│ └── FrontEnd/ # C++ frontend (in development)
72+
│ └── FrontEnd/ # Python/FastAPI HTTP server (C++ query processing in progress)
73+
│ ├── app/ # API endpoints and logic
74+
│ ├── tests/ # Frontend tests
75+
│ └── Dockerfile # Docker configuration
6276
├── .github/workflows/ # CI/CD pipelines
6377
├── Makefile # Development commands
6478
└── CONTRIBUTING.md # Contribution guidelines

src/Backend/opti-sql-go/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module opti-sql-go
22

3-
go 1.24.0
3+
go 1.23
44

55
require (
66
github.com/apache/arrow/go/v15 v15.0.2

src/FrontEnd/.dockerignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
env/
8+
venv/
9+
ENV/
10+
*.egg-info/
11+
dist/
12+
build/
13+
14+
# Testing
15+
.pytest_cache/
16+
.coverage
17+
htmlcov/
18+
19+
# IDE
20+
.vscode/
21+
.idea/
22+
*.swp
23+
*.swo
24+
25+
# Git
26+
.git/
27+
.gitignore
28+
29+
# Documentation
30+
*.md
31+
tests/
32+
33+
# Other
34+
.DS_Store
35+
*.log
36+
swagger.yml
37+
generate_swagger.py
38+
.env.example

src/FrontEnd/.env

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Server Configuration
2+
PORT=8000
3+
HOST=0.0.0.0
4+
5+
# Logging Configuration
6+
# Options: prod, info, debug
7+
LOGGING_MODE=info
8+
9+
# Testing Configuration
10+
TEST_SERVER_URL=http://localhost:8000

src/FrontEnd/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
# Install dependencies
6+
COPY requirements.txt .
7+
RUN pip install --no-cache-dir -r requirements.txt
8+
9+
# Copy application code
10+
COPY . .
11+
COPY ../../.env
12+
13+
# Expose port (will be read from config.yml)
14+
EXPOSE 8000
15+
16+
# Run the application
17+
CMD ["python", "-m", "app.main"]

0 commit comments

Comments
 (0)