An api manager using Fastify, Vite, MariaDB on Docker. We will manage some books in this project.
- /docker-mariadb
- ./docker-compose.yaml => our database inside a container and inside a compose
- ./db-data => generated by docker where we store data for db (it is a volume)
- ./.env => generated by you (See the third step)
- /fastify-backend
- ./prisma => it is for storing migrations, schema settings, and seeding options
- ./src/models => we define here our routes, services, handlers ...
- ./src/utils => it is for utilities
- /frontend => it is for handling Books (admin site) (Update, Delete, Create)
- /react-frontend => it is for the clients, it is the real frontend
- ./src => it is holding the react components, assets, constants and hooks
- Docker
- Node.js
- GIT
- Database manager (like DBeaver)
How to start and initiate it1
- git clone 'the repository URL'
git clone https://github.com/20HDMI04/api-manager-and-test.git
- npm install in each folder to get the dependecies
npm install
- adding the .env folder to /fastify-backend and /docker-mariadb the /fastify-backend/.env structure
DATABASE_URL="db_service://*hostname*:*password*@*ip*:*socket*/*your db name*"
DBNAME=**your db name**
DBPASSWORD=**your db password**
the /docker-mariadb/.env structure
DBNAME=**your db name**
DBPASSWORD=**your db password**
- RUN the db with docker
**in the /docker-mariadb directory**
docker compose up
- prisma migration
npx prisma migrate dev --name **your migration name**
- prisma db seed
npx prisma db seed
to reset the db you can run:
npx run reset
OR
prisma db push --force-reset
- RUN the backend and the frontend
**in the /fastify-backend and the /frontend directory**
npm run dev
made by Swagger you can find it here: http://localhost:3000/documentation
you can't watch it without the backend
Footnotes
-
not tested so it might not work (it is for the sake of understanding the backend) ↩