generated from prixite/backend-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b863ca
commit 9685073
Showing
1 changed file
with
0 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,13 @@ services we use in dev environment: | |
|
||
- *Django* - This serves the API. | ||
- *PostgreSQL* - The DB service. | ||
- *Cache* - Memcached service for caching data. | ||
- *Celery* - This is for background task management. | ||
- *Rabbitmq* - This is the brocker used by Celery. | ||
|
||
For production, we have the following services: | ||
|
||
- *Nginx* - This is used as reverse proxy. | ||
- *Gunicorn/Django* - This is the application server. It runs the Python Django | ||
application. | ||
- *PostgreSQL* - The DB service. | ||
- *Cache* - Memcached service for caching data. | ||
- *Celery* - This is for background task management. | ||
- *Rabbitmq* - This is the brocker used by Celery. | ||
|
||
## Installation | ||
The easiest way to start development is through Docker setup. If you have | ||
|
@@ -31,14 +25,6 @@ docker-compose up -d | |
You can access the application at http://localhost:8000/ | ||
|
||
|
||
## Fake Data | ||
When you run the application in development environment, you can expect the | ||
following users in the DB: | ||
- **Superadmin** - Creds: [email protected]/admin | ||
- **User** - Creds: [email protected]/soccer | ||
- **Default User** - Creds: [email protected]/soccer | ||
|
||
|
||
## Production Deployment | ||
Production deployment is also done using Docker. All the files associated with | ||
prod deployment are present in prod folder. To start prod build, do: | ||
|
@@ -48,80 +34,3 @@ cd prod | |
docker-compose build | ||
docker-compose up -d | ||
```` | ||
|
||
## Linters | ||
This project uses following linters: | ||
|
||
- GitLint: This is used to maintain quality of Git commit messages. | ||
- Flake8: This is used to maintain quality of Python code. | ||
- Isort: This is used to maintain imports in Python files. | ||
|
||
To run run all linters, do: | ||
|
||
``` | ||
docker-compose exec api bash | ||
./scripts/lint.sh | ||
``` | ||
|
||
You can fix Isort issues by running the following command: | ||
|
||
``` | ||
docker-compose exec api bash | ||
isort <file path> | ||
``` | ||
|
||
## Configuration files | ||
There are multiple special files that are actively used by this project: | ||
|
||
- .isort.cfg: This file is used to configure ISort. | ||
- .gitignore: This file is used to ignore files in Git. | ||
- .gitlab-ci.yml: This file is used to configure CI. | ||
- .dockerignore: This file is used to ignore files from Docker context. | ||
- .flake8: Thiis file is used to configuration Flake8. | ||
- .gitlint: This file is used to configure GitLint. | ||
- .coveragerc: This is file is used to configure coverage options. | ||
|
||
## Testing | ||
You can run tests with the following command: | ||
|
||
``` | ||
docker-compose exec api bash | ||
./scripts/test.sh | ||
``` | ||
|
||
You can run tests with coverage with the following command: | ||
|
||
``` | ||
docker-compose exec api bash | ||
./scripts/test-with-coverage.sh | ||
``` | ||
|
||
## Debugging | ||
This project integrates Django Debug Toolbar. It is a very good tool to profile | ||
the API code. As a note, you should always try to improve performance | ||
bottlenecks after profiling your code. You can see the toolbar, by logging in | ||
with the superuser and then sending debug=true query parameter in the URL. For | ||
example: | ||
|
||
``` | ||
http://localhost:8000/users/?debug=true | ||
``` | ||
|
||
## Documentation | ||
You can access very detailed Swagger based documentation by accessing: | ||
|
||
``` | ||
http://localhost:8000/docs/ | ||
``` | ||
|
||
## Permission Levels | ||
There are 4 permission levels in this application: | ||
|
||
1. *Unauthed* - When we don't send an auth token. | ||
2. *Default* - When we send auth token, but this auth token is associated to a | ||
default user. This user is not a real user. The purpose is to not provide | ||
public access of this API. | ||
3. *Authed* - We send auth token belonging to a real user. | ||
admin. | ||
4. *Admin* - We send auth token belonging to admins. This has unrestricted | ||
access to APIs. |