fac30 / PRO05_BACK_Gaj_Khalos_Max

Backend for our pokemon collection project
0 stars 0 forks source link

PokeLike API

Pikachu welcomes you!

Welcome to the PokeLike API! This project helps you track Pokémon you find cute 🥰 using an ASP.NET Core Web API backed by a PostgreSQL database.

Table of Contents


Getting Started

Prerequisites

Installation

  1. Clone the repository:
    git clone https://github.com/fac30/PRO05_BACK_Gaj_Khalos_Max.git
    cd PRO05_BACK_Gaj_Khalos_Max

Database Setup

Using Docker

When using Docker, the PostgreSQL database is automatically set up in a container. No additional manual configuration is required.

  1. Pull the Docker image from Docker Hub:

    docker-compose pull
  2. Build and start the Docker containers:

    docker-compose up -d
  3. The API will be available at http://localhost/.

  4. To stop the containers, run:

    docker-compose down
  5. The API will be available at http://localhost/ - no port number is needed.

Running Locally

To start the application locally, follow these steps:

  1. Modify ConnectionString in appsettings.json to be hosted on localhost rather than db Docker container:

    "ConnectionStrings": {
    "PokeLikeDbContext": "Host=localhost;Port=5432;Database=PokeLikeDb;Username=postgres;Password=password"
    }
  2. Restore dependencies:

    dotnet restore
  3. Run the application:

    dotnet run

Project Structure


Configuration


Entity Framework Migrations

Adding a New Migration

To add a new migration after modifying models, run:

dotnet ef migrations add <MigrationName>

Removing the Last Migration

If you need to undo the last migration:

dotnet ef migrations remove

Applying Migrations

Ensure the latest migrations are applied to the database:

dotnet ef database update

API Endpoints

Base URL

Endpoints


Troubleshooting

Docker Issues