Quick Start Guide¶
Get started with Vyte in minutes! This guide will walk you through installing Vyte, creating your first project, and running it.
Installation¶
Requirements¶
- Python 3.11 or higher
- pip (Python package installer)
Install Vyte¶
Verify Installation¶
You should see the version number displayed.
Create Your First Project¶
Let's create a simple FastAPI project with SQLAlchemy and PostgreSQL.
Interactive Mode (Recommended)¶
The easiest way to get started is using interactive mode:
You'll be prompted for:
- Project name - e.g., "my-api"
- Framework - Choose FastAPI, Flask-Restx, or Django-Rest
- ORM - Choose SQLAlchemy, TortoiseORM, or Peewee
- Database - Choose PostgreSQL, MySQL, or SQLite
Command-Line Mode¶
If you prefer, specify all options in one command:
Pro Tip
Use the shorthand flags: -f for framework, -o for ORM, -d for database
Project Structure¶
After creation, you'll have a fully structured project:
my-api/
├── app/
│ ├── __init__.py # Application factory
│ ├── main.py # Entry point
│ ├── database.py # Database configuration
│ ├── api/
│ │ ├── __init__.py
│ │ └── routes/
│ │ ├── __init__.py
│ │ └── users.py # Example user routes
│ └── models/
│ ├── __init__.py
│ └── user.py # Example user model
├── alembic/ # Database migrations
│ ├── versions/
│ └── env.py
├── tests/ # Test suite
│ ├── __init__.py
│ ├── conftest.py
│ └── test_users.py
├── .env.example # Environment variables template
├── .gitignore
├── alembic.ini # Alembic configuration
├── pyproject.toml # Project dependencies
└── README.md
Key Files¶
- app/main.py - Application entry point
- app/database.py - Database connection and session management
- app/models/ - SQLAlchemy/ORM models
- app/api/routes/ - API endpoints
- alembic/ - Database migration scripts
- .env.example - Copy this to
.envand configure
Configure Your Database¶
1. Set Up Environment Variables¶
Copy the example environment file:
2. Edit .env¶
Open .env and configure your database:
For PostgreSQL (Production)¶
For SQLite (Development)¶
For MySQL¶
Important
Never commit your .env file to version control! It's already in .gitignore.
Install Dependencies¶
Using pip¶
Using Poetry (if configured)¶
Run Database Migrations¶
Before running your application, create the database tables:
# Generate initial migration
alembic revision --autogenerate -m "Initial migration"
# Apply migrations
alembic upgrade head
About Alembic
Alembic is a database migration tool that tracks schema changes and applies them safely.
Run Your Application¶
FastAPI Projects¶
The API will be available at:
- API: http://localhost:8000
- Interactive Docs: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
Flask-Restx Projects¶
or
The API will be available at:
- API: http://localhost:5000
- Swagger Docs: http://localhost:5000/api/doc
Test Your API¶
Using FastAPI Interactive Docs¶
- Open http://localhost:8000/docs in your browser
- Try the example endpoints (e.g.,
/users) - Click "Try it out" to test requests
Using curl¶
# Create a user
curl -X POST "http://localhost:8000/users" \
-H "Content-Type: application/json" \
-d '{"username": "john", "email": "john@example.com"}'
# Get all users
curl http://localhost:8000/users
# Get a specific user
curl http://localhost:8000/users/1
Using httpie¶
# Install httpie
pip install httpie
# Create a user
http POST localhost:8000/users username=john email=john@example.com
# Get all users
http localhost:8000/users
Run Tests¶
Your project comes with a basic test suite:
For coverage report:
What's Next?¶
Now that you have your project running, you can:
1. Add More Models¶
Edit app/models/ to add your domain models:
# app/models/post.py
from sqlalchemy import Column, Integer, String, ForeignKey, Text
from app.database import Base
class Post(Base):
__tablename__ = "posts"
id = Column(Integer, primary_key=True, index=True)
title = Column(String(200), nullable=False)
content = Column(Text, nullable=False)
user_id = Column(Integer, ForeignKey("users.id"))
2. Add Routes¶
Create new route files in app/api/routes/:
# app/api/routes/posts.py
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.database import get_db
router = APIRouter(prefix="/posts", tags=["posts"])
@router.get("/")
def list_posts(db: Session = Depends(get_db)):
# Your logic here
pass
3. Customize Configuration¶
See the Configuration Guide to learn about:
- Environment variables
- Database settings
- Logging configuration
- Security settings
4. Deploy Your API¶
Check out deployment guides for:
- Docker containerization
- Cloud platforms (AWS, GCP, Azure)
- CI/CD pipelines
Common Issues¶
Database Connection Error¶
Problem: Can't connect to PostgreSQL/MySQL
Solution:
- Make sure the database server is running
- Check your DATABASE_URL in
.env - Verify username/password are correct
- Ensure database exists
Migration Errors¶
Problem: Alembic migration fails
Solution:
- Check database connection first
- Delete
alembic/versions/*.pyfiles and regenerate - Reset database:
alembic downgrade basethenalembic upgrade head
Import Errors¶
Problem: Module not found errors
Solution:
# Make sure you're in the project directory
cd my-api
# Reinstall dependencies
pip install -r requirements.txt
Port Already in Use¶
Problem: Address already in use
Solution:
Need Help?¶
Next Steps¶
- Configuration - Learn about customization options
- Databases - Deep dive into ORMs and databases
- Frameworks - Explore framework-specific features
- CLI Reference - Complete command documentation