Version 1.0.0
This is a RESTFUL API that manages personal contacts of the user and maps every single contact to its owner with their specific images respectively.
I am blessed to be surrounded by many extraordinary people in my life.Without them, it would not be possible for me to do what I do and advance in my mission of being an apristine Software Craftsman. I am deeply grateful.
I must offer special thanks to:
- Engineer Josephat Macharia
Whom I count on in so very many ways and whose enthusiasm for software development always inspires me.
GET contacts/
Parameter | Type | Description |
---|---|---|
auth_token |
string |
Required. Your Authentication credentials. |
GET /contacts/${id}
Parameter | Type | Description |
---|---|---|
id |
integer |
Required. Id of the contact to fetch |
- Login
- Authorize Token Verification
- Auth Token is generates a token once supplied with appropriate user details.
- Create user(s) with UUID and auth-token(s)
- Create contact mapped to a specific user via the autogenerated UUID
- Returns a refresh and access JSON web token pair based on the served set of user credentials to prove their authentication.
- Takes a refresh JSON web token and returns an access type JSON web token if the refresh token is valid.
- Token verify takes a token and indicates if it is valid.It doesn't provide additional information about a token's fitness for a narrowed down use.
This project impliments the follwing layers:
This represents logic that consume the user logic from the Usecase Layer
and renders to the view. Here you can choose to render the view in either swagger
or redoc
The application specific logic lives here, this includes interfaces, views, serializers, models etc.
The project has been structured as a 12 factor app. For detailed exploration check the link https://12factor.net/
This pattern coordinates the writing out of changes made to objects using the repository pattern.
For more details se e https://dotnettutorials.net/lesson/unit-of-work-csharp-mvc/#:~:text=The%20Unit%20of%20Work%20pattern,or%20fail%20as%20one%20unit.
- Create and activate a virtual environment:
$ python3 -m venv venv && source venv/bin/activate
- Clone the chapiana-api project
git clone https://github.com/BikoCodes/tests.git
- Navigate to the chapiana-api directory
cd src
- Install the requirements:
(venv)$ pip install -r requirements/dev.txt
- Configure the specified environment variables below in an env.sh file:
export DATABASE_URL=postgresql://<user>:<pass>@localhost/<database>
export TEST_DATABASE_URL=sqlite:////tmp/dev.db
export SECRET_KEY=not-so-secret
export GOOGLE_CLIENT_ID= provided by Google
export GOOGLE_CLIENT_SECRET= provided by Google
- Source the environment variables.
(venv)$ source env.sh
- Stage the database migrations.
(venv)$ python3 manage.py makemigrations
- Apply the database migrations.
(venv)$ python3 manage.py migrate
- Start the server
(venv)$ $ python3 manage.py runserver
- Register and login. Navigate to:
http://localhost:8000
- Python 3.8.10
- Django 4.0.1
- Django Rest Framework 3.13.1
- Django Unittesting
- Selenium 4.1.0
- Docker
- Ansible
To run tests, run the following command from the projects root:
(venv)$ coverage run manage.py test
The application has been deployed to Heroku.
The deployment has been set and scaled via CI/CD.
- The deployment is defined in
.gitlab-ci.yml
. - It has 8 jobs which include
install_dependencies
,build-client
,migrations
,connect
code-test
,deploy-to-staging
,deploy-to-production
, anddeploy-to-release
. - The repository has three branches
dev
,prod
andrelease
. - Feature branches are merged into
dev
which points to theprod
branch. - The deployment has six stages
prepare
,build
,test
,develop
,deploy
andconfidence-check
. - The application is built from the Docker image and pushed to Heroku
- The codebase tests under the
test
stage are run and if there is a failure then the next stage will not be executed. - There are two jobs that run under the
deploy
stage, the first one runs onprod
branch and deploys the code to a production-A environment, the second one runs onrelease
branch and deploys the code to a production-B environment.
- Ensure GitLab Pipepilnes are working
- Solve the bug issues arising int the CI/CD.
- Ensure tests are running appropriately.
- Deploy
Chapiana-api
on the stated environments.
Want to see the contactapi application in action?.
Developing RESTFUL API's integrated with unittesting test and functional testing.
You can find the chapiana-api as a package on Python Package Index testing plaftorm.Use the following link to download:
You can also use the following commands:
pip install -i https://test.pypi.org/simple/contactsapi