From 52b76d0e7736c5c8bf13ec512442a950c04860f9 Mon Sep 17 00:00:00 2001 From: jungwoo choi Date: Wed, 10 Sep 2025 16:02:23 +0900 Subject: [PATCH] Step 1: Minimal Foundation - Console service with Docker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created docker-compose.yml with Console backend service - Implemented Console backend with FastAPI (port 8011) - Added health check and status endpoints - Set up Docker-only development principle - Console service successfully running as API Gateway foundation Test with: - curl http://localhost:8011/health - curl http://localhost:8011/api/status πŸ€– Generated with Claude Code Co-Authored-By: Claude --- CLAUDE.md | 6 ++++ README.md | 29 ++++++++++++++++ console/backend/Dockerfile | 21 ++++++++++++ console/backend/main.py | 58 ++++++++++++++++++++++++++++++++ console/backend/requirements.txt | 5 +++ docker-compose.yml | 23 +++++++++++++ docs/PROGRESS.md | 8 +++-- 7 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 README.md create mode 100644 console/backend/Dockerfile create mode 100644 console/backend/main.py create mode 100644 console/backend/requirements.txt create mode 100644 docker-compose.yml diff --git a/CLAUDE.md b/CLAUDE.md index 05838c0..87903be 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,6 +2,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. +## Development Principles +**IMPORTANT**: +1. λͺ¨λ“  κ°œλ°œμ€ Docker ν™˜κ²½μ—μ„œλ§Œ μ§„ν–‰ +2. Docker λΉŒλ“œλŠ” λ°±κ·ΈλΌμš΄λ“œλ‘œ μ‹€ν–‰ν•˜κ³  μ™„λ£ŒκΉŒμ§€ λŒ€κΈ° +3. 둜컬 ν™˜κ²½ μ„€μ • κΈˆμ§€ (venv, npm install λ“±) + ## File Naming Convention **IMPORTANT**: λͺ¨λ“  λ¬Έμ„œ νŒŒμΌμ€ λŒ€λ¬Έμž.md ν˜•μ‹μœΌλ‘œ 생성 - 예: README.md, CHANGELOG.md, TODO.md, ARCHITECTURE.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4dcaa96 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Site11 - Microservices Architecture + +## Overview +Microservices platform with Console as API Gateway orchestrating multiple domain services. + +## Quick Start + +### Start Services +```bash +# Start console service +docker-compose up -d console-backend + +# Check status +curl http://localhost:8011/health +``` + +### Available Endpoints +- `http://localhost:8011/` - Root endpoint +- `http://localhost:8011/health` - Health check +- `http://localhost:8011/api/status` - System status + +## Architecture +- **Console**: API Gateway and orchestrator +- **Services**: Domain-specific microservices (users, oauth, images, etc.) +- **Database**: MongoDB for persistence +- **Cache**: Redis for caching and pub/sub + +## Development +See `docs/PLAN.md` for implementation roadmap and `docs/PROGRESS.md` for current status. \ No newline at end of file diff --git a/console/backend/Dockerfile b/console/backend/Dockerfile new file mode 100644 index 0000000..2515968 --- /dev/null +++ b/console/backend/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.11-slim + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements first for better caching +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy application code +COPY . . + +# Expose port +EXPOSE 8000 + +# Run the application +CMD ["python", "main.py"] \ No newline at end of file diff --git a/console/backend/main.py b/console/backend/main.py new file mode 100644 index 0000000..f832901 --- /dev/null +++ b/console/backend/main.py @@ -0,0 +1,58 @@ +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware +import uvicorn +from datetime import datetime + +app = FastAPI( + title="Console API Gateway", + description="Central orchestrator for microservices", + version="0.1.0" +) + +# CORS middleware +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +@app.get("/") +async def root(): + return { + "message": "Console API Gateway", + "status": "running", + "timestamp": datetime.now().isoformat() + } + +@app.get("/health") +async def health_check(): + return { + "status": "healthy", + "service": "console", + "timestamp": datetime.now().isoformat() + } + +@app.get("/api/status") +async def system_status(): + return { + "console": "online", + "services": { + "users": "pending", + "oauth": "pending", + "images": "pending", + "applications": "pending", + "data": "pending", + "statistics": "pending" + }, + "timestamp": datetime.now().isoformat() + } + +if __name__ == "__main__": + uvicorn.run( + "main:app", + host="0.0.0.0", + port=8000, + reload=True + ) \ No newline at end of file diff --git a/console/backend/requirements.txt b/console/backend/requirements.txt new file mode 100644 index 0000000..098afdc --- /dev/null +++ b/console/backend/requirements.txt @@ -0,0 +1,5 @@ +fastapi==0.109.0 +uvicorn[standard]==0.27.0 +python-dotenv==1.0.0 +pydantic==2.5.3 +httpx==0.26.0 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b1e4bf5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.8' + +services: + console-backend: + build: + context: ./console/backend + dockerfile: Dockerfile + container_name: site11_console_backend + ports: + - "8011:8000" + environment: + - ENV=development + - PORT=8000 + volumes: + - ./console/backend:/app + networks: + - site11_network + restart: unless-stopped + +networks: + site11_network: + driver: bridge + name: site11_network \ No newline at end of file diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 098ed56..3d35873 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -5,13 +5,17 @@ ## Current Status - **Date Started**: 2025-09-09 -- **Current Phase**: Planning Complete -- **Next Action**: Step 1 - Minimal Foundation κ΅¬ν˜„ +- **Current Phase**: Step 1 Complete βœ… +- **Next Action**: Step 2 - Add First Service (Users) ## Completed Checkpoints βœ… Project structure planning (CLAUDE.md) βœ… Implementation plan created (docs/PLAN.md) βœ… Progressive approach defined +βœ… Step 1: Minimal Foundation - Docker + Console Hello World + - docker-compose.yml created + - console/backend with FastAPI + - Running on port 8011 ## Active Working Files ```