-
Notifications
You must be signed in to change notification settings - Fork 15
docs: improve setup documentation and add .env.sample template #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
06d4b2e
b5e091b
9baf352
2971434
6cbbdb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Alpha One Labs Education Platform - Environment Variables Template | ||
| # Copy this file to `.dev.vars` for local development. | ||
| # Do not commit real secrets to version control. | ||
|
|
||
| # ======================================== | ||
| # Encryption | ||
| # ======================================== | ||
| # Used to encrypt user PII (Personal Identifiable Information) and activity data | ||
| # before storing it in the database. Ensure this is a strong randomly generated string. | ||
| ENCRYPTION_KEY=your-dev-encryption-key-here | ||
|
|
||
| # ======================================== | ||
| # Authentication | ||
| # ======================================== | ||
| # Used to sign JSON Web Tokens (JWT) for stateless user authentication. | ||
| # Keep this secret to prevent unauthorized token forging. | ||
| JWT_SECRET=your-dev-jwt-secret-here |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,102 +14,113 @@ Alpha One Labs is an education platform designed to facilitate both learning and | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Prerequisites | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Make sure you have installed: | ||||||||||||||||||||||||||||||||||||||||||||||
| - Node.js | ||||||||||||||||||||||||||||||||||||||||||||||
| - Wrangler CLI | ||||||||||||||||||||||||||||||||||||||||||||||
| Before starting, ensure you have the following installed: | ||||||||||||||||||||||||||||||||||||||||||||||
| - **Node.js**: v18.0.0 or higher | ||||||||||||||||||||||||||||||||||||||||||||||
| - **npm**: v9.0.0 or higher | ||||||||||||||||||||||||||||||||||||||||||||||
| - **Wrangler CLI**: For deploying Cloudflare Workers | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Install Wrangler: | ||||||||||||||||||||||||||||||||||||||||||||||
| Install Wrangler globally using npm: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| npm install -g wrangler | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Clone the Repository | ||||||||||||||||||||||||||||||||||||||||||||||
| ### Fork & Clone the Repository (For Contributors) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| If you are a contributor, first fork the repository to your own GitHub account. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| git clone https://github.com/alphaonelabs/learn.git | ||||||||||||||||||||||||||||||||||||||||||||||
| # Clone your fork (replace <your-username> with your actual username) | ||||||||||||||||||||||||||||||||||||||||||||||
| git clone https://github.com/<your-username>/learn.git | ||||||||||||||||||||||||||||||||||||||||||||||
| cd learn | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Add the original repository as an upstream remote | ||||||||||||||||||||||||||||||||||||||||||||||
| git remote add upstream https://github.com/alphaonelabs/learn.git | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Login to Cloudflare (One time) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Authenticate the Wrangler CLI with your Cloudflare account. This will open a browser window to complete the login process safely. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler login | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Setup Database (D1) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - Create Database: | ||||||||||||||||||||||||||||||||||||||||||||||
| Follow these step-by-step instructions to set up your Cloudflare D1 database: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| 1. **Create the Database:** | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler d1 create education_db | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - Add the generated database_id to your wrangler.toml: | ||||||||||||||||||||||||||||||||||||||||||||||
| 2. **Add configuration to `wrangler.toml`:** | ||||||||||||||||||||||||||||||||||||||||||||||
| After running the create command, copy the `database_id` from the output and update your `wrangler.toml` file with this placeholder: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```toml | ||||||||||||||||||||||||||||||||||||||||||||||
| [[d1_databases]] | ||||||||||||||||||||||||||||||||||||||||||||||
| binding = "DB" | ||||||||||||||||||||||||||||||||||||||||||||||
| database_name = "education_db" | ||||||||||||||||||||||||||||||||||||||||||||||
| database_id = "YOUR_DATABASE_ID" | ||||||||||||||||||||||||||||||||||||||||||||||
| database_id = "<YOUR_DATABASE_ID>" | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+59
to
67
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - Apply Schema: | ||||||||||||||||||||||||||||||||||||||||||||||
| 3. **Apply the Schema:** | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix ordered-list numbering to satisfy markdownlint (MD029). This repo’s lint rule expects Lint-safe numbering-2. **Add configuration to `wrangler.toml`:**
+1. **Add configuration to `wrangler.toml`:**
@@
-3. **Apply the Schema:**
+1. **Apply the Schema:**📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 59-59: Ordered list item prefix (MD029, ol-prefix) [warning] 69-69: Ordered list item prefix (MD029, ol-prefix) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| Run the following to set up your database tables (for local development): | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler d1 execute education_db --file=schema.sql | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler d1 execute education_db --local --file=schema.sql | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Setup Environment Variables | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| This project requires environment variables for encryption and authentication. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - For Local Development | ||||||||||||||||||||||||||||||||||||||||||||||
| #### For Local Development | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Create a `.dev.vars` file in the project root: | ||||||||||||||||||||||||||||||||||||||||||||||
| Create a `.dev.vars` file in the root of the project to store local secrets. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
| ENCRYPTION_KEY=your-dev-encryption-key | ||||||||||||||||||||||||||||||||||||||||||||||
| JWT_SECRET=your-dev-jwt-secret | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
Comment on lines
84
to
87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a language to fenced code blocks (MD040). The fence should include a language tag for lint compliance. Minimal fix-```
+```env
ENCRYPTION_KEY=your-dev-encryption-key
JWT_SECRET=your-dev-jwt-secret🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 84-84: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - For Production | ||||||||||||||||||||||||||||||||||||||||||||||
| Use Wrangler secrets: | ||||||||||||||||||||||||||||||||||||||||||||||
| #### For Production | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Use the Wrangler CLI to set secrets securely for your deployed worker: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler secret put ENCRYPTION_KEY | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler secret put JWT_SECRET | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Running the Application | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Run Backend | ||||||||||||||||||||||||||||||||||||||||||||||
| The application consists of a backend worker and frontend HTML files. Run them concurrently in separate instructions. | ||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
A1L13N marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler dev | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
| #### Run Backend | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Backend server starts at: | ||||||||||||||||||||||||||||||||||||||||||||||
| Start the Cloudflare Worker locally: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| http://127.0.0.1:8787 | ||||||||||||||||||||||||||||||||||||||||||||||
| wrangler dev | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ### Run Frontend | ||||||||||||||||||||||||||||||||||||||||||||||
| The backend server usually starts at: `http://127.0.0.1:8787` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - Open directly | ||||||||||||||||||||||||||||||||||||||||||||||
| #### Run Frontend | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| public/index.html | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - Use a local server | ||||||||||||||||||||||||||||||||||||||||||||||
| Serve the static files using a local development server (like `serve`): | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| npx serve public | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Frontend Server will start at: | ||||||||||||||||||||||||||||||||||||||||||||||
| The frontend server usually starts at: `http://localhost:3000` | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||||||
| http://localhost:3000 | ||||||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||||||
| ### Common Errors | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - **`wrangler: command not found`**: Ensure that npm's global bin directory is in your system's PATH. | ||||||||||||||||||||||||||||||||||||||||||||||
| - **`D1_ERROR` when running backend**: Check that you have replaced `<YOUR_DATABASE_ID>` with your actual database ID inside `wrangler.toml`. | ||||||||||||||||||||||||||||||||||||||||||||||
| - **CORS Errors**: If the frontend cannot communicate with the backend, ensure your backend is running (`wrangler dev`) and check the console. Ensure you are accessing the frontend via a local server (e.g., `http://localhost:3000`) rather than a `file://` URL. | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a trailing newline at end of file (MD047). README should end with exactly one newline to pass lint. 🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 126-126: Files should end with a single newline character (MD047, single-trailing-newline) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.