How ashmitmehta2004/smca works
What this project is (type + purpose)
This is a single-service FastAPI web application that serves:
• A minimal browser UI (HTML template + static JS/CSS)
• A JSON API endpoint that accepts PDF/image uploads, performs text extraction (PDF parsing or OCR), runs heuristic content analysis, and returns suggestions + stats.
What the file tree implies about architecture
From the tree:
• app/main.py: FastAPI app entrypoint; defines routes (very likely / and /api/analyze)
• app/templates/index.html: server-rendered initial UI page (Jinja2 or similar templating)
• app/static/app.js, styles.css: client-side behavior + UI styling (file upload, calling API, rendering results)
• app/services/extract.py: extraction layer (PDF via pdfplumber, image OCR via pytesseract + Pillow)
• app/services/analyze.py: analysis layer (rules/heuristics for engagement suggestions)
• Dockerfile: container runtime (includes system deps like Tesseract)
• requirements.txt: Python deps (FastAPI, uvicorn, pdfplumber, pytesseract, Pillow, etc.)
Architecturally this is a layered module structure inside one process:
Web/UI layer → API layer → service layer (extract/analyze) → OS-level tools/libs.
No database, queue, or multi-service separation is indicated.
What the README adds (runtime + flow)
The README describes the primary request flow clearly:
Extraction
• PDF: pdfplumber reads pages and preserves line breaks
• Image: pytesseract (Tesseract OCR) + Pillow
UI JS renders results + handles loading/error
Deployment: Docker image includes Tesseract; live on Render (container platform).
Shows: Browser ↔ FastAPI container ↔ external tooling (Tesseract) and libraries. Emphasize deployment boundary (Docker/Render).
Shows: Routes/controllers, templates/static serving, extract service, analyze service, temp file handling, and data objects (text, stats, suggestions).
This project benefits from both because it’s “one service” but has meaningful internal pipeline stages.
Main components to include (separate into as many as practical)
Client side (Browser)
• index.html (rendered page)
• app.js (upload + fetch /api/analyze, render JSON)
• styles.css
Server side (FastAPI app in app/main.py)
• Route: GET / (serves UI via templates/index.html)
• Route: POST /api/analyze (multipart upload handler, orchestrates pipeline)
• Static files handler (serves /static/app.js, /static/styles.css)
Service layer (app/services)
• extract.py
• PDF extraction subcomponent: pdfplumber
• Image OCR subcomponent: pytesseract + Pillow
• Normalization step (whitespace cleanup)
• analyze.py
• Stats calculator (word count, hashtags, punctuation, etc.)
• Suggestion rules engine (deterministic heuristics)
Runtime/External dependencies
• OS temp filesystem (where uploads are written)
• Tesseract binary (external executable invoked by pytesseract)
• (Optional to show) Render.com hosting as “Deployment environment”
• Uploaded file (PDF/Image)
• Temp file path
• Raw extracted text
• Normalized text
• Analysis result JSON (stats + suggestions)
Browser → FastAPI GET /
Payload: HTTP request; Response: HTML (template)
Browser → FastAPI static
Payload: GET /static/app.js, /static/styles.css
Browser (app.js) → FastAPI POST /api/analyze
Payload: multipart/form-data (file)
FastAPI handler → Temp File System
Payload: write uploaded bytes to temp path
FastAPI handler → extract.py
Payload: temp path + file type
extract.py → pdfplumber (if PDF)
Payload: PDF path; Response: page text
extract.py → pytesseract/Pillow → Tesseract (if image)
Payload: image bytes/path; Response: OCR text
extract.py → FastAPI handler
Payload: raw/normalized text
FastAPI handler → analyze.py
Payload: normalized text
analyze.py → FastAPI handler
Payload: stats + suggestions object
FastAPI handler → Browser
Payload: JSON response
Browser (app.js) → DOM
Payload: render results; show loading/errors
• FastAPI + Uvicorn (web server)
• Jinja2/templates (implied by templates/ usage; if confirmed in code, label it)
• pdfplumber (PDF text)
• Pillow + pytesseract (image OCR)
• Tesseract OCR (system binary)
• Docker (containerization)
• Render.com (hosting target; optional but useful for “live URL” context)