self-nokiy-net (0.1.0)
Installation
pip install --index-url self-nokiy-netAbout this package
Add your description here
Self.Nokiy.Net
A FastAPI application with Rust-powered markdown processing, featuring:
- FastAPI web framework with async support
- SQLModel/SQLAlchemy ORM with PostgreSQL
- Rust extensions via PyO3 for high-performance markdown parsing
- Docker containerization for easy deployment
Quick Start
Development with Docker Compose
-
Clone and setup:
git clone <repository> cd self.nokiy.net cp .env.example .env # Edit as needed -
Start all services:
# Production mode docker-compose up -d # Development mode (with hot reload) docker-compose --profile dev up -d -
Access the application:
- Production: http://localhost:8000
- Development: http://localhost:8001
- Health check: http://localhost:8000/health
- API docs: http://localhost:8000/docs
Local Development (without Docker)
-
Install dependencies:
# Install UV package manager if not installed curl -LsSf https://astral.sh/uv/install.sh | sh # Install Python dependencies uv sync # Build Rust extension cd nokiy/doc uv run maturin develop cd ../.. -
Setup database:
# Start only PostgreSQL docker-compose up -d postgres -
Run the application:
uv run uvicorn main:app --reload
Docker Services
Production Services
- app: Main FastAPI application (port 8000)
- postgres: PostgreSQL database (port 5432)
Development Services
- app-dev: Development server with hot reload (port 8001)
Optional Services
- valkey: Redis-compatible cache (commented out by default)
Docker Commands
# Build and start all services
docker-compose up -d
# Start with development profile
docker-compose --profile dev up -d
# View logs
docker-compose logs -f app
# Stop all services
docker-compose down
# Rebuild application image
docker-compose build app
# Clean up (removes volumes)
docker-compose down -v
Project Structure
├── main.py # FastAPI application entry point
├── route/ # API route handlers
│ ├── post.py # Post-related endpoints
│ └── context.py # Dependency injection context
├── model/ # Data models
│ ├── db.py # SQLModel database models
│ └── post.py # Post model definitions
├── nokiy/ # Rust extension package
│ └── doc/ # Markdown processing library
│ ├── src/lib.rs # Rust source code
│ └── bindings/ # Python bindings
├── config.py # Application configuration
├── Dockerfile # Multi-stage Docker build
├── docker-compose.yaml # Container orchestration
└── init.sql # Database initialization
API Endpoints
GET /health- Health check endpointGET /posts- List all postsPOST /posts- Create a new postPUT /posts/{id}- Update existing postDELETE /posts/{id}- Delete post
Configuration
Environment Variables
Key environment variables (see .env.example):
DATABASE_URL: PostgreSQL connection stringRUST_LOG: Logging level for Rust componentsPYTHONPATH: Python module search pathFASTAPI_ENV: Application environment (development/production)
Database
The application uses PostgreSQL with SQLModel for ORM operations. Database tables are automatically created on startup.
Development
Adding Dependencies
# Python dependencies
uv add package-name
# Rust dependencies (in nokiy/doc/)
cd nokiy/doc
cargo add crate-name
Building Rust Extension
cd nokiy/doc
uv run maturin develop # Development build
uv run maturin build # Production wheel
Running Tests
uv run pytest
Deployment
Production Deployment
-
Configure environment:
cp .env.example .env # Edit .env with production values -
Deploy with Docker Compose:
docker-compose up -d -
Monitor logs:
docker-compose logs -f
Health Monitoring
The application includes health check endpoints and Docker health checks:
- Application health:
GET /health - Database health: Built into PostgreSQL service
- Container health: Configured in docker-compose.yaml
Troubleshooting
Common Issues
- Port conflicts: Change ports in docker-compose.yaml if 8000/5432 are in use
- Database connection: Ensure PostgreSQL is running and accessible
- Rust build errors: Check that Rust toolchain is properly installed
- Import errors: Verify that the nokiy.doc package is properly built and installed
Debug Commands
# Check service status
docker-compose ps
# View application logs
docker-compose logs app
# Access database
docker-compose exec postgres psql -U nokiy -d nokiy
# Access application container
docker-compose exec app bash
Requirements
Requires Python: >=3.12