# Project export: Lost and Slugged

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: CruzHacks 2024
- Tagline: Easily log your lost items while discovering a community-driven map showcasing both lost and found items across campus. Don't fret, you have your fellow slugs to rely on!.
- Devpost: https://devpost.com/software/lost-and-slugged
- GitHub: https://github.com/crystalpop/LostandSlugged.git
- Video: https://www.youtube.com/embed/FasX_sd4g4s?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 3 GitHub contributor(s) — sophiabtran (25 commits), Tommy Chen (24 commits), Crystal Popeney (20 commits)

## Devpost submission (written by the team)

### Inspiration

As students, we know how frustrating it can be to lose a personal item on campus, remember exactly where we left it, return to that same place and it has suddenly disappeared. On the other hand, it can also be stressful to find an item that's been left behind, and not know who to return it to. With Lost and Slugged, we wanted to build a community driven solution to this issue.

### What it does

"Lost and Slugged" features an interactive map displaying pins indicating where items have been lost on campus. Students can easily log their lost items, mark the locations on the map, and search existing pins to locate their belongings. Additionally, students can log items they find, leaving contact information for owners to reclaim their possessions.

### How we built it

For the frontend, we used React. For login authentication we used Firebase, not allowing users to log lost/found items until they sign in to an account. Firestore stored data such as lost item coordinates, names, and contact information. The map functionality was implemented using the Leaflet library.

### Challenges we ran into

We faced challenges when it came to handling our Git repository, and had difficulty keeping all of our local repos up to date, while coordinating the remote repository to maintain the most recent useful changes. Additionally, all members of our team were not very experienced with React, so creating a web app that requires so many components and state hooks proved to be a struggle.

### Accomplishments we're proud of

We are proud of learning how to use the leaflet library for the first time, and being able to blend it with the other parts of the tech stack, a new framework for all of our first time working with maps. We also appreciate that our frontend team member was able to create a UI so similar to our original design, and what we wanted it to look like. We were also to implement all of the base functions that we wanted, such as logging and displaying pins on the map, and showing cards that contain previews of the existing entries.

### What we learned

The project provided valuable learning experiences, particularly in utilizing Firebase for authentication and database systems and integrating them with our React application. We also learned that it is important to prioritize our base requirements, before allocating more time to perfecting aspects such as aesthetic. Another important learning milestone that occurred is that we were able to more efficiently and neatly send and retrieve data from our database that previous attempts, due to the more well-ordered organization and formatting of our data.

### What's next

There are a few more levels of functionality that we would like to implement eventually, such as being able to search and filter for items, which would be helpful. We also think it would be interesting to work with UCSC PD to establish official records of lost items. This step aims to enhance the reliability and credibility of our platform in reuniting students with their belongings. With these next steps, "Lost and Slugged" is could evolve into a more comprehensive and collaborative resource for the university community.

## README (from the GitHub repository)

# VIDEO DEMO

