Test task for one of the companies. Django simple shop with Stripe.
Main goal is to have endpoint /item/<item_id>
that will return HTML with item information (from server database) and buy button,
that will fetch another route (API) (/buy/<item_id>
) that will return Stripe Session ID that is used to redirect user to payment screen (Actually, Stripe itself).
Project is being deployed to production by GitHub workflow (deploy action, CD). You can try project here (Click!)
Test item with id 1!
/item/<id>
: Returns HTML page with item information and button to buy selected item.
/buy/<id>
: Returns Stripe Session ID (Actually, item page fetches that endpoint to redirect by own).
/admin/*
: Project supports Django-Admin to work with models (Items, Discounts etc).
/
: Simple index page.
Project uses Docker, to run, simply do this in the repository root:
cd src && docker-compose up
. This will run Docker, Database and server with Gunicorn with Uvicorn workers!
Currently in production, static files is being served by Ngninx (+Django collectstatic
)
On the development, static files is only avaliable when using django runserver
Run docker exec -it django-stripe-server-1 /bin/sh
and then python manage.py makemigrations && python manage.py migrate
this will trigger all database migrations!
You can modify environment variables inside /src/.server.env
file that will be passed to the server with Docker. Look at the Django / App chapters.
STRIPE_API_PUBLISHABLE_KEY
, STRIPE_API_SECRET_KEY
is Stripe keys that may be found here.
URL_PREFIX
is used only for under proxy urls. All other settings refers to default Django fields.
- Python / Django (No DRF cause main goal is not to make API).
- Gunicorn with Uvicorn workers (ASGI).
- Stripe API for payments.
- Docker / Docker-Compose
- PostgreSQL (with PgBouncer) / Django ORM
- GitHub Workflows (CI/CD)
- Nginx on the server side as the proxy server.
- Ubuntu as the server OS.
- CD: Project have deploy workflow, that will automatically deploy all changes pushed to the
main
branch. - CI: Project have tests workflow, that will run Django tests / Test Docker when you are merging branch into
main
branch For now there is no special tests written for this project, so tests just not so useful.
Run docker exec -it django-stripe-server-1 /bin/sh
and then python manage.py test
this will trigger all tests!