In order to start the application in development mode:
- Install dependencies with
yarn
(ornpm install
). - To start the backend:
- First ensure that these environment variables are set:
GIPHY_API_KEY
PIXABAY_API_KEY
- Optionally, you can also set
HOST
andPORT
- by default, backend binds tolocalhost:8000
. - Run
yarn start
(ornpm start
).
- First ensure that these environment variables are set:
- To start the frontend:
- Optionally, set
API_URL
environment variable to the backend base URL. The default value ishttp://localhost:8000
. - Run
yarn frontend-dev
(ornpm run frontend-dev
) - this will run Webpack Dev Server on port8080
.
- Optionally, set
- Point your browser at
http://localhost:8080
.
For production mode (not that the code is in any way production-ready), the frontend application can be bundled into static files by running yarn frontend-build
(or npm run frontend-build
), with API_URL
environment set to the backend base URL.
The generated bundle will be created in dist/frontend
directory.
I have to admit, I rarely deal with CSS directly - not that I'm opposed to it, it just happens that usually, it's somebody else's responsibility. What I'd have done normally, is use Bootstrap framework, customise it with variables, and try to create my own semantic classes based on mixins it provides - this would give me a reasonable baseline easy to expand upon. However, since the task description specifically called for custom CSS, I included only styles written from scratch. As a result, the styling is very rudimentary, and might not be consistent across browsers - I'd definitely say it's the weakest part.
Many parts of the build setup could use improvement. Currently, React and other external libraries are bundled together with application code - it would be good to at least split them off into a separate bundle, or alternatively, load them from CDN, with local fallback.
In a real project, it might make sense to have separate NPM packages for frontend and backend, but that would complicate sharing code (especially types) between the two, so for simplicity, I went with a single package.
- error handling is not consistent
- some loading indicator, when the results are being fetched, would be nice
- responsive images for thumbnails, with resolution depending on screen size