![Demo](https://gist.github.com/YOUR_USERNAME/caa865cbd274a186d8881de666cf09f9.js)


# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)


### INSTALLATION REQUIREMENTS

```
npm i firebase
npm i react-router-dom
npm i react-bootstrap
npm i react-leaflet
npm i react-scroll
npm install
```


## Detected evidence (automated analysis)

Indexed codebase: 19 recognized source files, 33 KB.
- CSS (language) — detected in the code
- Firebase (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- React (technology) — detected in the code

## Codebase structure (from repository index)

### Files (21 of 21)

```
frontend/.gitignore
frontend/package.json
frontend/public/index.html
frontend/README.md
frontend/src/Add_Items/Add_items.js
frontend/src/Add_Items/card_info.js
frontend/src/App.css
frontend/src/App.js
frontend/src/Authentication/firebase.js
frontend/src/contexts/AuthContext.js
frontend/src/database/Add_items.js
frontend/src/index.css
frontend/src/index.js
frontend/src/Login.js
frontend/src/main.css
frontend/src/Main.jsx
frontend/src/pages/generate_cards.js
frontend/src/pages/map.js
frontend/src/Signup.js
frontend/src/styles/map.css
README.md
```

### Dependencies

- frontend/package.json: @testing-library/jest-dom@^5.17.0, @testing-library/react@^13.4.0, @testing-library/user-event@^13.5.0, bootstrap@^5.3.2, firebase@^10.7.2, leaflet@^1.9.4, react@^18.2.0, react-bootstrap@^2.10.0, react-dom@^18.2.0, react-hook-form@^7.49.3, react-leaflet@^4.2.1, react-leaflet-cluster@^2.1.0, react-router-dom@^6.21.3, react-scripts@5.0.1, react-scroll@^1.9.0, react-text@^3.2.5, swiper@^11.0.5, web-vitals@^2.1.4

### Recent commits (newest first)

- Update README.md
- Update README.md
- Update README.md
- Update README.md
- Update README.md
- Update README.md
- Added demo vid
- Update README.md
- Merge branch 'main' of https://github.com/crystalpop/cruzhacksyuh
- Delete CNAME
- sorting by date
- Update CNAME
- Create CNAME
- updated styling
- added popup and fixeed title and logo
- ahh
- card fixed and can add cards
- msg
- reload page
- ahhhhhh

## Key source files (fetched from GitHub, selected and truncated for size)

### frontend/package.json

```
{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "bootstrap": "^5.3.2",
    "firebase": "^10.7.2",
    "leaflet": "^1.9.4",
    "react": "^18.2.0",
    "react-bootstrap": "^2.10.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.49.3",
    "react-leaflet": "^4.2.1",
    "react-leaflet-cluster": "^2.1.0",
    "react-router-dom": "^6.21.3",
    "react-scripts": "5.0.1",
    "react-scroll": "^1.9.0",
    "react-text": "^3.2.5",
    "swiper": "^11.0.5",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

```

### frontend/src/index.js

```javascript
import React from 'react';
import ReactDOM from 'react-dom/client';
import Main from './Main.jsx';
import App from './App.js';
import './index.css'
import { AuthProvider, useAuth } from './contexts/AuthContext.js';
import 'bootstrap/dist/css/bootstrap.min.css';



const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <AuthProvider>
    <Main />
    </AuthProvider>
  </React.StrictMode>
);

```

### frontend/src/Main.jsx

```javascript
import { useState } from 'react'
import { Route, Routes, Navigate, BrowserRouter } from "react-router-dom"
import App from './App.js'
import { ThemeProvider } from 'react-bootstrap'
import './main.css'
import Login from './Login.js'
import Signup from './Signup.js'
import Map from './pages/map.js'

function Main() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path='/' element={<App />} />
        <Route path='/login' element={<Login />} />
        <Route path='/signup' element={<Signup />} />
        <Route path='/map' element={<Map />} />
      </Routes>
      </BrowserRouter>
  );
}

export default Main;
```

### frontend/src/App.js

```javascript
import React from 'react';
import {NavLink, useNavigate} from 'react-router-dom';
import './App.css';
import background from "./assets/homepage_background.png";
import logo from "./assets/logo.png";

function App() {
  const navigate = useNavigate();
  return (
    <div style ={{ backgroundImage: `url(${background})`,
                   backgroundPosition: 'center',
                   backgroundSize: 'cover',
                   backgroundRepeat: 'no-repeat',
                   width: '100vw',
                   height: '100vh'
                }}>
    <div className='homepage-container'>
      <div className='title'>
        <img className='home-logo' src={logo} width={200} height={200} ></img>
      <h1 className='slug'>Lost and Slugged</h1>
      </div>
    <p className='welcome-text'>Welcome! We are a team of UC undergraduates interested in 
      helping others find items that they have lost or found around 
      the UCSC campus.
    </p>
    <p className='welcome-text'>Sign in below to start looking!</p>
    <div className='login-signup'>
    <button className='login-button' onClick={()=> navigate('./login')}>Login</button>
    <button className='signup-button' onClick={()=> navigate('./signup')}>Sign up</button>
    </div>
    </div>
    </div>
  );
}

export default App;

```

### frontend/src/main.css

```css
.koulen-regular {
    font-family: "Koulen", sans-serif;
    font-weight: 400;
    font-style: normal;
  }
  
```

### frontend/src/index.css

```css
.koulen-regular {
    font-family: "Koulen", sans-serif;
    font-weight: 400;
    font-style: normal;
  }

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

```

### frontend/public/index.html

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Koulen&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Mako&display=swap" rel="stylesheet">
    <link
    href="https://fonts.googleapis.com/css2?family=Kodchasan:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap"
    rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Kodchasan:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
    <title>Lost and Slugged</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

```

### frontend/src/App.css

```css
h1 {
    font-family: 'Koulen';
    font-weight: 400;
    font-size: 500%;
    -webkit-text-fill-color: white;

}

.homepage-container {
    display:flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
}

.title {
    margin-top: 8%;
    filter:drop-shadow(0px 4px rgba(3, 3, 3, 0.207));
}
.slug {
    margin-top: 4%;
}
.welcome-text {
    font-family: 'Mako';
    margin-left: 20%;
    margin-right: 20%;
    -webkit-text-fill-color: white;
    font-size: 200%;
    filter: drop-shadow(2px 2px rgba(0, 0, 0, 0.3));
}

.home-logo {
    margin-left: 20%;
}

.login-signup {
    margin-top: 2%;
    margin-left: 80%;
    margin-right: 100%;
    display:flex;
    flex-direction: row;
    border-radius: 12px;
}

.login-button {
    font-family: 'Kanit';
    font-size: 200%;
    height: fit-content;
    padding: 5%;
    margin-left: 90%;
    border-radius: 12px;
    -webkit-text-fill-color: #3C98D7;
    border-color: white;

}

.signup-button {
    font-family: 'Kanit';
    font-size: 200%;
    width:max-content;
    height: min-content;
    padding: 5%;
    margin-left: 10%;
    margin-right: -500%;
    border-radius: 12px;
    -webkit-text-fill-color: #3C98D7;
    border-color: white;

}
```

### frontend/src/Login.js

```javascript
import React, {useRef, useState} from 'react'
import {Button, Form, Card, Alert} from 'react-bootstrap'
import { useAuth } from './contexts/AuthContext'
import {Link, useNavigate} from 'react-router-dom'
import background from "./assets/homepage_background.png";


export default function Login() {

  const emailRef = useRef()
  const passwordRef = useRef()

  const { login } = useAuth()
  const [error, setError] = useState('')
  const [loading, setLoading] = useState(false)
  const navigate = useNavigate()

  async function handleSubmit(e){
    //console.log(error)
    //prevent refresh
    e.preventDefault()

    // try to create account
    try{
        setError('')
        setLoading(true)
        await login(emailRef.current.value, passwordRef.current.value )
        navigate('../map')
        //alert('Login Successful')
    } catch {
        setError('Failed to login')
    }
    setLoading(false)
  }

  return (
    <div>
        
        <div style ={{ backgroundImage: `url(${background})`,
                    backgroundPosition: 'center',
                    backgroundSize: 'cover',
                    backgroundRepeat: 'no-repeat',
                    width: '100vw',
                    height: '100vh',
                    flexDirection: 'column',
                    display: 'flex',
                    justifyContent: 'center'

        }}>
        <h1 className='text-center mb-4'>Login</h1>
        <div className="d-flex align-items-center justify-content-center">
            <Card className='w-50'>
                <Card.Body>
                    
                    {error && <Alert variant="danger">{error}</Alert>}

                    <Form onSubmit={handleSubmit}>
                        <Form.Group id = 'email'>
                            <Form.Label>Email</Form.Label>
                            <Form.Control type = 'email' ref = {emailRef} required/>
                        </Form.Group>
                        <Form.Group id = 'password'>
                            <Form.Label>Password</Form.Label>
                            <Form.Control type = 'password' ref = {passwordRef} required/>
                        </Form.Group>
                        
                        <Button disabled={loading} className="w-100" type="submit" >
                            Login
                        </Button>
                    </Form>
                </Card.Body>
            </Card>
            </div>
            <div className='w-100 text-center mt-2'>
                Don't have an account?  <Link to = '/signup'>Sign Up</Link>
            </div>
            
        </div>
    </div>

  )
}
```

### frontend/src/Signup.js

```javascript
import React, {useRef, useState} from 'react'
import {Button, Form, Card, Alert} from 'react-bootstrap'
import { useAuth } from './contexts/AuthContext'
import {Link, useNavigate } from 'react-router-dom'
import background from "./assets/homepage_background.png";





export default function SignUp() {

  const emailRef = useRef()
  const passwordRef = useRef()
  const confirmPasswordRef = useRef()
  const { signup } = useAuth()
  const [error, setError] = useState('')
  const [loading, setLoading] = useState(false)
  const navigate = useNavigate()

  async function handleSubmit(e){
    //console.log(error)
    //prevent refresh
    e.preventDefault()

    // checks if passwords match
    if( passwordRef.current.value !== confirmPasswordRef.current.value){
        return setError('Passwords do not match')
    }

    // try to create account
    try{
        setError('')
        setLoading(true)
        await signup(emailRef.current.value, passwordRef.current.value )
        navigate("../map")
    } catch {
        setError('Failed to create an account')
    }
    setLoading(false)
  }

  return (
    <div>
        
        <div style ={{ backgroundImage: `url(${background})`,
                    backgroundPosition: 'center',
                    backgroundSize: 'cover',
                    backgroundRepeat: 'no-repeat',
                    width: '100vw',
                    height: '100vh',
                    flexDirection: 'column',
                    display: 'flex',
                    justifyContent: 'center'

        }}>
            
            <h1 className='text-center mb-4'>Sign Up</h1>
                

            <div className="d-flex align-items-center justify-content-center">
            
                
                <Card className = 'w-50'>
                    <Card.Body>
                        
                        {error && <Alert variant="danger">{error}</Alert>}

                        <Form onSubmit={handleSubmit}>
                            <Form.Group id = 'email'>
                                <Form.Label>Email</Form.Label>
                                <Form.Control type = 'email' ref = {emailRef} required/>
                            </Form.Group>
                            <Form.Group id = 'password'>
                                <Form.Label>Password</Form.Label>
                                <Form.Control type = 'password' ref = {passwordRef} required/>
                            </Form.Group>
                            <Form.Group id = 'confirm-password'>
                                <Form.Label>Confirm Password</Form.Label>
                                <Form.Control type = 'confirm-password' ref = {confirmPasswordRef} required/>
                            </Form.Group>
                            <Button disabled={loading} className="w-100" type="submit">
                                Sign Up
                            </Button>
                        </Form>
                    </Card.Body>
                </Card>
            </div>
                <div className='w-100 text-center mt-2'>
                    Already have an account?  <Link to = '/login'>Log in</Link>
                </div>
        </div>
    </div>
        
    

  )
}
```

[8 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]