To run this app you need Docker installed on your system.
- Make sure you don't have any other running containers on ports
5432,3000and6379. cdinto the project's folder, and rundocker-compose up.- Open http://localhost:3000 with your browser.
Results to be shown on the List Teams page are cached using Redis. After the query is run through PostgreSQL, the results are stored in Redis for future reference. Every time a new team is created, the Redis entry containing the previously cached results is deleted.
- Database credentials are read from a
.envfile. Normally, I would have excluded such file from source control, but considering this is an evaluation project, which has to be run on your side as well, I decided to add said file to source control. src\helpers\db\dbHelper.tscontains functions for performing data persistence operations. Normally, I would've modeled this after the Repository pattern (and I tried to at first), but Next.js 13 doesn't allow classes with async methods in a "use server" file (and when trying to use one, it raises an error specifying that "Only async functions are allowed to be exported in a "use server" file").- I didn't use an external library to implement the form to create a new team because for this specific task I considered it would have been a bit overkill. However, you can take a look at the
employee-registrationrepository on my GitHub page, where I built a form using React Hook Form. - In regards to the folder structure of the project, while colocating page folders with directories to accommodate other kinds of files (e.g. components, styles, etc) is definitely possible (because only the contents returned by
page.jsorroute.jsare publically addressable), I decided not to because personally I find it better to have routes insideappand everything else in same-level directories insidesrc. - Inside each file I followed what Robert C. Martin calls the Stepdown Rule (and describes at page 37 of his book Clean Code - A Handbook of Agile Software Craftsmanship). According to it, code should be read like a top-down narrative, with every function followed by those at the next level of abstraction.
- Both Create Team and Edit Team pages use a horizontally scrollable container to accommodate Pokémon cards.
After each create or edit operation performed, I would redirect to the home page (or to the list page, this really comes down to personal preference) and show a simple toast notification to inform the user if the operation has been successful.