A scalable, high-performance backend service mimicking core Instagram functionality, built with Clean Architecture and Domain-Driven Design (DDD) principles.
- Language: Python 3.14+
- Framework: FastAPI (Async)
- Database: PostgreSQL 15
- ORM: SQLAlchemy 2.0 (Async)
- Migrations: Alembic
- Authentication: JWT (Argon2 password hashing)
- Package Manager: uv (recommended) or pip
- Python 3.14+
- Docker & Docker Compose
- uv (optional but recommended for dependency management)
git clone https://github.com/Jayzhong/insta-backend.git
cd insta-backendCreate a .env file in the root directory. You can copy the example:
cp .env.example .envEnsure the .env values match your database configuration (defaults provided in .env.example work with the Docker setup).
Using uv (Recommended):
uv syncUsing pip:
pip install .Launch the PostgreSQL database container:
docker-compose up -dInitialize the database schema:
# If using uv
uv run alembic upgrade head
# If using pip/venv
source .venv/bin/activate
alembic upgrade head# If using uv
uv run uvicorn main:app --reload --host 0.0.0.0 --port 8000
# If using pip/venv
uvicorn main:app --reload --host 0.0.0.0 --port 8000# Execute all integration tests
uv run pytest tests/integration/Once the server is running, access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
This project strictly follows Clean Architecture to ensure decoupling and testability. The code is organized into four concentric layers:
- Domain (
src/domain): Pure business logic and entities. No external dependencies. - Application (
src/application): Use cases orchestrating the domain logic. - Interfaces (
src/interfaces): Adapters for the outside world (API routers, etc.). - Infrastructure (
src/infrastructure): Concrete implementations (Database, File Storage, Auth providers).
Dependencies only point inwards.