- FastAPI backend with JWT authentication - MySQL database with full schema - Docker Compose orchestration - CSV data import for 43,208 airports and 519,999 aircraft - Complete PPR management API - Modernized replacement for PHP-based system
158 lines
3.5 KiB
Markdown
158 lines
3.5 KiB
Markdown
# NextGen PPR System
|
|
|
|
A modern, containerized Prior Permission Required (PPR) system for aircraft operations management.
|
|
|
|
## Architecture
|
|
|
|
- **Backend**: FastAPI with Python 3.11
|
|
- **Database**: MySQL 8.0
|
|
- **Cache**: Redis 7
|
|
- **Container**: Docker & Docker Compose
|
|
|
|
## Features
|
|
|
|
- 🚀 **Modern API**: RESTful API with automatic OpenAPI documentation
|
|
- 🔐 **Authentication**: JWT-based authentication system
|
|
- 📊 **Real-time Updates**: WebSocket support for live tower updates
|
|
- 🗄️ **Self-contained**: Fully dockerized with local database
|
|
- 🔍 **Documentation**: Auto-generated API docs at `/docs`
|
|
- 🧪 **Testing**: Comprehensive test suite
|
|
- 📱 **Mobile Ready**: Responsive design for tower operations
|
|
|
|
## Quick Start
|
|
|
|
### Prerequisites
|
|
- Docker and Docker Compose installed
|
|
|
|
### 1. Start the System
|
|
```bash
|
|
cd nextgen
|
|
./start.sh
|
|
```
|
|
|
|
### 2. Access the Services
|
|
- **API Documentation**: http://localhost:8001/docs
|
|
- **API Base URL**: http://localhost:8001/api/v1
|
|
- **Database**: localhost:3307 (user: ppr_user, password: ppr_password123)
|
|
|
|
### 3. Default Login
|
|
- **Username**: admin
|
|
- **Password**: admin123
|
|
|
|
## API Endpoints
|
|
|
|
### Authentication
|
|
- `POST /api/v1/auth/login` - Login and get JWT token
|
|
|
|
### PPR Management
|
|
- `GET /api/v1/pprs` - List PPR records
|
|
- `POST /api/v1/pprs` - Create new PPR
|
|
- `GET /api/v1/pprs/{id}` - Get specific PPR
|
|
- `PUT /api/v1/pprs/{id}` - Update PPR
|
|
- `PATCH /api/v1/pprs/{id}/status` - Update PPR status
|
|
- `DELETE /api/v1/pprs/{id}` - Delete PPR
|
|
|
|
### Public Endpoints (No Auth Required)
|
|
- `GET /api/v1/public/arrivals` - Today's arrivals
|
|
- `GET /api/v1/public/departures` - Today's departures
|
|
|
|
### Real-time
|
|
- `WebSocket /ws/tower-updates` - Live updates for tower operations
|
|
|
|
## Development
|
|
|
|
### Local Development
|
|
```bash
|
|
cd backend
|
|
pip install -r requirements.txt
|
|
uvicorn app.main:app --reload
|
|
```
|
|
|
|
### Database Management
|
|
```bash
|
|
# Connect to database
|
|
docker exec -it ppr_nextgen_db mysql -u ppr_user -p ppr_nextgen
|
|
|
|
# View logs
|
|
docker-compose logs -f api
|
|
docker-compose logs -f db
|
|
|
|
# Restart services
|
|
docker-compose restart
|
|
```
|
|
|
|
### Testing
|
|
```bash
|
|
cd backend
|
|
pytest tests/
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
Key environment variables (configured in docker-compose.yml):
|
|
|
|
- `DB_HOST` - Database host
|
|
- `DB_USER` - Database username
|
|
- `DB_PASSWORD` - Database password
|
|
- `DB_NAME` - Database name
|
|
- `SECRET_KEY` - JWT secret key
|
|
- `ACCESS_TOKEN_EXPIRE_MINUTES` - Token expiration time
|
|
|
|
## Database Schema
|
|
|
|
The system uses an improved version of the original schema with:
|
|
|
|
- **users** - User authentication
|
|
- **submitted** - PPR records with status tracking
|
|
- **journal** - Activity logs with foreign keys
|
|
- **airports** - Airport reference data
|
|
- **aircraft** - Aircraft registration database
|
|
|
|
## Data Migration
|
|
|
|
To migrate data from the old system:
|
|
|
|
1. Export data from the old database
|
|
2. Transform to new schema format
|
|
3. Import into the new system
|
|
|
|
## Security
|
|
|
|
- JWT token authentication
|
|
- Password hashing with bcrypt
|
|
- Input validation with Pydantic
|
|
- SQL injection protection via SQLAlchemy ORM
|
|
- CORS configuration for frontend integration
|
|
|
|
## Performance
|
|
|
|
- Database connection pooling
|
|
- Indexed columns for fast queries
|
|
- Redis caching (ready for implementation)
|
|
- Async/await for non-blocking operations
|
|
|
|
## Monitoring
|
|
|
|
Access logs and monitoring:
|
|
|
|
```bash
|
|
# View API logs
|
|
docker-compose logs -f api
|
|
|
|
# View database logs
|
|
docker-compose logs -f db
|
|
|
|
# System health check
|
|
curl http://localhost:8001/health
|
|
```
|
|
|
|
## Stopping the System
|
|
|
|
```bash
|
|
docker-compose down
|
|
```
|
|
|
|
To remove volumes (database data):
|
|
```bash
|
|
docker-compose down -v
|
|
``` |