Lin / backend_structure.md
Zelyanoth's picture
fff
25f22bf

Backend Structure Plan

Directory Structure

backend/
β”œβ”€β”€ app.py                 # Flask application entry point
β”œβ”€β”€ config.py              # Configuration settings
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ .env                   # Environment variables
β”œβ”€β”€ models/                # Database models
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ user.py            # User model
β”‚   β”œβ”€β”€ social_account.py  # Social media account model
β”‚   β”œβ”€β”€ source.py          # RSS source model
β”‚   β”œβ”€β”€ post.py            # Post content model
β”‚   └── schedule.py        # Scheduling model
β”œβ”€β”€ api/                   # API endpoints
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ auth.py            # Authentication endpoints
β”‚   β”œβ”€β”€ sources.py         # Source management endpoints
β”‚   β”œβ”€β”€ accounts.py        # Social account endpoints
β”‚   β”œβ”€β”€ posts.py           # Post management endpoints
β”‚   └── schedules.py       # Scheduling endpoints
β”œβ”€β”€ services/              # Business logic
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ auth_service.py    # Authentication service
β”‚   β”œβ”€β”€ linkedin_service.py# LinkedIn integration service
β”‚   β”œβ”€β”€ content_service.py # Content generation service
β”‚   └── schedule_service.py# Scheduling service
β”œβ”€β”€ utils/                 # Utility functions
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ database.py        # Database connection
β”‚   └── helpers.py         # Helper functions
└── scheduler/             # Task scheduling
    β”œβ”€β”€ __init__.py
    └── task_scheduler.py  # Scheduling implementation

Key Components

app.py

  • Flask application initialization
  • Configuration loading
  • Blueprint registration
  • CORS setup
  • Error handlers

config.py

  • Environment-based configuration
  • Database settings
  • API keys and secrets
  • Scheduler settings

models/

  • SQLAlchemy models for all database entities
  • Relationship definitions
  • Validation logic

api/

  • RESTful endpoints for all features
  • Request validation
  • Response formatting
  • Authentication middleware

services/

  • Business logic implementation
  • External API integrations
  • Data processing and transformation

utils/

  • Database connection management
  • Helper functions for common operations
  • Error handling utilities

scheduler/

  • APScheduler implementation
  • Task scheduling and execution
  • Conflict resolution