# Summary
```
I'm creating an API with FastAPI in python. My database is mongo and I'm using docker-compose with 3 services (api, mongo and mongo-express)
```
# Project objective
The main goal is that a user can update some information on the player from a webpage.
The user is going to use a web ui to send some information to the API. The API has to save this information in the database and download the media in the local filesystem. Then another program (Touchdesigner) which will act as a player can ask the database for the information and access the local files.
The API also receives images and video uploaded by the user using the web editor and uploads them to an S3 bucket and then returns the urls to the web editor so that it can request to update the events with the url links.
# Project structure
Omitting the __init__.py files is the following:
```
myproject/
api/
app/
crud/
billboard/
operations.py
event/
operations.py
media_file/
operations.py
database/
client.py
models/
billboard.py
event.py
pyobjectid.py
media_file.py
s3_utils/
presigner.py
media_purger.py
notifications/
touchdesigner.py
main.py
tests/
billboard_test.py
Dockerfile
requirements.txt
media/
docker-compose.yml
```
# API libraries
```
#myproject/api/app/requirements.txt
fastapi
uvicorn[standard]
pydantic
motor
requests
debugpy
validators
boto3
```
# Endpoints
**Events**
- POST /event/
- GET /event/{id}
- PUT /event/{id}
- DELETE /event/{id}
**Billboards**
- POST /billboard/
- POST /billboard/{id}/synced
- GET /billboard/{id}
- GET /billboard/{id}/with-events
- GET /billboards/
- PUT /billboard/{id}
- DELETE /billboard/{id}
# Models
| Event | | | | | |
| ----------------- | --------------------------------- | --------- | ----------------- | ------------------------------------------------------ | ------------------ |
| Property | Data Type | Required? | Default Value | Description | Who sets the value |
| id | string | YES | | Unique identifier (master key). Assignated on creation | database |
| title | string | NO | "" | | user |
| brief_info | string | NO | "" | | user |
| additional_info | string | NO | "" | | user |
| location | string | NO | "" | | user |
| location_logo_url | string | NO | "" | url | user |
| category | string | NO | "" | | user |
| color | tuple of 4 ints between 0 and 255 | NO | (255,255,255,255) | | user |
| background_url | string | NO | "" | url | user |
| show_banner | bool | NO | TRUE | | user |
| media_position | tuple of 2 ints | NO | (0,0) | | user |
| media_dimensions | tuple of 2 ints | NO | (0,0) | | user |
| Billboard | | | | | |
| ------------------- | --------------- | --------- | ------------- | ------------------------------------------------------------ | ------------------ |
| Property | Data Type | Required? | Default Value | Description | Who sets the value |
| id | string | YES | | Unique identifier (master key). Assignated on creation | database |
| title | string | YES | | | user |
| publication_date | date | YES | | On creation if the request didn't include date it is set to the current date | user/api |
| events | tuple of 7 ints | YES | | Tuple of event id's. On creation of the Billboard the API creates 7 events and assigns their ID's to the new billboard | api |
| publication_allowed | bool | | FALSE | | user |
| Category | | | | | |
| -------- | --------------------------------- | --------- | ------------- | ------------------------------------------------------ | ------------------ |
| Property | Data Type | Required? | Default Value | Description | Who sets the value |
| name | string | YES | | Unique identifier (master key). Assignated on creation | user |
| color | tuple of 4 ints between 0 and 255 | YES | | | user |
| Media File | | | | | |
| ---------- | --------- | --------- | ------------- | ------------------------------------------------------------ | ------------------ |
| Property | Data Type | Required? | Default Value | Description | Who sets the value |
| id | string | | | Unique identifier | database |
| file_name | string | YES | | | user |
| url | string | NO | "" | | user |
| local_copy | bool | YES | FALSE | The user doesn't ever need this information. Is set by the api after downloading some media to the local file system from the url specified in the data by the user | api |
| local_path | string | NO | "" | | api |