This repository contains two main directories: api and database. The database directory includes a Docker Compose file for starting a MySQL container and a phpMyAdmin container. The api directory contains a NestJS and Prisma backend application.
Before you begin, ensure you have met the following requirements:
- Docker: Make sure Docker is installed on your machine. You can download it from Docker's official website.
- Node.js and npm: Ensure Node.js and npm are installed. You can download them from Node.js official website.
- Git: Ensure Git is installed for version control. You can download it from Git's official website.
- Chromium: Ensure Chromium is installed for running tests. You can download it from Chromium's official website.
Follow these instructions to set up and run the project on your local machine.
git clone git@github.com:paulwehage/sosd-backend.git
cd sosd-backend-
Navigate to the
databasedirectory:cd database -
Start the MySQL and phpMyAdmin containers using Docker Compose:
docker-compose up -d
This will start the MySQL container and phpMyAdmin container in detached mode.
-
Access phpMyAdmin:
Open your browser and go to
http://localhost:8080. You can log in using the following credentials:- Server:
mysql - Username:
root - Password:
root_password
Note: You can change these credentials in the
docker-compose.ymlfile if needed. - Server:
-
Prisma Setup:
-
Go back to the root of the repository and navigate to the
apidirectory:cd ../api -
Run the following command to apply the Prisma schema to the database:
npx prisma db push
-
After the migration is applied, you can seed the database with example data:
npx prisma db seed
-
-
Navigate to the
apidirectory:cd ../api -
Install the dependencies:
npm install
-
Start the NestJS application:
npm run start
This will start the API server in development mode.
-
Once the API server is running, you can access it at
http://localhost:3000. -
Use tools like Postman or curl to test the API endpoints.
The API documentation is available at http://localhost:3000/api.
├── api
│ ├── prisma
| | ├── schema.prisma
| | ├── seed.ts
| | ├── seed-data.json
│ ├── src
| | ├── controllers
| | ├── services
| | ├── dtos
| | ├── app.module.ts
| | ├── main.ts
│ ├── test
│ ├── .env.example
│ ├── nest-cli.json
│ ├── package.json
│ ├── tsconfig.json
│ └── tsconfig.build.json
├── database
│ ├── docker-compose.yml
└── README.md
- Database Connection Issues: Ensure the Docker containers are running and the database credentials in the
.envfile are correct. - Port Conflicts: If the default ports (3306 for MySQL, 8080 for phpMyAdmin, 3000 for the API) are in use, you can change them in the respective configurations.