Skip to content

Commit 9b20c3b

Browse files
authored
Merge pull request #3 from omidcodes/003-add-readme-file
Add Readme.md file Seperate development and production bash scripts
2 parents df8b779 + 660ae35 commit 9b20c3b

8 files changed

Lines changed: 161 additions & 16 deletions

File tree

.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# development env
2+
3+
DEBUG=True
4+
SECRET_KEY=your-secret-key-for-dev
5+
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,[::1]
6+
7+
POSTGRES_DB=taskflow
8+
POSTGRES_USER=postgres
9+
POSTGRES_PASSWORD=postgres
10+
POSTGRES_HOST=localhost
11+
POSTGRES_PORT=5432
12+
13+
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672//

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ RUN pip install --upgrade pip && pip install -r requirements.txt
1414

1515
# Copy project files
1616
COPY . .
17+
COPY entrypoint.sh /entrypoint.sh
18+
RUN chmod +x /entrypoint.sh
1719

1820
# Collect static files (optional if using admin panel)
1921
RUN mkdir -p /vol/web/static
2022

21-
CMD ["gunicorn", "taskflow_api.wsgi:application", "--bind", "0.0.0.0:8000"]
23+
CMD ["/entrypoint.sh"]

README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
2+
# 🧩 TaskFlow API
3+
4+
A Django RESTful API for managing personal or team tasks — featuring PostgreSQL, RabbitMQ, Docker support, and developer/production-ready configurations.
5+
6+
---
7+
8+
## 🚀 Features
9+
10+
- ✅ Django 5 + Django REST Framework
11+
- ✅ PostgreSQL database (via Docker)
12+
- ✅ RabbitMQ for background tasks (Celery-ready)
13+
- ✅ Environment config with `.env` and `python-decouple`
14+
- ✅ Swagger UI for API documentation
15+
- ✅ Containerized with Docker
16+
- ✅ CLI scripts for development and production modes
17+
18+
---
19+
20+
## 📁 Project Structure
21+
22+
```
23+
taskflow-api/
24+
├── taskflow_api/ # Django project
25+
├── tasks/ # App: task models, views, serializers
26+
├── requirements.txt # Python dependencies
27+
├── Dockerfile # Production image for gunicorn
28+
├── docker-compose.yml # DB and RabbitMQ container setup
29+
├── .env # Environment configuration
30+
├── run_server.sh # Run production server (Gunicorn)
31+
└── start-dev-services.sh # Run DB + RabbitMQ for development
32+
```
33+
34+
---
35+
36+
## ⚙️ Prerequisites
37+
38+
- Python 3.12+
39+
- Docker & Docker Compose
40+
- Virtualenv (optional but recommended)
41+
42+
---
43+
44+
## 📦 Setup Instructions
45+
46+
### 🔧 1. Install Python Dependencies
47+
```bash
48+
python3 -m venv env
49+
source env/bin/activate
50+
pip install -r requirements.txt
51+
```
52+
53+
### 🔧 2. Configure Environment
54+
Edit `.env` (already provided):
55+
```dotenv
56+
DEBUG=True
57+
SECRET_KEY=your-secret-key
58+
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,[::1]
59+
60+
POSTGRES_DB=taskflow
61+
POSTGRES_USER=postgres
62+
POSTGRES_PASSWORD=postgres
63+
POSTGRES_HOST=localhost
64+
POSTGRES_PORT=5432
65+
66+
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672//
67+
```
68+
69+
---
70+
71+
## 🧪 Development Mode
72+
73+
Use this when you want to run Django locally (`runserver`) and containers only for DB/RabbitMQ.
74+
75+
### ▶️ Start Docker Services:
76+
```bash
77+
./start-dev-services.sh
78+
```
79+
80+
> This will:
81+
> - Start PostgreSQL and RabbitMQ containers
82+
> - Stop and remove any running `web` container
83+
> - Run DB migrations automatically
84+
85+
### ▶️ Then Run Django:
86+
```bash
87+
python3 manage.py runserver
88+
```
89+
90+
Open:
91+
- Swagger docs: http://localhost:8000/docs/
92+
- API root: http://localhost:8000/api/tasks/
93+
94+
---
95+
96+
## 🏭 Production Mode (Dockerized Web)
97+
98+
### ▶️ Build & Run All Services:
99+
```bash
100+
./run_server.sh
101+
```
102+
103+
> This uses Docker to run:
104+
> - Django (with Gunicorn)
105+
> - PostgreSQL
106+
> - RabbitMQ
107+
108+
You can also run manually:
109+
```bash
110+
docker compose up --build
111+
```
112+
113+
---
114+
115+
## 🗃️ Tech Stack
116+
117+
- **Backend**: Django 5, DRF
118+
- **Database**: PostgreSQL (Docker)
119+
- **Broker**: RabbitMQ (Docker)
120+
- **Containerization**: Docker, Docker Compose
121+
- **CI-ready**: Gunicorn + environment-based config
122+
123+
---
124+
125+
## 📜 License
126+
127+
MIT © Omid Hashemzadeh

docker-compose.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
services:
22
web:
33
build: .
4-
command: gunicorn taskflow_api.wsgi:application --bind 0.0.0.0:8000
4+
command: /entrypoint.sh
55
volumes:
66
- .:/app
77
ports:
88
- "8000:8000"
99
depends_on:
1010
- db
1111
- rabbitmq
12+
env_file:
13+
- .env
1214
environment:
13-
- DEBUG=1
14-
- DJANGO_SETTINGS_MODULE=taskflow_api.settings
15-
- POSTGRES_DB=taskflow
16-
- POSTGRES_USER=postgres
17-
- POSTGRES_PASSWORD=postgres
18-
- POSTGRES_HOST=db
19-
- POSTGRES_PORT=5432
15+
POSTGRES_HOST: db
2016

2117
db:
2218
image: postgres
2319
restart: always
24-
environment:
25-
POSTGRES_DB: taskflow
26-
POSTGRES_USER: postgres
27-
POSTGRES_PASSWORD: postgres
20+
env_file:
21+
- .env
2822
ports:
2923
- "5432:5432"
3024

entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
echo "🚀 Running migrations..."
4+
python manage.py migrate
5+
6+
echo "🚀 Starting Gunicorn..."
7+
exec gunicorn taskflow_api.wsgi:application --bind 0.0.0.0:8000

requirements.txt

-840 Bytes
Binary file not shown.

run_server.sh

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
docker compose down
24
docker compose build --no-cache
35
docker compose up

taskflow_api/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@
118118
DATABASES = {
119119
'default': {
120120
'ENGINE': 'django.db.backends.postgresql',
121-
'NAME': config('POSTGRES_DB', default='taskflow'),
122-
'USER': config('POSTGRES_USER', default='postgres'),
123-
'PASSWORD': config('POSTGRES_PASSWORD', default='postgres'),
121+
'NAME': config('POSTGRES_DB'),
122+
'USER': config('POSTGRES_USER'),
123+
'PASSWORD': config('POSTGRES_PASSWORD'),
124124
'HOST': config('POSTGRES_HOST', default='localhost'),
125125
'PORT': config('POSTGRES_PORT', default='5432'),
126126
}

0 commit comments

Comments
 (0)