Backend Architecture¶
The backend of Socon-MKT is powered by Python and Django. It acts as the central hub for the platform, securely managing the REST API, complex database interactions, asynchronous background tasks, and third-party integrations like email services.
Core Technology Stack¶
| Technology | Role | Why We Use It |
|---|---|---|
| Python | Core Language | Provides a robust, readable, and highly scalable foundation for backend logic. |
| Django | Web Framework | Offers built-in security, ORM, and admin interfaces, allowing us to focus on business logic rather than reinventing the wheel. |
| Django REST Framework (DRF) | API Layer | Facilitates the rapid creation of robust API endpoints and handles complex serialization of nested database models. |
| Celery | Background Operations | Offloads heavy tasks (like processing large media uploads or sending transactional emails) from the main request/response cycle, keeping the API fast. |
| Resend | Email Service | A modern, developer-friendly API for sending transactional emails (like escrow alerts or welcome messages) with high deliverability. |
| Tailwind CSS & HTML | Email Templates | We use Tailwind to style our custom HTML email templates, ensuring responsive, modern-looking transactional emails across all email clients. |
Modular Project Structure¶
As platforms grow, standard Django apps that dump all logic into single views.py or models.py files quickly become unmanageable. Socon-MKT avoids this by using a modular folder architecture across its core applications.
By converting components like models, views, and serializers into Python packages (folders with __init__.py files), we keep the codebase clean, highly scalable, and easy to navigate.
- The
coreapp handles platform-wide logic like API keys, permissions, custom exceptions, paginations, and signals. - The
postapp divides models, serializers, and views into separate directories for better maintainability. - We use an
httpdirectory to store.httpfiles for quick and organized API testing.
SOCON_MKT/
├── .env # Contains all private API keys, database URLs, and secrets
├── .env.example
├── .gitignore
├── db.sqlite3
├── manage.py
├── requirements.txt
├── socon_mkt/ # Main project configuration (settings, wsgi, asgi)
├── core/ # The central app for platform-wide logic
│ ├── migrations/
│ ├── models/ # Modular models directory
│ │ ├── __init__.py
│ │ ├── api_keys_models.py
│ │ └── reposts_models.py
│ ├── permissions/ # Custom DRF permission classes
│ │ ├── __init__.py
│ │ ├── admin_only.py
│ │ └── api_permission.py
│ ├── serializers/ # Modular serializers directory
│ │ ├── __init__.py
│ │ ├── api_key_serializers.py
│ │ └── report_serializers.py
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── exceptions.py # Custom API exception handlers
│ ├── paginations.py # Global pagination classes
│ ├── signals.py # Django signals for cross-app events
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── post/ # Feature-specific application for posts
│ ├── management/
│ ├── migrations/
│ ├── models/ # Modular models for posts
│ ├── serializer/ # Modular serializers for posts
│ ├── views/ # Modular views for posts
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── filter.py # Custom DRF filtersets
│ ├── pagination.py
│ ├── tests.py
│ └── urls.py
├── chat/ # Application for real-time or REST chat logic
│ ├── migrations/
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py # Standard models layout
│ ├── pagination.py
│ ├── serializers.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── notifications/ # Feature application for alerts
├── users/ # Feature application for user management
├── http/ # REST Client testing requests
│ ├── auth.http
│ ├── chats.http
│ ├── core.http
│ ├── notification.http
│ └── posts.http
├── templates/ # Handles email rendering and Tailwind HTML templates
├── utils/ # Shared utility scripts and helpers
├── media/ # User-uploaded files
├── post_profile_pics/ # App-specific media uploads
├── statics/ # Collected static assets
└── staticfiles/ # Static file source directory