Part 1: Installation and Project Creation¶
Welcome to the Unfazed tutorial! In this series, we will build a student course enrollment system step by step, covering the complete development process: project creation, data model design, API development, testing, and more.
By the end of this tutorial, you will have a working application that demonstrates all major features of the Unfazed framework.
Environment Setup¶
System Requirements¶
- Python: 3.12 or higher
- Operating System: Windows, macOS or Linux
- Recommended Tool: uv package manager (faster dependency installation)
Installing Unfazed¶
Method 1: Install with pip (standard method)
Method 2: Install with uv (recommended)
Tip: uv is a high-performance Python package manager that is 10-100 times faster than pip.
Creating a Project¶
Using CLI Tool to Create Project¶
Unfazed provides a command-line tool unfazed-cli that can quickly create project scaffolding. See Command for the full CLI reference.
This command creates a complete project structure named tutorial in the current directory.
Project Structure¶
After creation, you will see the following structure:
tutorial/
├── README.md
├── changelog.md
├── deploy/
├── docs/
│ └── index.md
├── mkdocs.yml
└── src/
├── Dockerfile
├── docker-compose.yml
└── backend/
├── asgi.py # ASGI application entry file
├── conftest.py # Pytest configuration file
├── entry/
│ ├── __init__.py
│ ├── routes.py # Root URL configuration
│ └── settings/
│ └── __init__.py # Project settings (UNFAZED_SETTINGS)
├── logs/
├── Makefile
├── pyproject.toml
└── static/
Core Files¶
| File/Directory | Description |
|---|---|
asgi.py |
ASGI application entry — creates the Unfazed instance and sets the settings module. See Settings. |
entry/routes.py |
Root URL configuration — the patterns list that maps URL prefixes to app routes. See Routing. |
entry/settings/ |
Project settings — contains UNFAZED_SETTINGS dict with all configuration. See Settings. |
conftest.py |
Pytest configuration — defines the unfazed fixture for testing. See Test Client. |
pyproject.toml |
Project dependencies and tool configuration (Ruff, MyPy, Pytest). |
Makefile |
Quick commands for common tasks (run, test, format, migrate). |
Starting the Project¶
Install Dependencies and Run¶
Step 1: Enter the backend directory
Step 2: Install project dependencies
Step 3: Start development server
# Method 1: Using Makefile (recommended)
make run
# Method 2: Using uvicorn directly
uvicorn asgi:application --host 0.0.0.0 --port 9527 --reload
Verifying Startup¶
After successful startup, you should see output similar to:
INFO: Uvicorn running on http://127.0.0.1:9527 (Press CTRL+C to quit)
INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
Common Makefile Commands¶
The generated Makefile includes several useful shortcuts:
make run # Start development server
make test # Run tests with coverage
make format # Code formatting and linting
make init-db # Initialize database migrations
make upgrade # Apply database migrations
make shell # Launch interactive IPython shell
Docker Deployment¶
For Docker-based development, use the included Docker Compose configuration:
Next Steps¶
You have successfully created and started your first Unfazed project. In the next part, we will:
- Create the first application (App)
- Write a "Hello, World" API endpoint
- Understand Unfazed's route configuration
Continue to Part 2: Creating Applications and Hello World.
Troubleshooting¶
Q: Port occupation error during startup
Q: Dependency installation failed
Q: Python version incompatible