A scalable and maintainable backend API built with Django, Django REST Framework, and JWT Authentication, following Clean Architecture, Service Layer, Repository Pattern, and an Event-Driven Architecture.
One of the core modules is a Google Drive-inspired Storage Manager, providing hierarchical folder management, file organization, uploads, downloads, moving, renaming, and deletion through a RESTful API.
The project is fully containerized with Docker Compose and designed for scalability, maintainability, and clean separation of concerns.
- Clean Architecture
- Service Layer
- Repository Pattern
- Event-Driven Architecture
- JWT Authentication
- RESTful API
- Folder/File Management (Google Drive-like)
- Docker & Docker Compose
- Celery Background Tasks
- Redis Message Broker
- PostgreSQL Database
- Audit Logging
- Pagination
- Filtering & Searching
- Permission-based APIs
- Asynchronous Event Processing
- Ready for Horizontal Scaling
| Technology | Purpose |
|---|---|
| Python | Programming Language |
| Django | Web Framework |
| Django REST Framework | REST API |
| PostgreSQL | Database |
| Redis | Cache & Message Broker |
| Celery | Background Tasks |
| JWT | Authentication |
| Docker | Containerization |
| Docker Compose | Local Development |
| Clean Architecture | Application Structure |
| Repository Pattern | Data Access Layer |
| Service Layer | Business Logic |
| Event Driven | Loose Coupling |
project/
│
├── apps/
│ ├── useraccount/
│ ├── storage/
│ ├── dashboard/
│ └── auditlog/
│
├── config/
│
├── docker/
│
├── requirements/
│
├── docker-compose.yml
├── Dockerfile
└── manage.py
Responsible for:
- User Registration
- Login
- JWT Authentication
- Profile Management
- Permissions
- User Events
Responsible for:
- Folder Management
- File Management
- Nested Directories
- Upload
- Download
- Rename
- Move
- Delete
- Storage Events
The storage system behaves similarly to Google Drive, allowing unlimited nested folders and files.
Responsible for:
- Dashboard Statistics
- Storage Overview
- User Metrics
- Activity Summary
Responsible for:
- Recording System Events
- Tracking User Activities
- Logging File Operations
- Authentication Logs
- Event History
This project follows Clean Architecture principles.
HTTP Request
│
▼
DRF View / API
│
▼
Service Layer
│
┌──────────────┴──────────────┐
▼ ▼
Repository Layer Domain Events
│ │
▼ ▼
Django ORM Event Handlers
│ │
└──────────────┬──────────────┘
▼
PostgreSQL
Each layer has a single responsibility.
Contains:
- Views
- Serializers
- Permissions
- Authentication
- API Validation
Responsibilities:
- Receive HTTP Requests
- Validate Input
- Return HTTP Responses
Contains the complete business logic.
Responsibilities:
- Execute use cases
- Validate business rules
- Coordinate repositories
- Publish domain events
Example:
Create Folder
Request
↓
Serializer
↓
FolderService.create_folder()
↓
FolderRepository.create()
↓
FolderCreatedEvent
Responsible for database communication.
Responsibilities:
- Query Database
- Create Records
- Update Records
- Delete Records
Services never communicate directly with Django ORM.
Instead:
Service
↓
Repository
↓
ORM
The application is loosely coupled using events.
Example events:
UserRegisteredEvent
UserLoggedInEvent
FolderCreatedEvent
FolderDeletedEvent
FolderRenamedEvent
FileUploadedEvent
FileDeletedEvent
FileMovedEvent
PasswordChangedEvent
Each event can have multiple listeners.
Example:
FolderCreatedEvent
│
├────────► Audit Logger
│
├────────► Dashboard Update
│
└────────► Notification
No module depends directly on another module.
storage/
├── api/
│ ├── serializers.py
│ ├── views.py
│ └── urls.py
│
├── services/
│ ├── folder_service.py
│ └── file_service.py
│
├── repositories/
│ ├── folder_repository.py
│ └── file_repository.py
│
├── events/
│ ├── publishers.py
│ ├── handlers.py
│ └── events.py
│
├── models.py
├── permissions.py
└── signals.py
Every application follows the same architecture.
Client
│
▼
APIView
│
▼
Serializer Validation
│
▼
Service Layer
│
▼
Repository Layer
│
▼
Database
│
▼
Publish Event
│
▼
Event Handlers
│
▼
Response
Business Action
│
▼
Publish Event
│
▼
Event Dispatcher
│
┌─────┼───────────┐
▼ ▼ ▼
Audit Dashboard Notifications
Authentication is implemented using JWT.
Typical flow:
Register
↓
Login
↓
Access Token
↓
Refresh Token
↓
Authenticated APIs
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register/ |
Register new user |
| POST | /api/auth/login/ |
Login |
| POST | /api/auth/refresh/ |
Refresh JWT Token |
| POST | /api/auth/logout/ |
Logout |
| GET | /api/auth/profile/ |
Current User |
| PATCH | /api/auth/profile/ |
Update Profile |
| POST | /api/auth/change-password/ |
Change Password |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/storage/folders/ |
List folders |
| POST | /api/storage/folders/ |
Create folder |
| GET | /api/storage/folders/{id}/ |
Folder details |
| PATCH | /api/storage/folders/{id}/ |
Rename folder |
| DELETE | /api/storage/folders/{id}/ |
Delete folder |
| POST | /api/storage/folders/{id}/move/ |
Move folder |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/storage/files/ |
List files |
| POST | /api/storage/files/upload/ |
Upload file |
| GET | /api/storage/files/{id}/ |
File details |
| GET | /api/storage/files/{id}/download/ |
Download file |
| PATCH | /api/storage/files/{id}/ |
Rename file |
| DELETE | /api/storage/files/{id}/ |
Delete file |
| POST | /api/storage/files/{id}/move/ |
Move file |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/dashboard/overview/ |
Dashboard Overview |
| GET | /api/dashboard/storage/ |
Storage Statistics |
| GET | /api/dashboard/activity/ |
Recent Activities |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/audit/logs/ |
List Audit Logs |
| GET | /api/audit/logs/{id}/ |
Audit Log Details |
The project is fully containerized.
docker compose up --builddocker compose downdocker compose exec web python manage.py migratedocker compose exec web python manage.py createsuperuserdocker compose exec web pytestDocker Compose starts the following services:
- Django API
- PostgreSQL
- Redis
- Celery Worker
- Celery Beat (optional)
This architecture provides:
- Clear separation of concerns
- Testable business logic
- Loosely coupled modules
- Easy scalability
- High maintainability
- Easy feature extension
- Independent domain components
- Minimal ORM dependency inside business logic
- API Versioning
- OpenAPI / Swagger Documentation
- WebSocket Notifications
- File Sharing
- Role-Based Access Control (RBAC)
- Object-Level Permissions
- Soft Delete
- Multi-Tenant Support
- Distributed Event Bus (Kafka/RabbitMQ)
- S3 / MinIO Storage
- Prometheus & Grafana Monitoring
This project is intended as a production-ready backend template demonstrating Clean Architecture, Service Layer, Repository Pattern, and Event-Driven design using Django and Django REST Framework.
