# khalidoukoujane/startup_planet architecture

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

- Interactive diagram: https://gitdiagram.com/khalidoukoujane/startup_planet
- Repository: https://github.com/khalidoukoujane/startup_planet

## Overview

##### Project Type & Purpose
- This is a backend-only RESTful API service (“Startup Planet API”) built with Node.js and Express.js.
- It serves startup data from an in-memory data store (`data.js`) and exposes two main endpoints:
- GET /api (with optional query filters)
- GET /api/:field/:term

##### File Structure Analysis
- server.js: Entry point, sets up Express app, CORS, middleware, and mounts routes.
- routes/apiRoutes.js: Defines the HTTP endpoints and ties them to controller functions.
- controllers/getAllData.js & controllers/getDataByPathParams.js: Contain the logic to retrieve and filter startup data.
- data.js: A JavaScript module exporting the array of startup objects (acts as the data store).
- package.json / package-lock.json: Dependency and script definitions.

##### Key Architectural Patterns
- Layered Architecture:
1. Presentation Layer (HTTP Server + CORS)
2. Routing Layer (apiRoutes)
3. Controller Layer (business logic: filtering/search)
4. Data Layer (data.js as the in-memory datastore)
- No external database: data.js is the primary data source.

##### Main Components
a. Client (e.g., browser, curl, Postman)
b. Express Server
c. Middleware (CORS, JSON parsing)
d. Router Module (`apiRoutes.js`)
e. Controller Module (two controllers)
f. Data Module (`data.js`)

##### Relationships & Data Flow
1. Client issues HTTP request →
2. Express Server (middleware) →
3. Router matches endpoint →
4. Controller executes business logic →
5. Controller reads/filters `data.js` →
6. Controller returns JSON response →
7. Express Server sends response back to Client

##### Technologies & Frameworks
- Node.js (runtime)
- Express.js v5 (web framework)
- ES Modules (import/export)
- CORS (cross-origin support)

##### Essential Details to Capture
- Middleware ordering (e.g., CORS first, JSON parser next).
- Route definitions and path patterns (`/api`, `/api/:field/:term`).
- Controller responsibilities: filtering vs. path-parameter search.
- The in-memory nature of the data store.
- Startup attributes (industry, country, funding flags).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        Client["Client (Postman / Browser / curl)"]:::client
    end

    subgraph "Presentation Layer"
        Server["Express Server (server.js)"]:::server
        Middleware_CORS["CORS Middleware"]:::server
        Middleware_JSON["JSON Parser Middleware"]:::server
    end

    subgraph "Routing Layer"
        Router["API Router (routes/apiRoutes.js)"]:::router
    end

    subgraph "Controller Layer"
        GetAll["GetAllData Controller (controllers/getAllData.js)"]:::controller
        GetByPath["GetDataByPathParams Controller (controllers/getDataByPathParams.js)"]:::controller
    end

    subgraph "Data Layer"
        DataStore["In-Memory Data Store (data.js)"]:::data
    end

    Client -->|"HTTP Request"| Server
    Server --> Middleware_CORS --> Middleware_JSON --> Router
    Router -->|"GET /api"| GetAll
    Router -->|"GET /api/:field/:term"| GetByPath
    GetAll --> DataStore
    GetByPath --> DataStore
    GetAll -->|"JSON Response"| Server
    GetByPath -->|"JSON Response"| Server
    Server -->|"HTTP Response"| Client

    click Server "https://github.com/khalidoukoujane/startup_planet/blob/main/server.js"
    click Middleware_CORS "https://github.com/khalidoukoujane/startup_planet/blob/main/server.js"
    click Middleware_JSON "https://github.com/khalidoukoujane/startup_planet/blob/main/server.js"
    click Router "https://github.com/khalidoukoujane/startup_planet/blob/main/routes/apiRoutes.js"
    click GetAll "https://github.com/khalidoukoujane/startup_planet/blob/main/controllers/getAllData.js"
    click GetByPath "https://github.com/khalidoukoujane/startup_planet/blob/main/controllers/getDataByPathParams.js"
    click DataStore "https://github.com/khalidoukoujane/startup_planet/blob/main/data.js"

    classDef client fill:#cccccc,stroke:#333,stroke-width:1px
    classDef server fill:#b7eb8f,stroke:#333,stroke-width:1px
    classDef router fill:#ffd591,stroke:#333,stroke-width:1px
    classDef controller fill:#91d5ff,stroke:#333,stroke-width:1px
    classDef data fill:#d3adf7,stroke:#333,stroke-width:1px
```
