Internship Diary Entry — April 4, 2026
- Role: AI Engineer — SynerSense
- Project: AnanaCare CDSS (Architecture Refactor + Web Image Support)
- Hours Worked: 8
Work Summary
Today’s work focused on a major architectural refactor and the introduction of web-based image ingestion. The goal was to simplify the backend by removing the tightly coupled class-based design and replacing it with a clean, functional pipeline, while also extending the system to accept images directly from URLs.
Key Technical Achievements
1. Decommissioning faces.py (Core Refactor)
- Began breaking down the monolithic
faces.pyinto modular, standalone functions. - Extracted core responsibilities:
- Face detection & cropping (MediaPipe)
- Image validation logic
- Analysis pipeline (embeddings + DNN inference)
- Replaced class-based usage (
PreProcessor,Validator,Analyzer) with pure functions, improving readability and testability. - Ensured each route now directly calls functional utilities, removing hidden dependencies.
2. Functional Pipeline Design
- Established a clear processing flow:
input → decode → detect face → crop (512x512) → validate → analyze
- Each step is now:
- Stateless
- Reusable
- Independently testable
- Reduced coupling between modules, making future debugging and scaling easier.
3. Web Image Fetching Feature
- Implemented support for remote image URLs:
- Accepts image URL as input
- Downloads image using HTTP client
- Converts to in-memory file (PIL/bytes)
- Routes through the same validation + analysis pipeline
- Ensured:
- Format validation (PNG/JPG)
- Safe decoding before processing
- This enables use cases like:
- External dataset ingestion
- Integration with third-party systems
4. Architecture Alignment
- Designed web image ingestion to reuse the same functional pipeline as local uploads.
- Avoided duplicate logic by ensuring both sources (file + URL) converge into a single processing path.
- Maintained consistency with
.validate_cacheand downstream analysis flow.
Learnings & Insights
- Functional > Class-Based (for pipelines): Stateless functions are easier to reason about and scale in API systems.
- Separation of Concerns: Decoupling detection, validation, and analysis makes the system far more maintainable.
- Input Abstraction: Treating all inputs (file or URL) uniformly simplifies the architecture significantly.
- Refactoring Risk: Removing a central file like
faces.pyrequires careful dependency tracking to avoid silent breakages.
Challenges & Risks
- Hidden Dependencies: Some routes were tightly coupled to
faces.pyinternals, requiring careful extraction. - Error Handling: Web image fetching introduces new failure modes (timeouts, invalid URLs, large files).
- Security Considerations: Remote fetching must guard against malicious URLs or unexpected content types.
Next Steps
- Fully remove
faces.pyafter verifying no residual imports remain. - Add timeout, size limits, and content-type checks for URL-based image fetching.
- Write unit tests for each functional component (crop, validate, analyze).
- Optimize MediaPipe initialization using a shared singleton to avoid repeated loads.
Outcome
The backend is now transitioning into a modular, function-driven architecture, significantly improving maintainability and scalability. Additionally, the system now supports direct web image ingestion, expanding its real-world usability and integration potential.