API lengkap untuk membuat, membaca, memperbarui, dan menghapus artikel menggunakan FastAPI dan ClickHouse sebagai database utama. API ini mendukung otentikasi JWT, dokumentasi Swagger UI, ekspor data ke CSV, pagination, serta visualisasi melalui Grafana.
- ✅ CRUD Artikel (
GET,POST,PUT,DELETE) - 🔐 Login dengan Auth JWT
- 📄 Swagger UI otomatis
- 🔁 Pagination & Search
- 📦 Export data ke CSV
- 🧪 Unit Test dengan
pytest - 📊 Visualisasi data di Grafana
- 🔧 Struktur proyek modular dan terorganisir
- 🐳 Siap deploy dengan Docker Compose
- FastAPI
- ClickHouse
- clickhouse-connect
- Faker untuk dummy data
- Grafana untuk dashboard
- Docker untuk containerisasi
- pytest untuk pengujian
fastapi-clickhouse-crud/
├── app/
│ ├── main.py
│ ├── core/
│ │ ├── config.py
│ │ └── security.py
│ ├── models/
│ │ └── article.py
│ ├── routers/
│ │ ├── auth.py
│ │ └── articles.py
│ └── services/
│ └── clickhouse_client.py
├── tests/
│ └── test_articles.py
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
├── .env
└── README.md
git clone https://github.com/eka0789/fastapi-clickhouse-crud.git
cd fastapi-clickhouse-crudpython -m venv env
# Windows
env\Scripts\activate
# Linux/Mac
source env/bin/activatepip install -r requirements.txtdocker run -d --name clickhouse-server -p 8123:8123 -p 9000:9000 clickhouse/clickhouse-serveruvicorn app.main:app --reloaddocker compose up --build -dAkses:
- API: http://localhost:8000/docs
- Grafana: http://localhost:3000
- ClickHouse: http://localhost:8123
Login Grafana: admin / admin
{
"username": "admin",
"password": "password"
}{
"title": "Judul Artikel",
"content": "Isi artikel yang sangat menarik."
}Mendapatkan semua artikel (support ?skip=0&limit=10&q=keyword)
Mengunduh artikel dalam bentuk file CSV.
pytest tests/test_articles.py- Akses Grafana
http://localhost:3000 - Tambah ClickHouse sebagai Data Source (host:
http://clickhouse:8123) - Buat Dashboard → Panel → Query:
SELECT count() FROM articles
- Simpan & sesuaikan visualisasinya.
- 🔐 Manajemen user & roles (admin/user)
- ⏱ Scheduled job & data analytics
- 📦 Export ke Excel/JSON
- 🔒 Rate limiting & throttling
- ☁️ CI/CD deployment pipeline
MIT License © 2025 Eka Prasetyo (Aktif Koding)