How jeanmilpied/raizuum-api works
Project Type and Purpose
• The project is an API service (backend) that processes CV files. It exposes endpoints for OCR extraction and feature extraction from PDFs.
• It uses a FastAPI framework, provides OAuth2-based authentication, and makes use of data models and utility modules to perform text extraction and feature scoring.
Analyzing the File Structure
• The top-level “app” directory contains the main application code:
• Main entry point is app/main.py.
• The “routes” directory holds endpoints: “auth.py” covers authentication while “ocr.py” is dedicated to OCR processing.
• The “services” directory encapsulates business logic for authentication and OCR processes.
• The “models” directory defines data structures like OCRRequest and UserModel which likely utilize pydantic for request/response schemas.
• The “utils” directory provides helper modules (extractors, nlp_utils, scoring, security) to support the main services.
• Infrastructure files such as Dockerfile, docker-compose.yml, and environment settings in .env indicate containerization, deployment configuration, and environment-based settings.
• The setup_project.py and requirements.txt handle project setup and library dependencies.
a. Main Components:
• Client / Consumer:
• The user or client making HTTP requests to the API.
• Interactions coming through browsers (Swagger UI) or via cURL/Postman.
• Web Server / API Gateway:
• The FastAPI application (app/main.py) that acts as the entry point.
• Incorporate external view of Docker containerized service (Dockerfile & docker-compose.yml).
• API Endpoints:
• Authentication Endpoint (via app/routes/auth.py): handling OAuth2 token generation.
• OCR/Extraction Endpoints (via app/routes/ocr.py): handling file uploads (/extract-from-pdf) and text feature extraction (/extract-features).
• Business Logic Layer:
• Services (app/services/auth_service.py and app/services/ocr_service.py) that encapsulate core logic.
• Data Models:
• Models (app/models/ocr_request.py and app/models/user_model.py) defining the data structures for requests, responses, and internal processing.
• Utilities and Helpers:
• Utility modules (app/utils/*.py) responsible for OCR text extraction, NLP analysis, scoring, and additional security routines.
b. Relationships and Data Flow:
• The Client issues API requests (with valid OAuth2 tokens) to the FastAPI server.
• Requests hit the relevant API endpoint (e.g., upload a PDF to /extract-from-pdf/).
• Endpoints invoke the corresponding service in the “services” layer (OCR or Authentication service).
• Services process the request using helper functions from the “utils” directory and validate/convert data using models.
• Processed data and responses flow back from services to the API endpoints and then return to the Client.
c. Architectural Patterns and Design Principles:
• Separation of Concerns: Routes are solely responsible for request/response handling while business logic resides in services, and helper functions are in utilities.
• Layered Architecture: Clear division between API routes, service layer, and utility modules.
• Containerization: Dockerfile and docker-compose indicate that the entire system is containerized, which should be represented as an infrastructure boundary.
d. Technologies, Frameworks, and Libraries:
• FastAPI as the web framework.
• Python (with libraries for OCR, NLP, and OAuth2).
• Docker for containerization and deployment.
• Potential use of Pydantic models in the models directory for data schema validation.