Skip to content

Commit

Permalink
Merge pull request #18 from codeuniversity/feature-merge
Browse files Browse the repository at this point in the history
Feature merge
  • Loading branch information
essaaam authored Nov 12, 2024
2 parents 3d514c6 + 6d5b5d0 commit d2b07cb
Show file tree
Hide file tree
Showing 48 changed files with 2,009 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ jobs:
with:
python-version: '3.11'
- name: Install dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run tests
working-directory: ./backend
run: pytest
45 changes: 38 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ celerybeat.pid
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
backend/.env
backend/.venv
backend/env/
backend/venv/
backend/ENV/
backend/env.bak/
backend/venv.bak/

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -165,3 +165,34 @@ cython_debug/

# Secrets
credentials.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*.tsbuildinfo
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
3. [Project Architecture](#project-architecture)
4. [Data Sources](#data-sources)
5. [Installation](#installation)
- [Normal Installation](#normal-installation)
- [Backend Installation](#backend-installation)
- [Frontend Installation](#frontend-installation)
- [Docker Installation](#docker-installation)
6. [Authentication](#authentication)
7. [Linting and Formatting](#linting-and-formatting)
Expand All @@ -28,22 +29,40 @@ To-do

## Installation

### Normal Installation
### Backend Installation
1. Clone the repository:
```bash
git clone https://github.com/codeuniversity/thf-climate.git
```
2. Create a virtual environment and install the dependencies:
2. Change directory to backend (from thf-climate):
```bash
cd backend
```
3. Create a virtual environment and install the dependencies:
```bash
python -m venv venv
source venv/bin/activate
pip install -r requirements-dev.txt
```
3. Copy the env.sample file to .env and set the required variables:
4. Copy the env.sample file to .env and set the required variables:
```bash
cp env.sample .env
```

### Frontend Installation
1. Change directory to frontend (from thf-climate):
```bash
cd frontend
```
2. Install NPM packages:
```bash
npm install
````
3. Run project locally:
```bash
npm run dev
````

### Docker Installation
1. Clone the repository:
```bash
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions src/main.py → backend/src/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from src.routes.ndvi import ndvi_router

from .weather.router import router as weather_router

app = FastAPI()

origins = ["http://localhost:5173"]

app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.get("/")
def read_root():
Expand Down
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions backend/src/routes/temp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from fastapi import APIRouter, Query

from src.constants import AggregationMethod, LocationName, TemporalResolution
from src.validation.models import (
DataPoint,
TemperatureDataMeta,
TemperatureDataResponse,
)
from src.validation.utils import (
validate_timestamp_in_range,
validate_timestamp_startdate_before_enddate,
)

weather_router = APIRouter()


@weather_router.get("/temp", response_model=TemperatureDataResponse)
async def get_temperature_data(
startDate: int = Query(..., description="Start date as UNIX timestamp in seconds"),
endDate: int = Query(..., description="End date as UNIX timestamp in seconds"),
location: LocationName = Query(..., description="Location name"),
temporalResolution: TemporalResolution = Query(
..., description="Temporal resolution"
),
aggregation: AggregationMethod = Query(..., description="Aggregation method"),
):
validate_timestamp_in_range(startDate)
validate_timestamp_in_range(endDate)
validate_timestamp_startdate_before_enddate(startDate, endDate)

# do the real processing here :)

# just a dummy response for now
sample_response = TemperatureDataResponse(
meta=TemperatureDataMeta(
unit="Celsius",
location=location,
startDate=startDate,
endDate=endDate,
temporalResolution=temporalResolution,
aggregation=aggregation,
),
data=[
DataPoint(value=13.45, timestamp=1617321600),
DataPoint(value=15.5, timestamp=1617555600),
DataPoint(value=24.0, timestamp=1677721600),
],
)
return sample_response
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions frontend/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}
8 changes: 8 additions & 0 deletions frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"tsconfig.json": "tsconfig.*.json, env.d.ts",
"vite.config.*": "jsconfig*, vitest.config.*, cypress.config.*, playwright.config.*",
"package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .eslint*, eslint*, .prettier*, prettier*, .editorconfig"
}
}
29 changes: 29 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frontend

This template should help get you started developing with Vue 3 in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).

## Customize configuration

See [Vite Configuration Reference](https://vite.dev/config/).

## Project Setup

```sh
npm install
```

### Compile and Hot-Reload for Development

```sh
npm run dev
```

### Compile and Minify for Production

```sh
npm run build
```
16 changes: 16 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Climates of Tempelhofer Feld</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>

</html>
8 changes: 8 additions & 0 deletions frontend/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit d2b07cb

Please sign in to comment.