This project, Roback
, is a basic CRUD app whose first goal was to learn the framework Django. It can not be considered as a ready-to-use production app, since key functionnalities are missing. However, it is functional and can be built locally (more info in the dedicated section)
Roback
: Name of the projectSearch target
: Name for an entity holding a text in which search can be performedMedia
: Name for an entity which holds a piece of media, typically a video or an image
The main feature is to expose search targets. Each of these search targets holds a main text, and has optional media. There is a basic filtering implementation to perform text search across all search targets. For better performance, search targets access has been paginated.
The exposed data can be viewed in a dedicated UI. The code relative to this frontend can be found here.
- Improve search system, which is currently minimal (a simple check by inclusion)
- Add tag support
- Add media processing : creation of thumbnails, transcoding
Add authentification(done, see this commit)- Add further safety checks for uploaded files
- Makes the app suitable and safe for production : hide secrets, add automatic error reports, add backup mechanism, add proper CI/CD, etc...
- Write the
pyproject.toml
file to setup build backend and project metadata (link)
Add documentation for exposed routes with a tool like Swagger(done, see this commit)Makes the app easily retrievable and ran locally with a containerization tool like Docker(done, see this commit)
This is a method to run the project in standalone, based on a local SQLite database. For a full build of the project (front + PostgreSQL database, see dedicated section)
-
Retrieve the code
You can retrieve the project via :
cd my/projects/folder git clone https://github.com/LedruRollin/Roback.git cd Roback/
-
Setup the environment
To run, the app needs some environment variables. To setup them, you can create a
.env
file inside project folder# In file Roback/.env ENGINE=django.db.backends.sqlite3 NAME=rosearch MEDIA_ROOT=/home/roback/media MEDIA_URL=media/ SECRET_KEY='' # To fill
The SECRET_KEY variable is used internally by Django to encrypt personal app data (more info in the official doc). You can generate your own by running this piece of code in a Django environment :
from django.core.management.utils import get_random_secret_key print(get_random_secret_key())
-
Launch the app
To launch the app, use Docker to run it inside a container thanks to local
Dockerfile
:cd my/projects/folder/Roback docker build . -t roback-image:v1.0.0 # Build app image docker container run --name roback-container --env-file .env roback-image:v1.0.0 # Run container
Inside the container, you can then check everything's fine by retrieving seed data using the following commands :
apt-get install curl # Install curl
curl -i http://localhost:8000/api/search_targets/
An easy way to launch the whole project is upcoming. It will use Docker Compose to run the front, the back and the database.