How woodong-222/pokeface-api works
Project type and purpose
• This is a backend-only, API-first web service written in PHP, augmented by a Python script for face-recognition/embedding.
• The API (“Pokéface-api”) assigns and evolves a unique Pokémon for each user by analyzing face embeddings on repeated recognition.
File structure
• Top-level files:
• Dockerfile, start.sh, nginx-php.conf, php.ini – deployment & runtime configuration
• composer.json/lock – PHP dependencies
• requirements.txt – Python dependencies
• config/ – middleware, headers, env config
• db/db.php – database connection
• api/ – all REST endpoints, grouped by resource (community, pokemon, user, register, login, password, notices)
• scripts/ – machine-learning helpers (face_embedding.py, register_developer_face.php)
• Patterns:
• MVC-style routing within api/ (each .php file is a controller action)
• A thin Python microservice for face embedding steps, triggered from PHP
README
• Confirms high-level purpose: AI-driven face recognition, Pokémon assignment & evolution.
a. Main components:
• Client(s): Web/Mobile apps
• Reverse Proxy & Web Server: Nginx → PHP-FPM
• PHP Application Layer:
· Routing (api/)
· Business logic (community, pokemon, user modules)
· Auth middleware (config/auth_middleware.php)
• ML Microservice: Python face_embedding.py (script accepts image, returns embedding & closest Pokémon match)
• Database: relational (MySQL or MariaDB via db/db.php)
• File Storage: User face images & Pokémon avatars (local FS or network share)
b. Relationships & interactions:
• Client → HTTPS → Nginx
• Nginx → PHP-FPM → application code
• On “capture” or “upload” endpoints: PHP code calls the Python script (either via CLI or a lightweight RPC)
• Python script returns embedding; PHP persists/queries matching data in DB
• DB returns user’s Pokémon data; PHP responds to client
• Community endpoints read/write posts & likes in DB
c. Architectural patterns & design principles:
• Separation of concerns:
· Routing/controllers (api/) vs. config vs. data layer (db/) vs. ML layer (scripts/)
• Single responsibility: each PHP endpoint handles one resource operation
• Middleware for authentication (JWT or session)
• Microservice pattern for ML logic (Python script)
d. Key technologies/frameworks:
• PHP 7+ with Composer packages (e.g., JWT, database ORM)
• Nginx + PHP-FPM
• MySQL/MariaDB
• Python (face_embedding.py using face-recognition library)
• Docker for containerization