How asef69/core-buetian--your-buetian-social-media-app works
1. System shape
Core BUETians is a split frontend/backend platform: a React 18 + Vite client talks to a Django 4.2 backend built with Django REST Framework, while real-time chat uses Django Channels over WebSockets. PostgreSQL is the primary datastore, and the backend is organized around feature domains rather than a single monolith.
2. Backend boundary and entrypoints
The backend root lives in core_buetians/, which contains global settings plus the main HTTP/ASGI/WSGI wiring. core_buetians/urls.py and the domain URL modules define the API surface, while asgi.py enables both normal HTTP traffic and the WebSocket path used by chat. manage.py is the standard Django control entrypoint.
3. Domain-oriented Django apps
Each major business area is isolated into its own app: users, posts, chat, groups, forums, marketplace, and notification. This is the main architectural boundary in the backend. The apps carry their own models, views, serializers, URLs, tests, and in some cases extended_views or auth_views for specialized endpoints.
4. Data flow for REST APIs
Most user actions follow a simple path: the React app calls a domain API endpoint, the Django view/serializer layer validates the request, and the app reads or writes PostgreSQL. The backend returns JSON, and the frontend renders it through route-level pages such as Posts, Groups, Marketplace, Forums, Profile, and Search.
5. Real-time chat path
Chat is the only clearly real-time subsystem. The frontend chat page connects to a WebSocket endpoint handled by chat/consumers.py and chat/routing.py, with Channels managing live message delivery. Chat messages are also persisted, so the system has both a transient real-time transport and durable storage/query behavior.
6. Notification orchestration
Notifications are treated as a cross-cutting domain rather than a UI-only concern. Multiple backend actions can create them: likes, comments, follows, messages, group activity, and other interactions. This makes notifications a downstream effect of other domains instead of an isolated user-triggered feature.
7. Shared backend utilities
Common infrastructure lives in utils/: authentication, permissions, pagination, database helpers, file upload handling, exception types, and media config. These utilities form the shared service layer used across apps, keeping repeated concerns out of the domain modules.
8. Database is more than tables
The sql/ directory is a major architectural asset. It contains schema, indexes, views, functions, procedures, and triggers, which means a fair amount of business logic is pushed into PostgreSQL. That affects the architecture materially: the app layer is not the only place where counters, notifications, derived fields, and transactional workflows are maintained.
9. Frontend structure
The frontend is organized by pages and reusable components, with shared state in context/, API access in services/, reusable logic in hooks/, and app-wide styling in styles/. The UI is composed around domain pages that mirror the backend areas, which keeps the frontend aligned with the API boundaries.
10. Cross-cutting UX and platform concerns
Authentication flows are centralized in the frontend AuthContext and backend user/auth views, while protected routes enforce access on the client. Media uploads are supported through the backend media structure and upload utilities. Error handling, online status, skeleton loaders, and toasts are treated as shared UX infrastructure rather than feature-specific code.
11. Search and content discovery
Search is surfaced as its own route set under core_buetians/search_*, which suggests a cross-domain discovery layer rather than a single app-local search. This is important for diagramming because it sits above multiple domains like users, posts, groups, forums, and marketplace content.
12. Local runtime and deployment boundary
Development runs as two processes: a Django backend on port 8000 and a Vite frontend on port 3000, with run_fullstack.py acting as a convenience launcher. The repository also includes Swagger/ReDoc exposure, indicating the backend is intended to be inspected and integrated as an API-first service.
Main entry points: urls.py API router · DB_SCHEMA.sql SQL layer · authentication.py Shared utils · main.jsx App shell
Components 21
Backend
Django API, domain apps, Channels, and shared backend utilities
- manage.py · Administrative command entrypoint for the Django backend
BACKEND/manage.py - Core settings · Global Django configuration and request wiring
BACKEND/core_buetians/settings.py - API router · Main HTTP URL dispatcher that mounts domain API surfaces
BACKEND/core_buetians/urls.py - ASGI app · ASGI configuration for HTTP and WebSocket handling
BACKEND/core_buetians/asgi.py - Users · Accounts, profiles, authentication, and user-facing profile actions
BACKEND/users/views.py - Posts · Post creation, reading, and interaction workflows
BACKEND/posts/views.py - Chat · WebSocket chat, message delivery, and persisted conversation data
BACKEND/chat/consumers.py - Groups · Group membership, pages, and group interaction endpoints
BACKEND/groups/views.py - Forums · Forum threads and discussion-oriented endpoints
BACKEND/forums/views.py - Marketplace · Product listings and marketplace interactions
BACKEND/marketplace/views.py - Notifications · Cross-cutting notification generation and delivery endpoints
BACKEND/notification/views.py - Shared utils · Authentication, permissions, pagination, database, uploads, and exceptions
BACKEND/utils/authentication.py - Chat routing · WebSocket route mapping for the chat subsystem
BACKEND/chat/routing.py - Launcher · Convenience launcher for running frontend and backend together
run_fullstack.py
Frontend
React UI, pages, shared state, and client-side services
- App shell · Client bootstrap and top-level application wiring
FRONTEND/src/main.jsx - Auth context · Centralized authentication state and session flow on the client
FRONTEND/src/context/AuthContext.jsx - API service · HTTP data access layer used by pages and hooks
FRONTEND/src/services/apiService.js - Pages · Route-level screens for posts, groups, marketplace, forums, profile, search, and chat
FRONTEND/src/pages/Home/Home.jsx - Shared UI · Reusable components, route guards, loaders, and shared interaction widgets
FRONTEND/src/components/Navbar.jsx - Styles · App-wide and feature-specific CSS for the frontend
FRONTEND/src/styles/index.css
Data
PostgreSQL schema, functions, views, triggers, and procedures
- SQL layer · Schema, indexes, views, functions, procedures, and triggers that hold business logic
BACKEND/sql/DB_SCHEMA.sql
Connections 33
- manage.py → Core settings: loads · Django management commands use shared project settings
- Core settings → API router: wires · Project settings connect the main URL configuration
- Core settings → ASGI app: configures · Settings support the ASGI runtime used by HTTP and WebSockets
- API router → Users: routes · Main API router mounts the user domain
- API router → Posts: routes · Main API router mounts the posts domain
- API router → Chat: routes · Main API router mounts chat endpoints
- API router → Groups: routes · Main API router mounts group endpoints
- API router → Forums: routes · Main API router mounts forum endpoints
- API router → Marketplace: routes · Main API router mounts marketplace endpoints
- API router → Notifications: routes · Main API router mounts notification endpoints
- Chat → Chat routing: uses · Chat domain exposes live WebSocket routing
- Users → Shared utils: uses · Domain apps rely on shared auth and permission helpers
- Posts → Shared utils: uses · Shared utilities support validation, pagination, and uploads
- Groups → Shared utils: uses · Group workflows reuse common backend support
- Forums → Shared utils: uses · Forum endpoints use shared backend helpers
- Marketplace → Shared utils: uses · Marketplace endpoints reuse common backend support
- Notifications → Shared utils: uses · Notification logic depends on shared infrastructure helpers
- Chat → SQL layer: persists · Chat data and derived behavior are backed by PostgreSQL logic
- Users → SQL layer: reads/writes · User data is stored in PostgreSQL and may use SQL-side logic
- Posts → SQL layer: reads/writes · Post workflows depend on database tables, views, and functions
- Groups → SQL layer: reads/writes · Group workflows depend on database-side logic and storage
- Forums → SQL layer: reads/writes · Forum workflows depend on database-side logic and storage
- Marketplace → SQL layer: reads/writes · Marketplace workflows depend on database-side logic and storage
- Notifications → SQL layer: derives · Notifications are often produced from database-backed domain events
- Launcher → Core settings: starts · Launcher brings up the Django backend during local development
- Launcher → App shell: starts · Launcher brings up the Vite frontend during local development
- App shell → Auth context: uses · App bootstrap installs shared authentication state
- App shell → API service: uses · Client app talks to backend through a central API layer
- App shell → Pages: renders · React app is composed around route-level pages
- Pages → Shared UI: composes · Screens are built from shared navigation and reusable components
- Pages → Styles: styles · Pages are themed through shared CSS assets
- Pages → API service: fetches · Route-level screens load data through the service layer
- Shared UI → Auth context: consumes · Protected and authenticated UI depends on shared auth state