SWAPI-PY is a Star Wars API inspired web application that provides comprehensive access to Star Wars universe data. Built with modern web technologies, it offers both a RESTful API backend and an interactive web interface for managing and exploring Star Wars films, characters, planets, species, starships, and vehicles.
The application serves as a comprehensive Star Wars database management system with the following core purposes:
- Data Management: Centralized storage and management of Star Wars universe entities
- API Services: RESTful API endpoints for programmatic access to Star Wars data
- Web Interface: User-friendly Angular frontend for browsing and managing content
- Authentication: Secure JWT-based user authentication and authorization
- Administration: Admin panel for system monitoring and configuration
Backend:
- Framework: Python Flask 2.1.2
- ORM: SQLAlchemy 1.4.40 with Flask-SQLAlchemy
- Authentication: Flask-JWT-Extended 4.4.4
- API Documentation: Flask-RESTX 0.5.1 (Swagger/OpenAPI)
- Serialization: Marshmallow 3.18.0
- Caching: Flask-Caching 2.0.1
- Database: PostgreSQL (primary), SQLite (development)
Frontend:
- Framework: Angular 13.3.1
- UI Library: Bootstrap 5.1.3 with ng-bootstrap
- Icons: FontAwesome
- Build Tool: Webpack with Angular CLI
Development Tools:
- Package Management: Poetry (Python), npm (Node.js)
- Testing: PyTest (backend), Jest (frontend)
- Code Quality: Ruff, Black, ESLint
- Security: Bandit security scanner
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Angular SPA │ │ Flask API │ │ PostgreSQL │
│ (Frontend) │◄──►│ (Backend) │◄──►│ (Database) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ┌─────────────────┐ │
│ │ JWT Auth │ │
│ │ + Caching │ │
│ └─────────────────┘ │
│ │
┌─────────────────┐ ┌─────────────────┐
│ Admin Panel │ │ Swagger UI │
│ (Monitoring) │ │ (API Docs) │
└─────────────────┘ └─────────────────┘
Represents Star Wars movies and media content.
Attributes:
title: Movie titleepisode_id: Episode number in the sagaopening_crawl: Introductory textdirector: Film directorproducer: Film producerrelease_date: Release date
Relationships:
- Many-to-many with Person (characters)
- Many-to-many with Planet (locations)
- Many-to-many with Species (alien races)
- Many-to-many with Starship (spacecraft)
- Many-to-many with Vehicle (ground vehicles)
Represents characters in the Star Wars universe.
Attributes:
name: Character nameheight,mass: Physical measurementshair_color,skin_color,eye_color: Physical appearancebirth_year: When the character was borngender: Character gender
Relationships:
- Many-to-one with Planet (homeworld)
- Many-to-many with Species
- Many-to-many with Vehicle (vehicles piloted)
- Many-to-many with Starship (starships piloted)
Represents worlds in the Star Wars galaxy.
Attributes:
name: Planet namerotation_period: Day length in hoursorbital_period: Year length in daysdiameter: Planet sizeclimate: Weather conditionsgravity: Gravitational forceterrain: Surface featuressurface_water: Percentage of water coveragepopulation: Number of inhabitants
Represents alien races and sentient beings.
Attributes:
name: Species nameclassification: Biological classificationdesignation: Sentience designationaverage_height: Typical heightskin_colors,hair_colors,eye_colors: Physical variationsaverage_lifespan: Life expectancylanguages: Native languages
Relationships:
- Many-to-one with Planet (homeworld)
Represents spacecraft capable of interstellar travel.
Attributes:
name: Starship namemodel: Ship model/classmanufacturer: Shipbuildercost_in_credits: Purchase pricelength: Ship dimensionsmax_atmosphering_speed: Top atmospheric speedcrew: Required crew sizepassengers: Passenger capacitycargo_capacity: Cargo spaceconsumables: Supply durationhyperdrive_rating: FTL capabilityMGLT: Megalight per hour ratingstarship_class: Ship classification
Represents ground and atmospheric vehicles.
Attributes:
name: Vehicle namemodel: Vehicle modelmanufacturer: Vehicle manufacturercost_in_credits: Purchase pricelength: Vehicle dimensionsmax_atmosphering_speed: Maximum speedcrew: Required crewpassengers: Passenger capacitycargo_capacity: Cargo spaceconsumables: Supply durationvehicle_class: Vehicle type
POST /api/authenticate- User loginPOST /api/register- User registrationPOST /api/account/reset-password/init- Password reset requestPOST /api/account/reset-password/finish- Complete password resetGET /api/account- Get current user infoPOST /api/logout- User logout
GET /api/films- List all films (paginated)GET /api/films/{id}- Get specific filmPUT /api/films/{id}- Update film (authenticated)DELETE /api/films/{id}- Delete film (authenticated)
GET /api/people- List all charactersGET /api/people/{id}- Get specific characterPUT /api/people/{id}- Update characterDELETE /api/people/{id}- Delete character
GET /api/planets- List all planetsGET /api/planets/{id}- Get specific planetPUT /api/planets/{id}- Update planetDELETE /api/planets/{id}- Delete planet
GET /api/species- List all speciesGET /api/species/{id}- Get specific speciesPUT /api/species/{id}- Update speciesDELETE /api/species/{id}- Delete species
GET /api/starships- List all starshipsGET /api/starships/{id}- Get specific starshipPUT /api/starships/{id}- Update starshipDELETE /api/starships/{id}- Delete starship
GET /api/vehicles- List all vehiclesGET /api/vehicles/{id}- Get specific vehiclePUT /api/vehicles/{id}- Update vehicleDELETE /api/vehicles/{id}- Delete vehicle
GET /api/management/health- System health checkGET /api/management/info- Application informationGET /api/management/metrics- System metricsGET /api/management/configprops- Configuration properties
- JWT-based authentication with configurable expiration
- Role-based access control (RBAC)
- Password hashing with bcrypt
- CORS support for cross-origin requests
- Security headers and middleware
- Database connection pooling
- Response caching with Flask-Caching
- Pagination for large datasets
- Lazy loading for database relationships
- Optimized database queries
- Responsive Angular SPA
- Bootstrap-based UI components
- Real-time data updates
- Pagination and filtering
- Admin dashboard with monitoring
- Interactive API documentation (Swagger UI)
- Hot reload for development
- Comprehensive test suites
- Code quality tools and linting
- Security vulnerability scanning
- Docker containerization support
- Database migrations with Liquibase
# Backend
poetry install
poetry run python src/main/python/Swapi_pyApp.py
# Frontend
npm install
npm start
# Full stack
npm run pyhipster# Build frontend
npm run webapp:build:prod
# Docker deployment
docker build -t swapi-py .
docker run -p 8080:8080 swapi-pyDATABASE_URL: PostgreSQL connection stringJWT_SECRET_KEY: JWT signing keyFLASK_ENV: Application environment (development/production)
- Database connectivity monitoring
- Memory and CPU usage tracking
- Response time metrics
- Error rate monitoring
- Structured logging with timestamps
- Request/response logging
- Error tracking and reporting
- Performance metrics collection
# Backend tests
poetry run pytest
# Frontend tests
npm test
# Code coverage
poetry run task coverage
# Security scan
poetry run task security_scanInteractive API documentation is available at:
- Swagger UI:
http://localhost:8080/api/v3/api-docs/default - API Specification: OpenAPI 3.0 compliant
The application follows modern development practices with:
- Automated testing and CI/CD ready
- Security best practices implementation
- Performance monitoring capabilities
- Scalable architecture design
- Comprehensive error handling
- Detailed logging and debugging support