Skip to content

paulwehage/sosd-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Software Sustainability Dashboard Backend (SOSD)

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.

Prerequisites

Before you begin, ensure you have met the following requirements:

Getting Started

Follow these instructions to set up and run the project on your local machine.

Clone the Repository

git clone git@github.com:paulwehage/sosd-backend.git
cd sosd-backend

Setting up the Database

  1. Navigate to the database directory:

    cd database
  2. 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.

  3. 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.yml file if needed.

  4. Prisma Setup:

    1. Go back to the root of the repository and navigate to the api directory:

      cd ../api
    2. Run the following command to apply the Prisma schema to the database:

      npx prisma db push
    3. After the migration is applied, you can seed the database with example data:

      npx prisma db seed

Setting up the API

  1. Navigate to the api directory:

    cd ../api
  2. Install the dependencies:

    npm install
  3. Start the NestJS application:

    npm run start

    This will start the API server in development mode.

Testing the API

  1. Once the API server is running, you can access it at http://localhost:3000.

  2. Use tools like Postman or curl to test the API endpoints.

Swagger Documentation

The API documentation is available at http://localhost:3000/api.

Directory Structure

├── 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

Troubleshooting

  • Database Connection Issues: Ensure the Docker containers are running and the database credentials in the .env file 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors