Getting Started with Inspira

Introduction

Welcome to the Inspira world! Whether you're a seasoned Python developer or just getting started, this guide will help you embark on a journey with Inspira, a powerful Python framework designed to streamline your development process.

Prerequisites

Make sure you have Python and pip installed on your system. If not, you can download them from Python's official website.

Create a new directory for your project

$ mkdir myproject
$ cd myproject

Create and activate a virtual environment

$ python -m venv venv
$ source venv/bin/activate

Installation

To install Inspira, use the following command:

$ pip install inspira

Generating an App

To generate a new app for your project, run the following command:

$ inspira init

Generated Directory Structure

After running the init command, the directory structure of your project should look like the following:

├── main.py
├── src
│   ├── __init__.py
│   ├── controller
│   │   └── __init__.py
│   ├── model
│   │   └── __init__.py
│   ├── repository
│   │   └── __init__.py
│   └── service
│       └── __init__.py
└── tests
    └── __init__.py

Generate Database file

Generate a database file using the following command:

$ inspira new database --name mydb --type sqlite

This command creates a new SQLite database file named mydb.db.

The generated database.py file typically contains initial configurations and may look like this:

from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, scoped_session, sessionmaker

engine = create_engine("sqlite:///mydb.db")
db_session = scoped_session(
    sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Base = declarative_base()
Base.query = db_session.query_property()

Generating Controller

To generate necessary controller for your project, run the following command:

$ inspira new controller order

Generating Repository

To generate repository file, run the following command:

$ inspira new repository order

Generating Service

To generate service file, run the following command:

$ inspira new service order

Generating Model

To generate model file, run the following command:

$ inspira new model order

Starting the Server

After generating your app and setting up necessary resources, start the server with the following command:

$ uvicorn main:app --reload

Congratulations! You're now set up with Inspira, and your development server is up and running. Explore the generated modules and build amazing Python applications with ease.

Happy coding!