diff --git a/app/README.md b/app/README.md index 4dfaf3f0b..356879377 100644 --- a/app/README.md +++ b/app/README.md @@ -12,7 +12,6 @@ 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 @@ -20,6 +19,25 @@ Our objective is to simplify the Starklings experience by eliminating complex co 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. + + Screenshot 2025-04-25 at 12 14 54 PM + +2. Once the connection is established, create a new query and execute the [init.sql](./database/init.sql) file. + + Screenshot 2025-04-25 at 12 26 58 PM + +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. + + Screenshot 2025-04-25 at 12 37 42 PM + + +#### Running the Backend + ```bash cd api/ ``` @@ -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. + +Screenshot 2025-04-25 at 12 38 49 PM + ### Frontend The frontend is the user interface of the Starklings App, providing an interactive environment for users to engage with Cairo exercises. diff --git a/app/api/.env.example b/app/api/.env.example index b2ef56217..0d5a21844 100644 --- a/app/api/.env.example +++ b/app/api/.env.example @@ -1,8 +1,7 @@ -PG_PORT= -PG_HOST= -PG_USER= -PG_PASSWORD= -PG_DATABASE= -PG_DATABASE_SSL= -# ORIGIN= -URL_GITHUB_STARKLINGS= \ No newline at end of file +PG_PORT=5432 +PG_HOST=localhost +PG_USER=postgres +PG_PASSWORD=postgres +PG_DATABASE=starklings-test +PG_DATABASE_SSL=false +ORIGIN=* diff --git a/app/database/init.sql b/app/database/init.sql index d51db70fc..2d795fee4 100644 --- a/app/database/init.sql +++ b/app/database/init.sql @@ -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) );