Skip to content

Commit eefa4e8

Browse files
authored
Merge pull request #262 from python-ellar/authentication_docs
fix: Added more context to authentication docs
2 parents b361a7f + c73559c commit eefa4e8

File tree

10 files changed

+701
-244
lines changed

10 files changed

+701
-244
lines changed

README.md

Lines changed: 51 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,44 @@
1+
# Ellar - Modern Python ASGI Framework
12
<p align="center">
2-
<a href="#" target="blank"><img src="https://python-ellar.github.io/ellar/img/EllarLogoB.png" width="200" alt="Ellar Logo" /></a>
3+
<img src="https://python-ellar.github.io/ellar/img/EllarLogoB.png" width="200" alt="Ellar Logo" />
34
</p>
4-
<p align="end">logo by: <a target="_blank" href="https://www.behance.net/azadvertised">Azad</a></p>
5-
6-
<p align="center"> Ellar - Python ASGI web framework for building fast, efficient, and scalable RESTful APIs and server-side applications. </p>
75

86
![Test](https://github.com/python-ellar/ellar/actions/workflows/test_full.yml/badge.svg)
97
![Coverage](https://img.shields.io/codecov/c/github/python-ellar/ellar)
108
[![PyPI version](https://badge.fury.io/py/ellar.svg)](https://badge.fury.io/py/ellar)
119
[![PyPI version](https://img.shields.io/pypi/v/ellar.svg)](https://pypi.python.org/pypi/ellar)
1210
[![PyPI version](https://img.shields.io/pypi/pyversions/ellar.svg)](https://pypi.python.org/pypi/ellar)
1311

14-
## **Introduction**
15-
16-
Ellar is a lightweight ASGI framework designed to simplify the development of efficient and scalable server-side Python
17-
applications. Whether you're building web services, APIs, or full-fledged web applications,
18-
Ellar offers a high level of abstraction and powerful features to streamline your development process.
12+
## Overview
1913

20-
Ellar allows developers to embrace both Object-Oriented Programming (OOP) and Functional Programming (FP) paradigms.
21-
It is built on top of Starlette, a renowned ASGI toolkit, ensuring robust asynchronous request-handling capabilities.
14+
Ellar is a modern, fast, and lightweight ASGI framework for building scalable web applications and APIs with Python. Built on top of Starlette and inspired by the best practices of frameworks like NestJS, Ellar combines the power of async Python with elegant architecture patterns.
2215

23-
## **Key Features**
16+
## Key Features
2417

25-
- **Easy to Use**: With an intuitive API, Ellar makes it easy for developers to get started with building fast and scalable Python web applications.
26-
- **Dependency Injection (DI)**: Ellar includes a built-in DI system, enabling easy management of dependencies and reducing coupling between components.
27-
- **Pydantic Integration**: Integrated with Pydantic for seamless data validation, ensuring that input data is always valid.
28-
- **Templating with Jinja2**: Built-in support for Jinja2 templates simplifies the creation of dynamic web pages.
29-
- **OpenAPI Documentation**: Ellar has built-in support for generating OpenAPI documentation and facilitating API documentation generation with Swagger or ReDoc.
30-
- **Controller (MVC) Architecture**: Ellar follows the Model-View-Controller (MVC) pattern, aiding in organizing code and separating concerns.
31-
- **Guards for Authentication and Authorization**: Offers built-in support for guards, making it easy to implement authentication and authorization in applications.
32-
- **Modularity**: Inspired by NestJS, Ellar follows a modular architecture, allowing developers to organize code into reusable modules.
33-
- **Asynchronous Programming**: Leveraging Python's async/await feature, Ellar enables the development of efficient and high-performance applications capable of handling concurrent requests.
34-
- **Type Hints Support**: Built with modern Python type hints for better IDE support and code reliability.
35-
- **WebSocket Support**: Native WebSocket support for real-time bidirectional communication.
36-
- **Database Agnostic**: Freedom to use any database with built-in support for popular ORMs.
37-
- **Testing Utilities**: Comprehensive testing utilities for unit and integration testing.
18+
- 🚀 **High Performance**: Built on ASGI standards for maximum performance and scalability
19+
- 💉 **Dependency Injection**: Built-in DI system for clean and maintainable code architecture
20+
- 🔍 **Type Safety**: First-class support for Python type hints and Pydantic validation
21+
- 📚 **OpenAPI Integration**: Automatic Swagger/ReDoc documentation generation
22+
- 🏗️ **Modular Architecture**: Organize code into reusable modules inspired by NestJS
23+
- 🔐 **Built-in Security**: Comprehensive authentication and authorization system
24+
- 🎨 **Template Support**: Integrated Jinja2 templating for server-side rendering
25+
- 🔌 **WebSocket Support**: Real-time bidirectional communication capabilities
26+
- 🧪 **Testing Utilities**: Comprehensive testing tools for unit and integration tests
3827

39-
## **Installation**
28+
## 🚀 Quick Start
4029

41-
You can install Ellar using pip:
30+
### Installation
4231

4332
```bash
44-
# Create and activate virtual environment (recommended)
45-
python -m venv venv
46-
source venv/bin/activate # On Windows use: venv\Scripts\activate
47-
48-
# Install Ellar
4933
pip install ellar
5034
```
5135

52-
## **Quick Start**
36+
### Basic Example
5337

5438
```python
55-
# main.py
5639
from ellar.common import get, Controller, ControllerBase
5740
from ellar.app import AppFactory
41+
import uvicorn
5842

5943
@Controller()
6044
class HomeController(ControllerBase):
@@ -64,135 +48,80 @@ class HomeController(ControllerBase):
6448

6549
app = AppFactory.create_app(controllers=[HomeController])
6650

67-
# Run the application
6851
if __name__ == "__main__":
6952
uvicorn.run("main:app", port=5000, reload=True)
7053
```
7154

72-
## **Getting Started**
55+
## 📚 Complete Example
7356

7457
```python
75-
# Example code showcasing Ellar usage
76-
# (Please ensure you have properly installed Ellar first)
77-
78-
import uvicorn
79-
from ellar.common import Body, Controller, ControllerBase, delete, get, post, put, Serializer, Inject
80-
from ellar.app import AppFactory
58+
from ellar.common import Body, Controller, ControllerBase, delete, get, post, put, Serializer
8159
from ellar.di import injectable, request_scope
82-
from ellar.openapi import OpenAPIDocumentModule, OpenAPIDocumentBuilder, SwaggerUI
60+
from ellar.app import AppFactory
8361
from pydantic import Field
84-
from pathlib import Path
8562

86-
# Define a serializer for creating a car
63+
# Define Data Model
8764
class CreateCarSerializer(Serializer):
8865
name: str
8966
year: int = Field(..., gt=0)
9067
model: str
9168

92-
# Define a service class for car operations
69+
# Define Service
9370
@injectable(scope=request_scope)
9471
class CarService:
9572
def __init__(self):
96-
self.detail = 'a service'
73+
self.detail = 'car service'
9774

98-
# Define a controller for car operations
75+
# Define Controller
9976
@Controller
100-
class MotoController(ControllerBase):
77+
class CarController(ControllerBase):
10178
def __init__(self, service: CarService):
10279
self._service = service
10380

10481
@post()
10582
async def create(self, payload: Body[CreateCarSerializer]):
106-
assert self._service.detail == 'a service'
107-
result = payload.dict()
108-
result.update(message='This action adds a new car')
109-
return result
110-
111-
@put('/{car_id:str}')
112-
async def update(self, car_id: str, payload: Body[CreateCarSerializer]):
11383
result = payload.dict()
114-
result.update(message=f'This action updated #{car_id} car resource')
84+
result.update(message='Car created successfully')
11585
return result
11686

11787
@get('/{car_id:str}')
118-
async def get_one(self, car_id: str, service: Inject[CarService]):
119-
assert self._service == service
120-
return f"This action returns a #{car_id} car"
88+
async def get_one(self, car_id: str):
89+
return f"Retrieved car #{car_id}"
12190

122-
@delete('/{car_id:str}')
123-
async def delete(self, car_id: str):
124-
return f"This action removes a #{car_id} car"
125-
126-
# Create the Ellar application
12791
app = AppFactory.create_app(
128-
controllers=[MotoController],
129-
providers=[CarService],
130-
base_directory=str(Path(__file__).parent),
131-
config_module=dict(REDIRECT_SLASHES=True),
132-
template_folder='templates'
133-
)
134-
135-
# Build OpenAPI documentation
136-
document_builder = OpenAPIDocumentBuilder()
137-
document_builder.set_title('Ellar API') \
138-
.set_version('1.0.2') \
139-
.set_contact(name='Author', url='https://www.yahoo.com', email='author@gmail.com') \
140-
.set_license('MIT Licence', url='https://www.google.com')
141-
document = document_builder.build_document(app)
142-
143-
# Setup OpenAPI documentation module
144-
OpenAPIDocumentModule.setup(
145-
app=app,
146-
docs_ui=SwaggerUI(),
147-
document=document,
148-
guards=[]
92+
controllers=[CarController],
93+
providers=[CarService]
14994
)
150-
151-
# Run the application
152-
if __name__ == "__main__":
153-
uvicorn.run("main:app", port=5000, reload=True)
15495
```
15596

156-
157-
Now we can test our API at [http://127.0.0.1:5000/docs](http://127.0.0.1:5000/docs#/)
158-
159-
You can also try the [quick-project](https://python-ellar.github.io/ellar/quick-project/) setup to get a good idea of the library.
160-
161-
162-
## **Project Documentation Status**
163-
- Authorization: In progress
164-
- Complete documentation available at: https://python-ellar.github.io/ellar/
165-
- API Reference: https://python-ellar.github.io/ellar/references/
166-
167-
## **Dependency Summary**
168-
169-
Ellar has the following core dependencies:
97+
## 🔧 Requirements
17098

17199
- Python >= 3.8
172100
- Starlette >= 0.27.0
173101
- Pydantic >= 2.0
174102
- Injector >= 0.19.0
175-
- typing-extensions >= 4.5.0
176103

177-
Optional dependencies:
178-
- jinja2 - For template rendering
179-
- python-multipart - For form data parsing
180-
- itsdangerous - For security features
104+
## 📖 Documentation
105+
106+
- Complete documentation: [https://python-ellar.github.io/ellar/](https://python-ellar.github.io/ellar/)
107+
- API Reference: [https://python-ellar.github.io/ellar/references/](https://python-ellar.github.io/ellar/references/)
108+
109+
## 🤝 Contributing
110+
111+
We welcome contributions! Here's how you can help:
112+
113+
- Create an issue for bugs or feature requests
114+
- Submit pull requests for improvements
115+
- Create third-party modules
116+
- Share your experience with Ellar
117+
- Build and showcase your applications
181118

182-
## **Contributing**
183-
Contributions are Welcome! You can contribute in the following ways.
119+
See [CONTRIBUTING.md](https://github.com/python-ellar/ellar/blob/main/docs/contribution.md) for detailed guidelines.
184120

185-
- **Create an Issue** - Propose a new feature. Report a bug.
186-
- **Pull Request** - Fix a bug and typo. Refactor the code.
187-
- **Create third-party module** - Just like ellar-throttling, ellar-jwt, ellar-sql that can solve common problem in web application development.
188-
- **Share** - Share your thoughts on the a Blog, Twitter, and others.
189-
- **Build your application** - Please try to use Ellar. For more details, see [docs/CONTRIBUTING.md](https://github.com/python-ellar/ellar/blob/main/docs/contribution.md).
121+
## 📝 License
190122

191-
## **Contributors**
192-
Thanks to all contributors!
123+
Ellar is [MIT Licensed](LICENSE).
193124

194-
## **Author**
195-
Ezeudoh Tochukwu https://github.com/eadwinCode
125+
## 👤 Author
196126

197-
## **License**
198-
Ellar is [MIT License](https://github.com/python-ellar/ellar/blob/main/LICENSE).
127+
Ezeudoh Tochukwu [@eadwinCode](https://github.com/eadwinCode)

0 commit comments

Comments
 (0)