Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,32 @@ The Starklings App is an interactive web platform designed to assist users in em

Our objective is to simplify the Starklings experience by eliminating complex configurations and installations. Simply access the app through your browser and begin coding.


## Components

### Backend

The backend of the Starklings App is responsible for handling data processing and interactions with the Starknet exercises.
Follow these steps to set up and run the backend:

#### Database Setup

If you're running the backend for the first time, you need to configure the database connection:

1. Create a new database named `starklings-test`. This example uses DBeaver to create a connection to PostgreSQL and then create the database.

<img width="805" alt="Screenshot 2025-04-25 at 12 14 54 PM" src="https://github.com/user-attachments/assets/c4161f4e-8102-47e2-bffc-a2b836192abc" />

2. Once the connection is established, create a new query and execute the [init.sql](./database/init.sql) file.

<img width="539" alt="Screenshot 2025-04-25 at 12 26 58 PM" src="https://github.com/user-attachments/assets/dacac140-2b0e-4c69-b243-a1fc3b9783ae" />

3. After the table is created, configure the [.env](./api/.env) file. You can copy the [.env.example](./api/.env.example) file and modify it with your own values.

<img width="306" alt="Screenshot 2025-04-25 at 12 37 42 PM" src="https://github.com/user-attachments/assets/77051a3a-1e4b-4bee-b9df-1a79a6681a48" />


#### Running the Backend

```bash
cd api/
```
Expand All @@ -36,6 +54,16 @@ Run the development server:
npm run dev
```

To test the database connection, you can use the ping endpoint:

```bash
curl http://localhost:3000/api/ping
```

You should see a response indicating that the connection is working properly.

<img width="402" alt="Screenshot 2025-04-25 at 12 38 49 PM" src="https://github.com/user-attachments/assets/77cfe6ea-6592-49f6-b1f8-283db83939ec" />

### Frontend

The frontend is the user interface of the Starklings App, providing an interactive environment for users to engage with Cairo exercises.
Expand Down
15 changes: 7 additions & 8 deletions app/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
PG_PORT=
PG_HOST=
PG_USER=
PG_PASSWORD=
PG_DATABASE=
PG_DATABASE_SSL=
# ORIGIN=
URL_GITHUB_STARKLINGS=
PG_PORT=5432
PG_HOST=localhost
PG_USER=postgres
PG_PASSWORD=postgres
PG_DATABASE=starklings-test
PG_DATABASE_SSL=false
ORIGIN=*
2 changes: 1 addition & 1 deletion app/database/init.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE Resolutions (
id SERIAL PRIMARY KEY,
user_name VARCHAR(255),
exercise_id VARCHAR(255) REFERENCES Exercises(id),
exercise_id VARCHAR(255),
resolution_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE (user_name, exercise_id)
);