This is a hybrid Next.js + Python app that uses Next.js as the frontend and FastAPI as the API backend.
First, install the dependencies:
npm install
# or
yarn
# or
pnpm install
Then, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 with your browser to see the result.
The FastApi server will be running on http://127.0.0.1:8000 – feel free to change the port in package.json
(you'll also need to update it in next.config.js
).
To learn more about Next.js, take a look at the following resources:
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
This repository uses Black
for Python and ESLint
for JS/TS to enforce code style standards. We also use MyPy
to perform static type checking on Python code. The pre-commit hook runs the formatters automatically before each commit, helping maintain code consistency across the project.
pip install pre-commit
.pre-commit-config.yaml
:
pre-commit install
This command sets up pre-commit to automatically run ESLint, Black, and MyPy before each commit.Running Black Automatically: After setup, every time you attempt to commit code, Black will check the staged files and apply formatting if necessary. If files are reformatted, the commit will be stopped, and you’ll need to review the changes before committing again.
Bypassing the Hook: If you want to skip the pre-commit hook for a specific commit, use the --no-verify flag with your commit command:
git commit -m "your commit message" --no-verify
.
Note: The --no-verify
flag is helpful in cases where you need to make a quick commit without running the pre-commit checks, but it should be used sparingly to maintain code quality. CI pipeline will fail during the pull request
action if the code is not formatted.
Running Pre-commit on All Files: If you want to format all files in the repository, use:
pre-commit run --all-files
This project uses Docker and Docker Compose to run the application, which includes the frontend, backend, and postgres database.
docker-compose up -d
This will:Access the Application:
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
docker exec -it my_postgis_db psql -U postgres -d qsdatabase
docker exec -it datasci-earthquake-backend-1 python <path/to/script>
Note: If you modify the Dockerfile
or other build contexts (e.g., .env
, requirements.txt
, package.json
), you should run docker-compose up -d --build
to rebuild the images and apply the changes!
To stop and shut down the application:
Stop Docker Compose: In the same directory where the docker-compose.yml
file is located, press Ctrl + C
in the terminal where the app is running.
Bring Down the Containers: If you want to stop and remove the containers completely, run:
docker-compose down
This will:
Note: If you want to start with a clean slate and remove all data inside the containers, run docker-compose down -v
.
We use GitHub Secrets to store sensitive environment variables. A template .env.example
file is provided in the repository as a reference. Only users with write access to the repository can manually trigger the Generate .env File
workflow, which creates and uploads the actual .env
file as an artifact.
Note: Before starting work on the project, make sure to:
Generate .env File
workflow and download the artifact..env
.The file is organized into three main sections:
NODE_ENV
variable that determines in which environment the Node.js application is running, and the token needed to access Mapbox APIs.