How kanagarajsck/react-flask-docker-app works
Project Type & Purpose
• Type: Full-stack web application, composed of a React/Vite frontend (“client”) and a Flask-based inference backend (“server”), both containerized via Docker and orchestrated via docker-compose.
• Purpose: Accept user image uploads in the browser, send them to the backend for face detection and age/gender inference, then display the results.
File Structure
• Top-level:
• docker-compose.yml — defines two services: client and server
• client/ — React app (Vite build, ESLint config)
• server/ — Flask app, Python inference scripts, pre-trained Caffe/OpenCV models
• Patterns:
• client/src/components → UploadForm.jsx handles file input & API call
• server/app.py → Flask endpoints
• server/face_detector.py → inference logic loading .prototxt/.caffemodel files
• server/models/ → contains Caffe & OpenCV face/age/gender models
Extract Key README Insights
• Confirms React-Flask-Docker stack
• Mentions age-gender detection functionality
Main Components & Their Interactions
a. Frontend (React/Vite container)
• UploadForm component captures image
• Sends HTTP POST to Flask API
• Receives JSON { age:…, gender:… }
• Renders results
b. Backend API (Flask container)
• /detect endpoint in app.py
• Delegates to face_detector.py
• face_detector loads models from server/models
• Runs OpenCV face detector → crops faces → age_net/gender_net inference
• Returns JSON response
c. Docker & Host
• docker-compose orchestrates both containers
• Port-mapping: client:80→5173, server:5000→5000
• Networks: client ↔ server on internal network
d. External Dependencies
• OpenCV (cv2), Caffe .prototxt/.caffemodel
• Python packages in requirements.txt
• Vite, React, other npm packages
Architectural Patterns & Design Principles
• Separation of concerns: UI vs. inference logic
• Containerization: isolates front and back, ensures reproducible environments
• Stateless API: no persistent storage; each request is independent
• Model abstraction: face_detector module encapsulates ML inference
Detailed Capture
• Flask API layer
• Inference module (face_detector.py)
• Model storage (server/models)
• HTTP layer separately from the ML layer
• Technology stacks next to each component:
• React, Vite, Node.js — client
• Python, Flask, OpenCV, Caffe — server
• How the user’s image flows through the system
• How containers communicate internally
• Where and how the ML models are applied
• The clear separation of frontend, backend API, and inference layers