This is a project of SF Civic Tech https://www.sfcivictech.org/
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 https://localhost:3000 with your browser to see the result.
The FastApi server will be running on https://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:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
- FastAPI Documentation - learn about FastAPI features and API.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
This project uses Docker and Docker Compose to run the application, which includes the frontend, backend, and postgres database.
- Docker: Make sure Docker is installed on your machine. Get Docker.
- Docker Compose: Ensure Docker Compose is installed (usually included with Docker Desktop).
- Run Docker Compose: From the project root directory (where the docker-compose.yml file is located), run:
docker-compose up -d
This will:
- Build the necessary Docker images (if not already built).
- Start all services defined in the docker-compose.yml file (e.g., frontend, backend, database).
- Access the Application:
- The app is running at https://localhost:3000.
- The API is accessible at https://localhost:8000.
- The Postgres instance with PostGIS extension is accessible at https://localhost:5432.
To stop and shut down the application:
-
Stop Docker Compose: In the same directory where the
docker-compose.yml
file is located, pressCtrl + 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:- Stop all services.
- Remove the containers, but it will not delete volumes (so the database data will persist).
The .env.local
file contains environment variables used in the application to configure settings for both the backend and frontend components. If it contains sensitive information, .env.local
should not be checked into version control for security reasons. Right now there is no sensitive information but later secret management tools will be introduced.
The file is organized into three main sections:
- Postgres Environment Variables. This section contains the credentials to connect to the PostgreSQL database, such as the username, password, and the name of the database.
- Backend Environment Variables. These variables are used by the backend (i.e., FastAPI) to configure its behavior and to connect to the database and the frontend application.
- Frontend Environment Variables. This section contains the base URL for API calls to the backend and
NODE_ENV
variable that determines in which environment the Node.js application is running.