The Alias Check helps confirm the availability of a username on different social networks. While it is intended as a learning project by the Tech Interviews Nigeria that would introduce participants to different technologies in fullstack development, ranging from frontend technologies like NextJS to Flask and SQLite or Postgres on the backend in addition to Docker for development, its utility is quite apparent. For example, small businesses can see the application in the selection of an available and catchy name among major social media platform.
This is project is structured so that the developer can choose to set it up with or without Docker.
To start the project using Docker, even from scratch, run the following command:
docker-compose up
Then go to http://localhost:3000/ to access the frontend or http://localhost:5000/ to access the backend
For backend developers that might only need to run the server
and database
, run the following command:
docker-compose up server
For frontend developers who might not need access to the backend for the features they want to add, stop other services besides client
after starting up:
docker-compose up && \
docker stop $(docker-compose ps --services | grep -v client)
NOTES:
Add a
-d
switch to turn off logging and run the containers in detached modedocker-compose up -dor
docker-compose up -d serverWhile running in detached mode, you can view the logs at any time by running this command:
docker-compose logsYou can check the logs of any one of the three services (client, server and db) running in detached mode like so:
docker-compose logs <service-name>To continue the streaming the log output, add an
-f
switch:docker-compose logs -f <service-name>
There might be need to rebuild any of the containers. For example, if the data in create.sql changes, you can rebuild the database container by running the command:
docker-compose build db
In some cases, starting the containers after shutting them down may result in some errors, especially if you make changes affecting the container images. In this case, you can rebuild the container images while starting up the containers:
docker-compose up --build --force-recreate
You can also wind down the containers to pause development by running the following command:
docker-compose down
Though this project was built for easy startup with Docker, it can also be run without Docker. You would need to run the commands on two terminals, one for the frontend and the other for the backend:
On one terminal, go to the frontend folder named client
, install dependencies and run the development server:
cd client
npm install
npm run dev
On another terminal, create and activate a virtual environment, and then install the requirements.
Update project/server/config.py, and then run:
$ cd backend
$ export APP_NAME="ALIAS CHECK API"
$ export APP_SETTINGS="app.config.ProductionConfig"
$ export FLASK_DEBUG=0
By default the app is set to use the production configuration. If you would like to use the development configuration, you can alter the APP_SETTINGS
environment variable:
$ export APP_SETTINGS="app.config.DevelopmentConfig"
Using Pipenv Use the .env file to set environment variables:
APP_NAME="ALIAS CHECK API"
APP_SETTINGS="app.config.DevelopmentConfig"
FLASK_DEBUG=1
$ python manage.py create-db
$ python manage.py db init
$ python manage.py db migrate
$ python manage.py run
Access the application at the address http://localhost:5000/
Without coverage:
$ python manage.py test
With coverage:
$ python manage.py cov
Run flake8 on the app:
$ python manage.py flake
or
$ flake8 project