How opficdev/swiftui_starbridge works
Project Type and Purpose
• This is a full‑stack mobile application:
• Frontend: iOS app built with SwiftUI (incl. Social Login via Firebase/Kakao).
• Backend/API: Python Flask service exposing endpoints to the app.
• Data‑processing service: Python scripts crawling X.com and cleansing data via ChatGPT API, then persisting to MySQL (via SQLAlchemy).
• Persistence: AWS EC2‑hosted MySQL database.
File Structure Analysis
• Top‑level directories:
• DB/ – periodic data‐ingestion & processing scripts (cafe_db.py, x_db.py).
• api/ – Flask application (api.py), configuration (config.py), deployment scripts (gunicorn.py, cmd.sh).
• iOS/ – SwiftUI app source, assets, SocialLogin MVVM modules, Storyboard‑style entry points.
• Patterns & Config:
• iOS uses MVVM and SwiftUI views under SocialLogin and ContentView directories.
• Flask follows a single‐module MVC lite pattern (api.py handles routes, config.py for settings).
• SQLAlchemy models live inside DB scripts for schema creation & migrations.
• Deployment: gunicorn.py indicates WSIGI entrypoint.
README Insights
• Confirms the three pillars: SwiftUI frontend, Python/Flask backend/API, MySQL via SQLAlchemy.
• Describes data‑flow for “생일 카페” crawler: crawl JSON → cleanse (dedupe, format dates) → SQLAlchemy → MySQL → log to .txt.
• Documents 4 API “Content” operations: bboard, cafe, image, x.
a. Main Components
1. External Services
– X.com crawler target
– OpenAI ChatGPT API
– OAuth providers (Firebase Auth, Kakao)
2. Data‑Ingestion Service (DB/)
– cafe_db.py & x_db.py run on a scheduler (every 30 min)
– Perform crawling, call ChatGPT for cleanup
– Use SQLAlchemy to upsert into MySQL
– Emit JSON logs to .txt
3. Persistence Layer
– AWS EC2 – MySQL database instance
– Two domains: “생일 카페” tables & “게시판” tables
4. Backend/API Service (api/)
– Flask app (api.py) behind Gunicorn
– Routes parse “Content” field, query MySQL, return JSON or images
5. iOS Mobile App (iOS/)
– SwiftUI Views & MVVM (ContentView, SocialLogin modules)
– Social login flow → OAuth providers → FirebaseAuth/Kakao SDK
– HTTP client calls Flask API endpoints
– Renders lists, details, forms
b. Relationships & Data Flow
1. Crawling Service → (ChatGPT API) → Data processing → SQLAlchemy → MySQL
2. Crawling Service → JSON log files (.txt) for monitoring
3. iOS App → HTTP(S) requests → Flask API → MySQL → Back to iOS
4. iOS App ↔ OAuth providers (Firebase/Kakao) for login
5. Flask API → serves image files from disk per “image” requests
c. Architectural Patterns
• Scheduler + ETL (Extract/Transform/Load) for crawling
• MVC‐lite for Flask (controllers in api.py, models via SQLAlchemy)
• MVVM + SwiftUI for iOS
• REST‐style API with content‐driven routing
d. Key Technologies
• SwiftUI, Combine (or standard networking) on iOS
• Python 3.x, Flask, Gunicorn, SQLAlchemy on backend
• MySQL on AWS EC2
• ChatGPT API for NLP cleansing
• FirebaseAuth & Kakao SDK for Social Login