# ozescu/parkingappres architecture

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

- Interactive diagram: https://gitdiagram.com/ozescu/parkingappres
- Repository: https://github.com/ozescu/parkingappres

## Overview

##### Project type and purpose
- Full-stack mobile application (“Smart Parking”) for reserving parking spots.
- Frontend: React Native (Expo) targeting Android & iOS.
- Backend:
– Primary REST API in Express (Node.js) for CRUD (listing spots, booking, cancelling).
– Secondary micro-service in Flask (Python) exposing `/api/predict` for ML-based occupancy predictions.
- Storage: persistent database (e.g., MongoDB/PostgreSQL) behind Express (not shown in code but implied).
- ML model: `parking.pkl` loaded by Flask micro-service.

##### File structure
- Top-level:
– android/, ios/: native project scaffolding generated by Expo/React Native.
– expo/: Expo runtime metadata.
– backend/: contains both `server.js` (Express) and `app.py` (Flask).
– screens/: React Native view components (.js files).
– assets/: static images/fonts.
– App.js / index.js: RN entry points.
– config.js: client-side endpoints/configs.
- Backend details:
– server.js: Express entry point; routes/controllers/models under its folder.
– app.py + preprocess.py + model/parking.pkl: Python service.
- No direct DB folder, but Express controllers/models likely connect to a database.

##### Key README insights
- Tech stack described above.
- Lists API endpoints for both services.
- Clarifies authentication & notification duties may go to Flask as well.

##### Main components & their relationships
a. Mobile Client
– React Native layers:
- JavaScript app (App.js, screens/*)
- Expo runtime
- Native Android & iOS hosts
b. Network/Internet
c. Backend-express (Node.js)
– Exposes REST endpoints:
- GET /api/parking/spots
- POST /api/parking/reserve
- DELETE /api/parking/free
– Interacts with persistent Database
d. Backend-flask (Python)
– Exposes ML endpoint: POST /api/predict
– Loads `parking.pkl`, runs `preprocess.py`
e. Database (MongoDB / PostgreSQL)
– Stores users, reservations, parking-spot metadata
f. (Optional) External services
– Authentication provider, push notifications, map APIs

Relationships:
- RN client ⟷ Express API ⟷ Database
- RN client ⟷ Flask service ⟷ ML model
- (Express or RN) ⟷ external services

##### Architectural patterns & design principles
- Mobile app/client-server architecture
- Microservices style in backend: separate REST API and ML service
- Separation of concerns: UI, business logic (Node), ML logic (Python)
- Potential MVC or similar in Express (routes/controllers/models)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client
    subgraph "Mobile Client" 
        subgraph "JavaScript Layer"
            AppJS["App.js"]:::file
            IndexJS["index.js"]:::file
            ConfigJS["config.js"]:::file
            ScreensDir["screens/"]:::dir
            AssetsDir["assets/"]:::dir
            ExpoDir["expo/"]:::dir
        end
        subgraph "Native Hosts"
            Android["Android"]:::compute
            iOS["iOS"]:::compute
        end
    end

    %% Server Side
    subgraph "Server"
        Express["Express REST API<br/>(Node.js + Express)"]:::compute
        Flask["Flask ML Service<br/>(Python + Flask)"]:::compute
        Model["parking.pkl"]:::model
        DB[(Database)]:::database
    end

    %% External
    Internet["Internet"]:::cloud
    ExtServ["External Services<br/>(Auth, Notifications, Maps)"]:::external

    %% Data Flows
    AppJS -->|uses| Internet
    IndexJS -->|uses| Internet
    ConfigJS -->|reads config from| Internet
    ScreensDir -->|renders UI via| Internet
    ExpoDir -->|runs on| Android
    ExpoDir -->|runs on| iOS

    Internet -->|requests| Express
    Internet -->|requests| Flask
    Express -->|reads/writes| DB
    Flask -->|loads| Model
    Express -->|integrates with| ExtServ
    Android -->|hosts app| AppJS
    iOS -->|hosts app| AppJS

    %% Click Events
    click AppJS "https://github.com/ozescu/parkingappres/blob/main/App.js"
    click IndexJS "https://github.com/ozescu/parkingappres/blob/main/index.js"
    click ConfigJS "https://github.com/ozescu/parkingappres/blob/main/config.js"
    click ScreensDir "https://github.com/ozescu/parkingappres/tree/main/screens/"
    click AssetsDir "https://github.com/ozescu/parkingappres/tree/main/assets/"
    click ExpoDir "https://github.com/ozescu/parkingappres/tree/main/expo/"
    click Android "https://github.com/ozescu/parkingappres/tree/main/android/"
    click iOS "https://github.com/ozescu/parkingappres/tree/main/ios/"
    click Express "https://github.com/ozescu/parkingappres/blob/main/backend/server.js"
    click Flask "https://github.com/ozescu/parkingappres/blob/main/backend/app.py"
    click Model "https://github.com/ozescu/parkingappres/blob/main/backend/model/parking.pkl"

    %% Styles
    classDef compute fill:#87CEFA,stroke:#000,stroke-width:1px
    classDef database fill:#FFA500,stroke:#000,stroke-width:1px
    classDef model fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef cloud fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef external fill:#98FB98,stroke:#000,stroke-width:1px
    classDef file fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef dir fill:#ADD8E6,stroke:#000,stroke-width:1px
```
