FastAPI CRUD with JSON and routers
Prequesite
- siapkan venv
- aktifkan venv
- install fastapi
- tambahkan file db.json
- jalankan
fastapi dev main.py
Features
- Create, Read, Update, Delete user
- JSON file sebagai penyimpanan data (
db.json)
- Swagger UI otomatis
- Modular structure (router, service, data layer)
- Tanpa ORM, tanpa database dan tanpa pydantic
Project Structure
project/
āā main.py # App bootstrap
āā users_router.py # Router / controller
āā users_service.py # Business logic
āā json_db.py # JSON file data access
āā db.json # Database file
āā README.md
āā .venv/
Database (JSON File)
[
{
"id": 1,
"name": "Pythonia",
"email": "pythonia@mail.com",
"is_active": true
}
]
API Endpoints