Svelte_FastAPI_Boilerplate Svelte Themes

Svelte_fastapi_boilerplate

                   

Weather

A weather app that caches its data from the OpenWeatherMap API(uses Svelte and FastAPI)

Logo

Run the stack

Create a .env file with the following contents

DEV=true
WEATHER_API_KEY=<OPENWEATHERMAP_KEY>

Then run the command below:

docker compose up --build  # might want to add -d to run detached 

then access http://127.0.0.1

Highlights

  • The backend uses FastAPI to generate the OpenAPI specification.
  • The frontend uses openapi-client-axios client to access the backend using the specs generated by FastAPI.
  • The Frontend uses Svelte, and it is served with a nginx container
  • The nginx config is mapping path /api/ to the backend container, so the frontend does not experience CORS errors
  • Cache is implemented using TTL in Redis

Cache

Verify that cache is working as expected by running the app and triggering get requests to the backend quickly. You will notice a log message showing that cache content is being used

Logo

Future

  • Add mod security to the nginx container to implement WAF.
  • Update frontend libraries
  • Implement unit testing
  • Add docker compose file watch
  • Add more animations to the frontend

Top categories

Loading Svelte Themes