┌─────────────────────────────────┐
│ React Frontend │
│ (Vite + TypeScript + FC) │
│ Port 3000 → proxies to :5000 │
└──────────────┬──────────────────┘
│ HTTP/JSON (REST)
┌──────────────▼──────────────────┐
│ Flask Backend │
│ (Python 3.11+ / Flask) │
│ Port 5000 │
│ │
│ ┌───────────────────────────┐ │
│ │ Route Blueprints │ │
│ │ /api/health │ │
│ │ /api/chat/* │ │
│ │ /api/calendar/* │ │
│ │ /api/workouts/* │ │
│ └───────────┬───────────────┘ │
│ │ │
│ ┌───────────▼───────────────┐ │
│ │ Services Layer │ │
│ │ CoachAgent (AI logic) │ │
│ └───────────┬───────────────┘ │
│ │ │
│ ┌───────────▼───────────────┐ │
│ │ SQLAlchemy Models │ │
│ │ User, CalendarEvent, │ │
│ │ Workout, ChatMessage │ │
│ └───────────┬───────────────┘ │
│ │ │
│ ┌───────────▼───────────────┐ │
│ │ SQLite (dev) / Postgres │ │
│ └───────────────────────────┘ │
└──────────────┬──────────────────┘
│ OpenAI-compatible API
┌──────────────▼──────────────────┐
│ AI Provider │
│ (OpenAI / Ollama / etc.) │
└─────────────────────────────────┘
AI_Cycling_Coach/
├── Plan.md # Living project plan (updated as work progresses)
├── ARCHITECTURE.md # This file
├── REQUIREMENTS.md # API requirements & external dependencies
├── AGENT.md # Instructions for AI agents working on this codebase
├── backend/
│ ├── run.py # Entry point
│ ├── config.py # Flask configuration (dev/prod/test)
│ ├── requirements.txt # Python dependencies
│ ├── .env.example # Environment variable template
│ └── app/
│ ├── __init__.py # Flask app factory (create_app)
│ ├── models/ # SQLAlchemy models
│ │ ├── user.py
│ │ ├── calendar_event.py
│ │ ├── workout.py
│ │ └── chat_message.py
│ ├── routes/ # Flask blueprints (REST endpoints)
│ │ ├── health.py
│ │ ├── calendar.py
│ │ ├── chat.py
│ │ └── workouts.py
│ ├── services/ # Business logic
│ │ └── coach_agent.py # AI coaching agent
│ └── utils/
│ └── auth.py # User helper (MVP: single-user)
└── frontend/
├── package.json
├── vite.config.ts # Dev server + API proxy
├── tsconfig.json
└── src/
├── main.tsx # Entry point
├── App.tsx # Router setup
├── index.css # Global styles (dark theme)
├── types/ # TypeScript interfaces
├── services/ # API client layer
├── hooks/ # Custom React hooks
└── components/
├── Layout/ # Sidebar + shell
├── Calendar/ # FullCalendar integration
├── Chat/ # AI coach chat interface
└── Workout/ # Workout list + detail/logging modal