How mariem-m11/mlops-car-side-recognition-and-data-extraction-app works
Project Type and Purpose
• This is a full-stack, containerized, machine-learning-driven web application.
• The frontend is a simple static site (HTML/CSS/JS) in the front/ directory.
• The backend is a FastAPI service in app/appfast.py that loads TensorFlow models to do car-pose classification, license-plate OCR, and ID-card recognition.
• The project is orchestrated locally via Docker Compose and in production via Kubernetes.
• It has built-in code quality analysis (SonarQube + PostgreSQL) and a GitLab CI/CD pipeline.
File Structure
• Top-level folders:
• app/ – Python/FastAPI code + Dockerfile + requirements.txt
• front/ – Static site + Dockerfile
• docker_compose/ – docker-compose.yml and docker-compose-app.yml for multi-container setups
• kubernetes/ – YAML manifests for Deployments, Services, Ingress, and SonarQube components
• static/ – Images for documentation/UI
• CI/CD: .gitlab-ci.yml defines stages for build, test, code-quality, containerize, push, deploy.
• Code scanning: .scannerwork/ holds SonarQube analysis artifacts.
• Test runner: test.py at project root.
README for Insights
• Confirms use of FastAPI (with Swagger UI), TensorFlow, Pydantic, python-multipart, Docker (Debian base), pipreqs/pireqs, Docker Compose, Kubernetes, SonarQube, and GitLab CI.
• Shows usage snippets for building, running, converting Compose → Kubernetes, and kubectl commands.
Main Components and Their Interactions
a. Client (Browser)
– Interacts over HTTP/HTTPS with the Ingress or LoadBalancer.
b. Ingress / LoadBalancer
– Routes / to the Web service and /api/ to the API service.
c. Web Service (Static Frontend)
– Container built from front/Dockerfile, serves index.html and assets.
d. API Service (FastAPI + ML)
– Container built from app/Dockerfile, endpoint definitions in appfast.py.
– Invokes TensorFlow models, performs OCR, returns JSON.
e. Data Store for SonarQube
– PostgreSQL container / pod for code-quality data.
f. SonarQube Service
– Runs alongside the app in Compose and as pods in Kubernetes.
g. GitLab CI/CD Pipeline
– Pulls code, runs tests, triggers SonarQube analysis, builds Docker images, pushes to registry, deploys to Kubernetes.
h. Docker Registry (Docker Hub or private)
– Stores versioned images for frontend and backend.
i. Kubernetes Cluster
– Hosts Deployments, Services, PVCs (for Sonar data), and the nginx-ingress controller.
Architectural Patterns and Design Principles
• Microservices: separate web and API containers.
• Twelve-factor app: config via env vars, stateless services, separate build/deploy.
• Infrastructure as Code: all Docker Compose and Kubernetes manifests live in repo.
• CI/CD with code-quality gates (SonarQube).
b. Inside the cluster, place:
– Ingress/LoadBalancer
– Web Deployment + Service
– API Deployment + Service
– SonarQube Deployment + Service + Postgres PVC
c. Outside the cluster, place:
– Developer’s Browser
– Docker Registry
– Browser → Ingress → Web
– Browser → Ingress → API (for /api calls)
– GitLab → CI/CD Stages → Docker Registry → Kubernetes Cluster
– CI job → SonarQube analysis (to the SonarQube Service)
e. Component with its primary technology:
– Web: Dockerfile, HTML/CSS/JS
– API: FastAPI, Python, TensorFlow
– CI: GitLab CI, pipreqs/pireqs, pytest/test.py
– Code-Quality: SonarQube, PostgreSQL
– Orchestration: Docker Compose, Kubernetes YAMLs, Helm ingress-nginx