Skip to main content

PySpring is a Python web framework inspired by Spring Boot, combining FastAPI, and Pydantic for building scalable web applications with auto dependency injection, configuration management, and a web server.

Project description

PySpring Framework

PySpring is a Python web framework inspired by Spring Boot. It combines FastAPI for the web layer, and Pydantic for data validation. PySpring provides a structured approach to building scalable web applications with auto dependency injection, auto configuration management and a web server for hosting your application.

Key Features

  • Application Initialization: PySpringApplication class serves as the main entry point for the PySpring application. It initializes the application from a configuration file, scans the application source directory for Python files, and groups them into class files and model files.

  • Application Context Management: PySpring manages the application context and dependency injection. It registers application entities such as components, controllers, bean collections, and properties. It also initializes the application context and injects dependencies.

  • REST Controllers: PySpring supports RESTful API development using the RestController class. It allows you to define routes, handle HTTP requests, and register middlewares easily.

  • Component-based Architecture: PySpring encourages a component-based architecture, where components are reusable and modular building blocks of the application. Components can have their own lifecycle and can be registered and managed by the application context.

  • Properties Management: Properties classes provide a convenient way to manage application-specific configurations. PySpring supports loading properties from a properties file and injecting them into components.

  • Framework Modules: PySpring allows the integration of additional framework modules to extend the functionality of the application. Modules can provide additional routes, middlewares, or any other custom functionality required by the application.

  • Builtin FastAPI Integration: PySpring integrates with FastAPI, a modern, fast (high-performance), web framework for building APIs with Python. It leverages FastAPI's features for routing, request handling, and server configuration.

Project Structure

PySpring/
├── src/                    # Source code directory
├── tests/                  # Test files
├── logs/                   # Application logs
├── py_spring_core/         # Core framework package
├── app-config.json         # Application configuration
├── application-properties.json  # Application properties
├── main.py                 # Application entry point
├── pyproject.toml          # Project metadata and dependencies
└── README.md              # Project documentation

Getting Started

Prerequisites

  • Python 3.10 or higher
  • pip (Python package installer)

Installation

  1. Install the PySpring framework:
pip install py-spring-core
  1. Create a new Python project and navigate to its directory

  2. Set up your application:

    • Implement your application properties, components, and controllers using PySpring conventions inside the declared source code folder (which can be modified via the app_src_target_dir key in app-config.json)
    • Create an app-config.json file for your application configuration
    • Create an application-properties.json file for your application properties
  3. Create your main application script:

from py_spring_core import PySpringApplication

def main():
    app = PySpringApplication("./app-config.json")
    app.run()

if __name__ == "__main__":
    main()
  1. Run your application:
python main.py

For a complete example project, please refer to the PySpring Example Project.

Development Setup

  1. Clone the repository:
git clone https://github.com/NFUChen/PySpring.git
cd PySpring
  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest

Dependencies

PySpring relies on several key dependencies:

  • FastAPI (0.112.0)
  • Pydantic (2.8.2)
  • Uvicorn (0.30.5)
  • Loguru (0.7.2)
  • And other supporting packages

For a complete list of dependencies, see pyproject.toml.

Contributing

Contributions to PySpring are welcome! If you find any issues or have suggestions for improvements, please:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_spring_core-0.3.5.tar.gz (84.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_spring_core-0.3.5-py3-none-any.whl (50.8 kB view details)

Uploaded Python 3

File details

Details for the file py_spring_core-0.3.5.tar.gz.

File metadata

  • Download URL: py_spring_core-0.3.5.tar.gz
  • Upload date:
  • Size: 84.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for py_spring_core-0.3.5.tar.gz
Algorithm Hash digest
SHA256 543231a47b007091f77a223b52f64052ed9c3334a1677bfb9bcc87c00271cb6f
MD5 4847c4389e0d43b48689a7fcf60812ce
BLAKE2b-256 75b6793778e1bf34f9f77dcbcb0af277b3294632348892385e7977d580a46249

See more details on using hashes here.

File details

Details for the file py_spring_core-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: py_spring_core-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for py_spring_core-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c1944ae681f3bb1cfb6ba819d8acce59f0750dd8ca2d3a99924c7fefd90b1c93
MD5 3b443bfa631315d374d887ef71727f27
BLAKE2b-256 138cc4db82c8276ad916d4cd2d46ff79265b2d8f4c6cde85e7f1f46157875796

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page