Skip to content

๐Ÿš€ NasirPy Framework

[![GitHub release](https://img.shields.io/github/v/release/itx-nasir/nasirpy?include_prereleases&style=flat-square)](https://github.com/itx-nasir/nasirpy/releases) [![License](https://img.shields.io/github/license/itx-nasir/nasirpy?style=flat-square)](https://github.com/itx-nasir/nasirpy/blob/master/LICENSE) [![Python Version](https://img.shields.io/badge/python-3.6%2B-blue?style=flat-square)](https://www.python.org/downloads/) **Educational Python web framework built from scratch to understand how web frameworks work under the hood** [Get Started](getting-started/installation.md){ .md-button .md-button--primary } [View on GitHub](https://github.com/itx-nasir/nasirpy){ .md-button }

๐ŸŽฏ Purpose

NasirPy was created with the goal of deeply understanding how Python web frameworks work internally. Every component is built from scratch to demonstrate core concepts that power modern web frameworks.

Perfect for Learning

This framework is designed for developers who want to understand the internals of web frameworks like FastAPI, Flask, and Django.

โœจ What You'll Learn

  • HTTP Server Implementation


    Learn how web servers handle HTTP requests and responses at the protocol level.

  • Routing Mechanisms


    Understand URL pattern matching, parameter extraction, and route registration.

  • Middleware Architecture


    Discover how middleware chains process requests and responses.

  • ASGI/WSGI Concepts


    Compare synchronous and asynchronous web server interfaces.

๐Ÿš€ Quick Example

Here's how simple it is to create an API with NasirPy:

from nasirpy import App, Response

app = App()

@app.get("/")
async def hello_world():
    return Response({"message": "Hello, World!"})

@app.get("/users/{user_id}")
async def get_user(request):
    user_id = request.path_params["user_id"]
    return Response({"user_id": user_id, "name": f"User {user_id}"})

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="127.0.0.1", port=8000)

๐ŸŽ“ Educational Components

Core Features Implemented

  • [x] HTTP Server - Built from scratch to understand request handling
  • [x] Routing System - URL pattern matching and parameter extraction
  • [x] Middleware Chain - Request/response processing pipeline
  • [x] Request Parsing - HTTP request body and header parsing
  • [x] Response Formatting - JSON and HTML response generation
  • [x] Error Handling - Exception management and error responses

Learning Resources

Each component comes with detailed explanations:

  • ๐Ÿ“– Inline Documentation - Every function and class is documented
  • ๐Ÿ” Code Comments - Explaining the "why" behind implementation choices
  • ๐Ÿ“š Conceptual Guides - Understanding web framework patterns
  • ๐Ÿงช Working Examples - Real applications you can run and modify

๐Ÿ› ๏ธ Installation

Get started in seconds:

pip install git+https://github.com/itx-nasir/nasirpy.git

Or for development:

git clone https://github.com/itx-nasir/nasirpy.git
cd nasirpy
pip install -e .

๐Ÿ“– Documentation Structure

  • Getting Started


    Installation, quick start, and your first application

    Get Started

  • Core Concepts


    Deep dive into framework architecture and design patterns

    Coming soon - Core concepts documentation

  • API Reference


    Complete reference for all classes and methods

    Coming soon - API reference documentation

  • Examples


    Real-world applications and use cases

    Coming soon - Example applications

๐Ÿค Contributing

This is an educational project! Contributions are welcome:

  • ๐Ÿ› Bug Reports - Help improve the framework
  • ๐Ÿ“š Documentation - Make learning easier for others
  • ๐Ÿ’ก Examples - Share your educational use cases
  • ๐ŸŽ“ Learning Content - Add tutorials and explanations

View Repository

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


**Built with ๐Ÿ’ก for learning and understanding** [โญ Star on GitHub](https://github.com/itx-nasir/nasirpy){ .md-button }