Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
amirbahador-hub committed Mar 23, 2023
1 parent d817f8a commit 4ee456c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,38 @@
pytest . -rP
```

## Structure
## Architecture
- Django, By default, is based on Model-View-Template (MVT) architecture.
- I improved DRF basic architecture with my [cookiecutter](https://github.com/amirbahador-hub/django_style_guide).
- It also respects separation of concerns, having api, services, selectors, serializers layers.

### Layers
- `Api`: Api is just an interface for calling other methods in a clean way.
- `Serializers`: Provides parsing capabilities for our input and output json responses and that's it we are not going to put any bussiness logic in here what so ever.
- `Services`: This is were our business logic lives, when ever we want to have a create or update or delete from the database we will put in in services.
- `Selectors`: Just like the name suggest when ever we want to select something from the database we use selectors and just like services we can put out business logic in here.
- `Utils`: any thing which doesn't need any database call when ever we have some abstractions that can be used in `services` or `selectors` we will use utils layer.
- `Views`: Just like the Api layer it's just an interface but it used for template rendering.
- `Consumers`: it's an interface for out websocket calls.
- `routing`: websocket router
- `urls`: api and template routers

### Patterns
Technically, when you are using frameworks you have little abstraactoins or desgin patterns beacuse most of the desgins are actually in the library itself, But Beacuse Usaully when you have events you can use Observer Desgin pattern i used it to showoff my skills but in a real project with this scale this is an unnecessary abstraction:

![Observer Pattern](carbon.png)


## Libraries
- [Django](https://github.com/django/django): Django is a high-level Python web framework
- [Django Rest FrameWork](https://github.com/encode/django-rest-framework): A REST API communication framwork
- [Django Channels](https://github.com/django/channels): A WebSocket communaication framewrok
- [Swagger](https://github.com/tfranzel/drf-spectacular): Sane and flexible OpenAPI 3.0 schema generation for Django REST framework
- [Pytest](https://docs.pytest.org/en/7.2.x/): A Test Library
- [DjangoRedis](https://github.com/jazzband/django-redis): full featured Redis cache and session backend for Django.


## Future Improvements
- Eventho that we tried to isolate out bussins logic it's still depends on the redis, we can add another layer called mapper which will mappes python classes with any database.
- Better test covrage. we can add integration test using selenium for our templates and we we also must add more tests for our socket calls.
- if we have lot's of socket calls then i would suggest to use a microservice artitucure and use Golang or Erlang for better socket handeling.
Binary file added carbon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4ee456c

Please sign in to comment.