This covers the basics for getting set up and working on the CloudGate project locally.
Here's what runs locally when you start everything up:
| Service | Port | Docs |
|---|---|---|
| Gateway | 8000 | http://localhost:8000/docs |
| Auth | 8001 | http://localhost:8001/docs or /redoc |
| Profile | 8002 | http://localhost:8002/docs |
| Prometheus | 9090 | http://localhost:9090 |
| Grafana | 3000 | http://localhost:3000 (admin/admin) |
When making API calls, use these base URLs:
- Auth Service:
http://localhost:8001POST /api/v1/auth/register- Register a new userPOST /api/v1/auth/login- Login and get tokensPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/logout- Logout (requires auth)GET /api/v1/auth/me- Get current user info (requires auth)POST /api/v1/auth/change-password- Change password (requires auth)POST /api/v1/auth/verify-token- Verify token validity (requires auth)
- Gateway:
http://localhost:8000- Routes requests to appropriate services
- Profile Service:
http://localhost:8002- Profile management endpoints
Note: Endpoints marked "(requires auth)" need an Authorization: Bearer <token> header with your access token from login.
Here are some examples of how to interact with the APIs:
# Register a new user
curl -X POST http://localhost:8001/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "Test123!@#", "first_name": "John", "last_name": "Doe"}'
# Login to get tokens
curl -X POST http://localhost:8001/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "Test123!@#"}'
# Get current user info (replace TOKEN with actual token)
curl -X GET http://localhost:8001/api/v1/auth/me \
-H "Authorization: Bearer TOKEN"You can also use the interactive docs at http://localhost:8001/docs to test endpoints directly in your browser.
FastAPI automatically generates two types of documentation:
- Swagger UI (
/docs): Interactive docs where you can actually test API endpoints right in your browser. Click "Try it out" on any endpoint to send real requests. - ReDoc (
/redoc): Clean, printable documentation that's great for sharing specs or reading through the API structure.
Both pull from the same source - your FastAPI route definitions and Pydantic models - so they're always in sync.
Note: The Auth login endpoint uses strict validation — unknown/extra request fields result in HTTP 422 Unprocessable Entity.
Getting your local environment ready:
# Clone and setup
git clone https://github.com/amgad01/cloudgate.git && cd cloudgate
python3.13 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install --upgrade pip
pip install -e ".[dev]"
pre-commit install# Install Docker Desktop for Windows with WSL2 integration
# In WSL2 Ubuntu shell:
sudo apt update && sudo apt install -y \
python3.13 python3.13-venv python3.13-dev \
nodejs git build-essentialIf you're new to this tech stack, here's a good order to learn things in:
- Python Async Basics: Get comfortable with async/await and asyncio
- FastAPI: Learn about routing, dependency injection, and middleware
- ASGI: Understand how it differs from WSGI
- Uvicorn: The ASGI server and how development reload works
- Pydantic v2: Data validation and configuration management
- SQLAlchemy 2.0: Async ORM patterns and working with asyncpg
- Alembic: Handling database schema changes
- Redis: Using the async client for caching
- JWT & Security: Token handling and password security
- Docker: Building images, running containers, and using compose
- Prometheus & Grafana: Setting up metrics and dashboards
- TypeScript: Frontend components (if you work on the UI)
Key folders to know:
services/— The microservices (gateway, auth, profile). Each has amain.pyfor the FastAPI app andapi/routes.pyfor the endpointsshared/— Common code likeconfig.py, database connections, middleware, and data schemasdocker/— Dockerfiles for building the service imagesdocker-compose.yml— How everything runs together locallyinfrastructure/— AWS setup code using CDKTFtests/— Unit and integration testspyproject.toml— Python dependencies and project configMakefile— Handy shortcuts for common tasks
git clone https://github.com/amgad01/cloudgate.git
cd cloudgate# Start everything
make dev
# or
docker-compose up -d
# Check that containers are running
docker-compose ps
# Follow logs for a specific service
docker-compose logs -f gateway# Run all tests
make test
# Run a specific test file
pytest tests/unit/test_auth.py -v
# Run just one test with shorter output
pytest -k "test_login" --tb=shortbash scripts/reset-db.shmake dev # Start all services
make test # Run the test suite
make docker-build # Build container images
docker-compose logs -f # Follow logs from all services# Connect to the database
docker-compose exec postgres psql -U postgres -d cloudgate
# Get a shell in a running container
docker-compose exec gateway bash
# Check recent logs for a service
docker-compose logs -f gateway --tail=50The default settings for development are in docker-compose.yml. If you need to override anything locally, create a .env file:
# .env (don't commit this file)
DEBUG=true
DATABASE_URL=postgresql://...We follow these conventions:
- Python: PEP 8 with Black formatting and 4-space indentation
- TypeScript: Strict mode, no
anytypes allowed - Pre-commit hooks will enforce these rules when you commit
Async database:
async def get_user(user_id: int):
async with get_db_session() as session:
return await session.get(User, user_id)Dependency injection:
async def get_current_user(token: str = Depends(get_token)):
return verify_token(token)Error handling:
raise HTTPException(status_code=400, detail="Invalid request")# Check for port conflicts
lsof -i :8000
# Completely rebuild everything
docker-compose down -v && docker-compose up -d --build
# Reset the database if things are messed up
bash scripts/reset-db.sh
# Get detailed output from failing tests
pytest tests/unit/test_auth.py -vv --tb=long- Run
make devto start everything - Open http://localhost:8000/docs to see the gateway API
- Look at
services/gateway/main.pyto understand the app structure - Check out
tests/unit/to see how we write tests