diff --git a/Makefile b/Makefile index 8e7d0b2..6778c53 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ # Install the dependencies install: @poetry install +# Run Alembic migrations +migrations: + @poetry run alembic upgrade head # Build docker image build: @docker build -t final-pyweb-image . diff --git a/README.md b/README.md index f9c0237..9e145b7 100644 --- a/README.md +++ b/README.md @@ -1 +1,123 @@ -# FINAL-PYWEB \ No newline at end of file +# FINAL-PYWEB + +## Description + +This is a project management dashboard API built with FastAPI. It allows users to create, update, share, and delete project information. + +## Getting Started + +### Prerequisites + +- Python 3.10.6 +- Poetry for dependency management +- Make for the Makefile +- Docker (for building and running the application in a container) +- PostgreSQL 15 + +### Installation + +1. Clone the repository: +```commandline +git clone git@github.com:kojicmarko/FINAL-PYWEB.git +``` +2. Navigate to project directory: +```commandline +cd FINAL-PYWEB +``` +3. Install dependencies: +```commandline +make install +``` + +## Setting up Environment Variables +Before running the application, you need to set up the necessary environment variables. + +These include: +- `SECRET_KEY` +- `ALGORITHM` +- `TOKEN_EXPIRE_TIME` +- `DATABASE_URL` +- `DB_HOST` +- `DB_PORT` +- `AWS_BUCKET_NAME` +- `AWS_DEFAULT_REGION` + +You can set these up in a `.env` file in the root of your project directory. + +## Setting Up the Database + +This application uses PostgreSQL 15. Make sure you have it installed and create a new database for this application. + +## Running Alembic Migrations + +After setting up the database, you need to run Alembic migrations to create the necessary tables: +```commandline +make migrations +``` + +## Running the Application Locally +1. Start the server directly: +```commandline +make run +``` +## Running the Application inside Docker +1. Build the Docker image: +```commandline +make build +``` +2. Start a Docker container with the server: +```commandline +make up-docker +``` +3. To stop the Docker container and preserve volumes: +```commandline +make down-docker +``` +4. To stop the Docker container and delete volumes: +```commandline +make down-docker-v +``` + +## Linting +1. Lint and fix style and lint type-hinting: +```commandline +make lint +``` + +## Testing +1. Run tests: +```commandline +make test +``` + +## API Endpoints + +The API provides the following endpoints: + +### Users/Auth + +- `POST /auth`: Creates a user. +- `POST /login`: Logs in the user. + +### Projects + +- `POST /projects`: Creates a new project. Making the user who created it the project owner +- `GET /projects`: Returns all projects where user is a participant. +- `GET /project//info`: Returns project information, if the user is a participant. +- `PUT /project//info`: Updates project information, if the user is a participant. +- `DELETE /project/`: Deletes project, if the user is project owner. +- `POST /project//invite?user=`: Adds user to a project as a participant. Only the project owner can invite. + +### Documents + +- `GET /project//documents`: Returns all documents of a project. +- `POST /project//documents`: Uploads a document for a specific project. +- `GET /document/`: Returns a document. +- `PUT /document/`: Updates a document. +- `DELETE /document/`: Deletes a document, if the user is project owner. + +### Logos + +- `GET /project//logo`: Returns the logo of a project. +- `PUT /project//logo`: Updates the logo of a project. +- `DELETE /project//logo`: Deletes the logo, if the user is project owner. \ No newline at end of file