# l-quincy01/student-hub-app architecture

> Architecture diagram of the GitHub repository l-quincy01/student-hub-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/l-quincy01/student-hub-app
- Repository: https://github.com/l-quincy01/student-hub-app

## Overview

##### Project type and purpose
- This is a full-stack mobile marketplace application called Student Hub.
- Frontend: a React Native (Expo) client for iOS/Android.
- Backend: a Go HTTP API using the Fiber framework.
- Data persistence: MongoDB (self-hosted or via Docker Compose).
- Authentication: Firebase Auth (OAuth2 & phone/SMS).

##### File structure
- Top-level folders:
- api/ – Go source code, config, DB adapters, controllers, services, repositories, middleware.
- client/ – React Native code: App.js, navigation (TabNavigation), screens, hooks, assets, Tailwind config.
- .expo/ – Expo Metro bundler internals (supports local development).
- docker-compose.yml under api/ defines MongoDB service.
- Go API follows a layered (controller → service → repository → DB) architecture.
- React Native client uses Expo, React Navigation (tab navigation), custom hooks, and Firebase SDK.

##### Pull additional insights from the README
- README confirms tech stack: React Native + JavaScript on the client, Go + Fiber on the API, MongoDB, Firebase Auth.

a. Main components
- Mobile App (Expo/React Native)
- Expo Metro Bundler (dev toolchain)
- Go API Server (Fiber)
- Firebase Auth (external OAuth2 provider)
- MongoDB database
- (Optional) Docker Compose orchestrator for local MongoDB
b. Relationships & interactions
1. Mobile App → Firebase Auth: sign-in/sign-up (OAuth2 or phone)
2. Firebase Auth → Mobile App: ID token or OTP flow
3. Mobile App → Go API: attach Firebase token, request business endpoints (products, users, orders)
4. Go API → Firebase Auth: validate token & fetch user identity
5. Go API → MongoDB: CRUD operations for users, products, orders, documents
6. Go API → Mobile App: respond with JSON payloads
c. Architectural patterns & principles
- Mobile: component-based UI, unidirectional data flow via hooks and React Navigation.
- API: layered “clean-onion” style – controllers handle HTTP, services contain business logic, repositories abstract DB, middleware handles auth.
- Separation of concerns: authentication (Firebase) vs business data (MongoDB) vs presentation (mobile screens).
d. Key technologies
- Mobile: React Native, Expo, React Navigation, Tailwind CSS (via tailwind.config.js), TypeScript settings.
- API: Go, Fiber framework, MongoDB driver, Firebase Admin SDK, environment/config management (env_config.go, secrets_config.go).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Services
    FirebaseAuth["Firebase Auth (OAuth2 / SMS)"]:::external

    %% Client Side
    subgraph "Client Side"
        direction TB
        ExpoMetro["Expo Metro Bundler"]:::client
        MobileApp["Mobile App (Expo/React Native)"]:::client
        ExpoMetro -->|"bundles"| MobileApp
        subgraph "Mobile App Structure"
            direction TB
            AppJs["App.js"]:::client
            TabNav["TabNavigation.js"]:::client
            Screens["Screens/*.jsx"]:::client
            Hooks["warmUpBrowser.tsx"]:::client
            Assets["assets/"]:::client
            TailwindCfg["tailwind.config.js"]:::client
            FirebaseCfg["firebaseConfig.js"]:::client
        end
        MobileApp --> AppJs
        MobileApp --> TabNav
        MobileApp --> Screens
        MobileApp --> Hooks
        MobileApp --> Assets
        MobileApp --> TailwindCfg
        MobileApp --> FirebaseCfg
    end

    %% Backend Side
    subgraph "Backend"
        direction TB
        subgraph "API Server (Fiber HTTP)" 
            direction TB
            APIConfig["Configuration\n(env_config, oauth_config,\nsecrets_config)"]:::server
            HTTPServer["Fiber HTTP Server"]:::server
            Middleware["auth_middleware.go"]:::server
            Controllers["Controllers"]:::server
            Services["Services"]:::server
            Repos["Repositories"]:::server
            Models["Models"]:::server
            Errors["Error Types"]:::server

            APIConfig --> HTTPServer
            HTTPServer --> Middleware
            Middleware --> Controllers
            Controllers --> Services
            Services --> Repos
            Repos --> Models
            Controllers --> Errors
        end

        subgraph "DB Adapters & Init"
            direction TB
            MongoAdapter["mongodb.go"]:::server
            FirebaseAdapter["firebase_auth.go"]:::server
            DBInit["database.go"]:::server
            DBInit --> MongoAdapter
            DBInit --> FirebaseAdapter
        end

        HTTPServer -->|Validate Token| FirebaseAuth
        HTTPServer -->|CRUD operations| MongoDB
    end

    %% Infrastructure
    MongoDB["MongoDB\n(via docker-compose.yml)"]:::infra

    %% Client to Backend interactions
    MobileApp -->|"API Requests\n(JSON + Bearer Token)"| HTTPServer
    FirebaseAuth -->|"ID Token / OTP"| MobileApp

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,color:#004085;
    classDef server fill:#d4edda,stroke:#155724,color:#155724;
    classDef external fill:#fff3cd,stroke:#856404,color:#856404;
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#6c757d;

    %% Click Events - Client
    click ExpoMetro "https://github.com/l-quincy01/student-hub-app/tree/main/.expo/"
    click MobileApp "https://github.com/l-quincy01/student-hub-app/tree/main/client/"
    click AppJs "https://github.com/l-quincy01/student-hub-app/blob/main/client/App.js"
    click TabNav "https://github.com/l-quincy01/student-hub-app/blob/main/client/Apps/Navigations/TabNavigation.js"
    click Screens "https://github.com/l-quincy01/student-hub-app/tree/main/client/Apps/Screens/"
    click Hooks "https://github.com/l-quincy01/student-hub-app/blob/main/client/hooks/warmUpBrowser.tsx"
    click Assets "https://github.com/l-quincy01/student-hub-app/tree/main/client/assets/"
    click TailwindCfg "https://github.com/l-quincy01/student-hub-app/blob/main/client/tailwind.config.js"
    click FirebaseCfg "https://github.com/l-quincy01/student-hub-app/blob/main/client/firebaseConfig.js"

    %% Click Events - Backend
    click HTTPServer "https://github.com/l-quincy01/student-hub-app/blob/main/api/cmd/student-hub-api/main.go"
    click APIConfig "https://github.com/l-quincy01/student-hub-app/blob/main/api/config/env_config.go"
    click APIConfig "https://github.com/l-quincy01/student-hub-app/blob/main/api/config/oauth_config.go"
    click APIConfig "https://github.com/l-quincy01/student-hub-app/blob/main/api/config/secrets_config.go"
    click MongoAdapter "https://github.com/l-quincy01/student-hub-app/blob/main/api/db/mongodb.go"
    click FirebaseAdapter "https://github.com/l-quincy01/student-hub-app/blob/main/api/db/firebase_auth.go"
    click DBInit "https://github.com/l-quincy01/student-hub-app/blob/main/api/db/database.go"
    click Controllers "https://github.com/l-quincy01/student-hub-app/tree/main/api/internal/controller/"
    click Services "https://github.com/l-quincy01/student-hub-app/tree/main/api/internal/service/"
    click Repos "https://github.com/l-quincy01/student-hub-app/tree/main/api/internal/repository/"
    click Models "https://github.com/l-quincy01/student-hub-app/tree/main/api/internal/model/"
    click Middleware "https://github.com/l-quincy01/student-hub-app/blob/main/api/internal/middleware/auth_middleware.go"
    click Errors "https://github.com/l-quincy01/student-hub-app/blob/main/api/internal/errors/types.go"
    click MongoDB "https://github.com/l-quincy01/student-hub-app/blob/main/api/docker-compose.yml"
```
