|
1 | | -# Go Backend Rest Api for the project |
| 1 | +# Model Maker Backend API |
2 | 2 |
|
3 | | -UPDATE: This repo is outdated. It has been merged with the docker parent repo at: https://github.com/2024-dissertation/model-maker-docker |
| 3 | +<img align="right" width="125" src="assets/app-icon.png"> |
4 | 4 |
|
5 | | -## New Method |
| 5 | +[](https://github.com/2024-dissertation/go-api/actions/workflows/test.yml) |
6 | 6 |
|
7 | | -As of 17/01/25, migrations are now handled with [Goose](https://github.com/pressly/goose) and [Upper.io](https://upper.io/v4/adapter/postgresql/) Postgresql Adapter. |
| 7 | +Model Maker is an accessible and Open Source solution to Photogrammetry. This is the backend for the also open source [Flutter App](https://github.com/2024-dissertation/model-maker-app). |
8 | 8 |
|
9 | | -To migrate up, reset or check status of the database, use the following commands: |
| 9 | +Included is a Go REST API with a Dockerfile environment ready for deployment. |
10 | 10 |
|
11 | | - - `make db-status` to check the status of the database |
12 | | - - `make up` to migrate up |
13 | | - - `make reset` to reset the database |
| 11 | +#### Features |
14 | 12 |
|
15 | | -Other commands in the Makefile: |
| 13 | +- Works against multiple databases: |
| 14 | + - Postgres, MySQL, and more. |
| 15 | +- Cross platform. |
| 16 | +- Development and Production ready Docker environments. |
| 17 | + - `docker-compose-test.yml` will setup a Postgres container and deploy an Ubuntu based enironment for the server executable. |
| 18 | + - `docker-compose-dev.yml` will create a continous environment for internal compiling with `make` |
| 19 | +- Uses [OpenMVG](https://github.com/openMVG/openMVG) and [OpenMVS](https://github.com/cdcseacave/openMVS). |
| 20 | +- Makefile for handling deploying, migrations, running tests. |
| 21 | +- Firebase for authentication. |
| 22 | +- Environment variables integrations. |
| 23 | +- ... and more! |
| 24 | + |
| 25 | +#### Setup |
16 | 26 |
|
17 | | - - `make run` to run the server |
18 | | - - `make build` to build the server |
19 | | - - `make seed` to seed the database |
| 27 | +Before setting up, a [Google Firebase](https://firebase.google.com/) project must be setup. This project is designed to use the free plan for authentication, so all that'd needed is the `service-account-key.json`. |
20 | 28 |
|
21 | | -The .env in app/ is necessary for Makefile to work. Structure is as follows: |
| 29 | +Environment variables must be configured, check [/app/.env.example](/app/.env.example) for required keys. It's important to provide the raw json as a string in `GOOGLE_CREDENTIALS`. If running the development environment, the json file should be placed in [/app](/app) and the path updated accordingly. If using the production environment, only the string value needs to be configured. |
| 30 | + |
| 31 | +To run the development environment: |
| 32 | + |
| 33 | +```bash |
| 34 | +docker compose -f docker-compose-dev.yml up -d |
| 35 | +``` |
22 | 36 |
|
23 | | -```env |
24 | | -DATABASE_URL=postgres://postgres:postgres@localhost:5432/appdb?sslmode=disable |
| 37 | +and the production environment: |
25 | 38 |
|
26 | | -MIGRATION_PATH=db/migrations |
| 39 | +```bash |
| 40 | +docker compose -f docker-compose-test.yml up -d |
27 | 41 | ``` |
28 | 42 |
|
29 | | -This repo also contains a postres docker, but migrations are still handled through Goose and Go. |
| 43 | +**(Note, build times take up to 40 mins on M1 Pro Macbook due to the size of the Photogrammetry tools)** |
30 | 44 |
|
31 | | -## Old Method |
| 45 | +To rebuild the application in development, the Docker container will stay open without executing the binary. Instead exec in with `docker compose -f docker-compose-dev.yml exec modelmaker bash` and run `make`. |
32 | 46 |
|
33 | | -Database is handled with migrations using [Go Migrations CLI Tools](https://github.com/golang-migrate/migrate/blob/master/database/postgres/TUTORIAL.md) and [Upper.io](https://upper.io/v4/adapter/postgresql/) Postgresql Adapter. |
| 47 | +In both scenarios, the API will run on port `3333` unless changed in the `.env`. |
34 | 48 |
|
35 | | -`brew install golang-migrate` |
| 49 | +Example scripts are provided in [/app](/app) called `run.sh` and `build.sh` for deploying and building the docker images. |
36 | 50 |
|
37 | | -mirgate with `source .env && migrate -database ${DATABASE_URL} -path migrations up` |
| 51 | +#### Migrations |
38 | 52 |
|
39 | | -coverter https://developer.apple.com/augmented-reality/tools/ |
| 53 | +Migrations are handled automatically. Incase manual control is needed, install the tool [Goose](https://github.com/pressly/goose). |
| 54 | + |
| 55 | +To migrate up, reset or check status of the database, use the following commands: |
| 56 | + |
| 57 | +- `make db-status` to check the status of the database |
| 58 | +- `make up` to migrate up |
| 59 | +- `make reset` to reset the database |
| 60 | + |
| 61 | +Other commands in the Makefile: |
40 | 62 |
|
41 | | -datasets: https://github.com/natowi/photogrammetry_datasets |
| 63 | +- `make run` to run the server |
| 64 | +- `make build` to build the server |
| 65 | +- `make seed` to seed the database |
42 | 66 |
|
43 | | -## Running the server |
| 67 | +#### Documentation |
44 | 68 |
|
45 | | -The current routes are as follows: |
| 69 | +Documentation is currently in development for the API, as well as a Postman collection. In the meantime, refer to the frontend App. |
46 | 70 |
|
47 | | - - POST /verify |
48 | | - - GET /tasks |
49 | | - - POST /tasks |
50 | | - - GET /tasks/:taskID |
51 | | - - POST /tasks/:taskID/upload |
52 | | - - POST /tasks/:taskID/start |
53 | | - - POST /uploads |
54 | | - - GET /uploads/:taskId/:filename |
55 | | - - GET /objects/:taskID/:filename |
| 71 | +#### Special Thanks |
56 | 72 |
|
57 | | - A postman collection exists to demo these routes. |
| 73 | +- **Datasets index**: https://github.com/natowi/photogrammetry_datasets |
| 74 | +- **Testing image dataset**: https://www.youtube.com/watch?v=4LexaqdxdiU |
0 commit comments