How yasuo-kouki/stock-web-project works
1. System shape
- This repo is a split-client/split-server stock analysis app.
- The browser UI is a Next.js/React frontend; the API is a separate FastAPI service in Python.
- The backend persists state in SQLite and calls OpenAI for prediction generation.
2. Frontend boundary
- The documented frontend lives under frontend/ and is a TypeScript Next.js app with React components and CSS/Tailwind-style styling.
- It contains presentation components like components/Chart.tsx and components/StockChart.tsx, which are the main visualization layer for stock time series.
- pages/_app.tsx and pages/index.tsx indicate a Pages Router-based client in this directory.
3. Additional top-level Next.js app
- The repo root also contains an app/ directory plus public/ and stocks.db.
- That suggests a second Next.js app shell or a migration artifact alongside the frontend/ app.
- For architecture diagrams, treat this as an overlapping front-end surface rather than a separate backend service.
4. Backend service
- The backend is in backend/main.py and is the system’s API and business-logic entry point.
- It exposes at least two HTTP endpoints: POST /download_stock and POST /predict.
- download_stock fetches and returns stock data; predict runs a prediction flow using OpenAI.
5. Data layer
- The backend uses SQLite, with database files present as backend/stocks.db and a root-level stocks.db.
- This indicates local persistent storage for stock history and/or cached results rather than a remote database service.
- The DB sits behind the FastAPI boundary and is not accessed directly by the frontend.
6. External integrations
- OpenAI API is a core external dependency for the prediction path.
- The stock data acquisition path is server-side as well, so the browser never talks directly to market-data providers.
- This keeps secrets and data-fetching logic inside the backend.
7. Request/response flow
- User actions in the frontend trigger HTTP requests to the backend at the URL configured by NEXT_PUBLIC_API_URL.
- The backend returns either raw stock data for charting or a textual prediction payload.
- The chart components consume the returned time-series data to render the UI.
8. Runtime and configuration boundaries
- Local development expects the frontend on port 3000 and the backend on 8000.
- Backend CORS is controlled by CORS_ORIGINS, allowing the frontend origin(s) to call the API.
- Frontend API base URL is environment-driven, which is the main coupling point between the two tiers.
9. Deployment and packaging
- The backend has a Dockerfile and .dockerignore, so it is intended to be containerized.
- The repo also includes a GitHub Actions workflow under .github/workflows/ and Azure-related docs, indicating Azure deployment automation.
- The presence of both Docker artifacts and an Azure Static Web Apps workflow suggests mixed or evolving deployment paths.
10. Repo-level structure to diagram
- Show three major blocks: frontend client, FastAPI backend, and SQLite storage.
- Add an external dependency block for OpenAI, and optionally a stock-data source if you want to distinguish fetch vs predict flows.
- Note the duplicate/overlapping Next.js app layouts (frontend/ and root app/) as an implementation detail that may affect build/deploy boundaries.
Main entry points: index.tsx Frontend app · main.py FastAPI app · azure-static-web-apps-victorious-pond-049969d00.yml Azure workflow · stocks.db SQLite DB
Components 17
Frontend client
Next.js/React UI under frontend/ for browsing stock data and triggering analysis.
- Frontend app · Primary browser client with Pages Router entrypoints and shared UI.
frontend/pages/index.tsx - App wrapper · Client bootstrap and global composition for the frontend app.
frontend/pages/_app.tsx - Chart · Renders stock time-series visuals.
frontend/components/Chart.tsx - Stock chart · Stock-specific chart presentation layer.
frontend/components/StockChart.tsx
Root app shell
Top-level Next.js surface in app/ that overlaps with the frontend client boundary.
- Root app · Overlapping top-level Next.js surface in the repository root.
app/page.tsx - Layout · Root app router layout and global frame.
app/layout.tsx - Global styles · Shared styling for the root app shell.
app/globals.css
Backend API
FastAPI service that fetches data, persists state, and generates predictions.
- FastAPI app · Main backend entrypoint exposing stock download and prediction endpoints.
backend/main.py - Download stock · Server-side stock data acquisition and response path.
backend/main.py - Predict · Prediction flow that produces model output for the UI.
backend/main.py
Storage
Local SQLite persistence used by the backend.
External services
Third-party APIs the backend depends on.
- OpenAI · External prediction dependency used by the backend.
- Market data · External stock-data source reached only from the backend.
Deployment
Container and workflow artifacts for shipping the app.
- Azure workflow · GitHub Actions automation for Azure deployment.
.github/workflows/azure-static-web-apps-victorious-pond-049969d00.yml - Dockerfile · Backend container packaging for local or cloud deployment.
backend/Dockerfile - Azure docs · Documentation for Azure-oriented deployment paths.
AZURE_DOCKER_DEPLOYMENT.md
Connections 18
- Frontend app → FastAPI app: HTTP requests · Browser actions call the backend API configured by environment.
- App wrapper → Frontend app: bootstraps · Shared client setup wraps the page surface.
- Frontend app → Chart: renders · Main page feeds chart components with stock data.
- Frontend app → Stock chart: renders · Stock-specific visualization layer consumes the returned series.
- Root app → Layout: wraps · Root app router layout frames the overlapping Next.js surface.
- Layout → Global styles: styles · Layout applies global root styling.
- FastAPI app → Download stock: serves · Backend exposes stock download behavior through its main entrypoint.
- FastAPI app → Predict: serves · Backend exposes prediction behavior through its main entrypoint.
- Download stock → Market data: fetches · Stock acquisition is performed server-side against external sources.
- Predict → OpenAI: calls · Prediction generation depends on OpenAI.
- Download stock → SQLite DB: persists · Fetched or cached stock data is stored locally.
- Predict → SQLite DB: reads · Prediction flow uses local persisted history or cached state.
- DB copy → SQLite DB: duplicate · Repository contains overlapping SQLite database artifacts.
- Frontend app → Root app: overlaps · The repository has two Next.js surfaces that likely share build/deploy concerns.
- Azure workflow → Frontend app: deploys · CI workflow supports shipping the web client.
- Azure workflow → FastAPI app: deploys · CI workflow also suggests backend or integrated deployment automation.
- Dockerfile → FastAPI app: packages · Backend service is containerized for deployment.
- Azure docs → Azure workflow: documents · Docs describe the Azure deployment path and workflow usage.