How ayushx15/plotera-lead-automation works
Project Type & Purpose
• This is a backend-only RESTful service built in Python/Flask.
• Its responsibilities are:
• Managing leads and sales-person assignments
• Exposing HTTP endpoints for CRUD operations
• Running a daily scheduler to send SMS reminders via Twilio
• Persisting data in MySQL and logging key events
File Structure
• Top-level files:
• app.py — Flask application entry point (routes registration, server startup)
• config.py — environment and DB/Twilio credentials loader
• requirements.txt — dependency list
• Directories:
• routes/ — HTTP route modules (leads.py, sales.py)
• db/ — data layer (db_connection.py, init_db.sql)
• utils/ — business utilities (sms.py for Twilio integration)
• cron/ — scheduled job (send_reminders.py)
• logs/ — runtime logs (app.log)
• tests/ — placeholder for unit/integration tests
Extract Architecture Details from README
• Tech stack: Flask (web server), MySQL (persistent store), Twilio (SMS), dotenv (config), Python logging
• Features: REST API, daily cron SMS, one-off test SMS, logging
a. Main Components
1. Client (Postman, Browser, Mobile)
2. Flask API Server
– Route Handlers: /add-lead, /get-leads, /update-status, /assign-salesperson, etc.
– Business Logic Layer (integrated in routes + utils)
3. MySQL Database (db_connection.py)
4. SMS Service (Twilio API via utils/sms.py)
5. Cron Scheduler (cron/send_reminders.py)
6. Configuration Store (.env via config.py)
7. Logging Sink (logs/app.log)
b. Interactions & Data Flows
• Client → HTTP → Flask API → CRUD → MySQL ← init_db.sql
• Flask API → utils/sms.py → Twilio REST API → SMS delivered
• Cron Scheduler (OS cron or manual invocation) → Python script →
– Query MySQL for today’s visits → for each record:
→ utils/sms.py → Twilio
→ Logging service
• config.py centrally provides DB credentials & Twilio keys to all components
c. Architectural Patterns & Principles
– Layered separation:
• Presentation/API layer (Flask + routes/)
• Data access layer (db/db_connection.py)
• Integration layer (utils/sms.py)
• Scheduled tasks separate from request flow (cron/)
– Single Responsibility: each module has focused duties
– External-Service isolation: Twilio calls encapsulated in utils
d. Key Technologies & Frameworks
– Python 3.x + Flask for HTTP server
– MySQL for relational storage
– Twilio REST API for SMS
– dotenv for secure environment variables
– Python logging module for audit trail