> For the complete documentation index, see [llms.txt](https://hackathon-crew.gitbook.io/welcome-overview/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hackathon-crew.gitbook.io/welcome-overview/architecture/system-architecture.md).

# System Architecture

### Tech Stack

#### Frontend

* **React** - UI framework
* **Vite** - Build tool
* **Leaflet** - Interactive maps
* **Tailwind CSS** - Styling
* **Axios** - HTTP requests

#### Backend

* **Node.js** - Runtime
* **Express** - Web framework
* **Firestore** - Database
* **ES6 Modules** - Modern JavaScript

#### APIs & Services

* **Google Gemini** - AI chatbot
* **Wolfram Alpha** - Historical data
* **Netlify** - Frontend hosting
* **Render** - Backend hosting

***

#### System Diagram:

{% stepper %}
{% step %}

### U**ser Browser (React)**

{% endstep %}

{% step %}

### Leaflet Map + UI Components

{% endstep %}

{% step %}

### API Layer (Axios)

{% endstep %}

{% step %}

### Express Backend (Node.js)

{% endstep %}
{% endstepper %}

* Firestore (user data, progress)
* Google Gemini API (AI responses)
* Wolfram Alpha (Historical context)

#### &#x20;***Data Flow:***

**User Journey: Visited Musuem**

1. User clicks museum marker on map
2. Frontend routes to ***'/museum/:id'***
3. Frontend calls ***'POST/api/passport/stamp'***
4. Backend saves VISITED stamp to Firestore
5. User sees confetti + "+10 XP" notification

**User Journey: Take Quiz**&#x20;

1. User clicks "Takes Quiz" on museums page&#x20;
2. Frontend loadds questions from local data
3. User submits answers&#x20;
4. Frontend calculates score&#x20;
5. If =>80%, frontend calls ***'POST /api/passport/quiz'***
6. Backend awards QUIZ\_PASSED stamp + 25 XP
7. User levels up if XP threshold crossed

***U*****ser Journey: View Leaderboard**

1. User navigates to *'**/leaderboard'***
2. Frontend calls ***'GET/api/leaderboard'***
3. Backend queries Firestore for top 10 users by XP
4. Frontend displays ranked table


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hackathon-crew.gitbook.io/welcome-overview/architecture/system-architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
