# okchang95/oow-fastapi architecture

> Architecture diagram of the GitHub repository okchang95/oow-fastapi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/okchang95/oow-fastapi
- Repository: https://github.com/okchang95/oow-fastapi

## Overview

##### Project type and purpose
- This is a monolithic FastAPI-based backend service that exposes RESTful endpoints for:
- MyPage (image upload + OCR verification + user stats)
- Calendar (daily attendance overview)
- Notice (CRUD for announcements)
- It uses Firebase (Firestore + Storage) as its database and file store, and is packaged in a Docker container.

##### File structure
- Top-level:
- Dockerfile / .dockerignore / .gitignore / requirements.txt
- README.md with environment and usage instructions
- serviceAccountKey.json + .env for Firebase credentials and config
- app/
- main.py — FastAPI app instantiation + router mounting
- api/ — route modules (calendar, mypage, notice)
– each subfolder has a router .py handling HTTP methods
– mypage/timecheck/ocr.py provides image-to-text logic
- core/config.py — Pydantic settings loader
- db/firebase.py — initializes Firebase Admin SDK (Firestore & Storage)

##### README for additional insights
- Environment variables configure CORS (FRONTEND_URL), Firebase key path, bucket name
- Docker build and run instructions emphasize volume-mounting the Firebase key

##### Elements
- Clear labels: “FastAPI Server”, “Router Layer”, “OCR Service”, “Firebase Firestore”, “Firebase Storage”, “Frontend/UI”
- Client → HTTP → FastAPI
- FastAPI → Firebase Storage / Firestore
- OCR → Storage → OCR result → FastAPI → Client
- Blue rectangles for internal modules (app/api, app/core, app/db)

##### Detailed guidance
- Inside it, partition three horizontal layers:
1) “API Gateway” – listing the three routers (calendar, mypage, notice)
2) “Business Logic” – OCR module, stats calculator
3) “Data Access” – Firebase initializer module
- Outside the container, show:
- Frontend (browser at FRONTEND_URL) invoking /docs and endpoints
- .env + serviceAccountKey.json feeding into the container at startup
- Firebase Cloud with two sub-services: Firestore and Storage

## Diagram (Mermaid)

```mermaid
flowchart TD
    UI["Frontend / UI"]:::external
    ENV[".env"]:::external
    SA["serviceAccountKey.json"]:::external
    README["README.md"]:::external
    REQ["requirements.txt"]:::external

    UI -->|"HTTP Requests"| main["FastAPI Server"]:::internal
    ENV -->|mounted at startup| main
    SA -->|mounted at startup| main

    subgraph Container["Docker Container"]
        direction TB
        subgraph "API Gateway"
            CR["Calendar Router"]:::internal
            MR["MyPage Router"]:::internal
            NR["Notice Router"]:::internal
        end
        subgraph "Business Logic"
            OCR["OCR Service"]:::internal
        end
        subgraph "Configuration"
            CFG["Pydantic Config Loader"]:::internal
        end
        subgraph "Data Access"
            FB["Firebase Init Module"]:::internal
        end
    end

    main --> CR
    main --> MR
    main --> NR
    main --> CFG
    CFG --> FB

    CR -->|"list files"| ST
    MR -->|"upload image"| OCR
    OCR -->|"upload to storage"| ST
    OCR -->|"write record"| FS
    MR -->|"query stats"| FS
    NR -->|"CRUD metadata"| FS
    NR -->|"upload asset"| ST

    FB --> FS
    FB --> ST

    subgraph FirebaseCloud["Firebase Cloud Services"]
        FS["Firestore"]:::database
        ST["Storage Bucket"]:::storage
    end

    subgraph DockerConfig["Container Config Files"]
        DCK["Dockerfile"]:::config
        DCI[".dockerignore"]:::config
    end

    DCK --> Container
    DCI --> Container
    README --> Container
    REQ --> Container

    classDef internal fill:#E0F7FA,stroke:#0288D1
    classDef database fill:#C8E6C9,stroke:#388E3C,stroke-width:2px
    classDef storage fill:#FFE0B2,stroke:#F57C00
    classDef external fill:#CFD8DC,stroke:#78909C,stroke-dasharray: 5 5
    classDef config fill:#FFF9C4,stroke:#FBC02D

    click main "https://github.com/okchang95/oow-fastapi/blob/main/app/main.py"
    click CR "https://github.com/okchang95/oow-fastapi/blob/main/app/api/calendar/calendar.py"
    click MR "https://github.com/okchang95/oow-fastapi/blob/main/app/api/mypage/mypage.py"
    click NR "https://github.com/okchang95/oow-fastapi/blob/main/app/api/notice/notice.py"
    click OCR "https://github.com/okchang95/oow-fastapi/blob/main/app/api/mypage/timecheck/ocr.py"
    click CFG "https://github.com/okchang95/oow-fastapi/blob/main/app/core/config.py"
    click FB "https://github.com/okchang95/oow-fastapi/blob/main/app/db/firebase.py"
    click DCK "https://github.com/okchang95/oow-fastapi/tree/main/Dockerfile"
    click DCI "https://github.com/okchang95/oow-fastapi/blob/main/.dockerignore"
    click ENV "https://github.com/okchang95/oow-fastapi/blob/main/.env"
    click SA "https://github.com/okchang95/oow-fastapi/blob/main/serviceAccountKey.json"
    click README "https://github.com/okchang95/oow-fastapi/blob/main/README.md"
    click REQ "https://github.com/okchang95/oow-fastapi/blob/main/requirements.txt"
```
