mdstream is a sample project consisting of a React (Vite) + TypeScript frontend and a Serverless Framework (Node.js) backend. It uses AWS S3 to store Markdown files and fetches them via HTTP APIs for listing and detail views in the web application.
-
Frontend:
- Located under the
frontend/directory, built with Vite + React + TypeScript. - Displays a list of Markdown files and their contents.
- Also demonstrates how to load local markdown (e.g.,
terms.mdandprivacy.md) in the/public/markdown/folder and render it with React.
- Located under the
-
Backend:
- Located under the
backend/directory, built with the Serverless Framework on Node.js. - Fetches Markdown files from an S3 bucket and serves them via an HTTP API.
- The environment variables (
BUCKET_NAME,ALLOWED_REFERER, etc.) control where the Markdown files are stored and which referers are allowed.
- Located under the
-
License:
- This project is published under GNU General Public License (GPL) v3.
- See the
LICENSEfile for more details.
mdstream/
├─ frontend/ # React + Vite project
│ ├─ public/markdown # Markdown files
│ ├─ src/ # Source code (components, services, etc.)
│ ├─ package.json
│ ├─ vite.config.ts
│ └─ ...other configs
├─ backend/ # Serverless Framework (Node.js) project
│ ├─ src/
│ ├─ serverless.yml
│ └─ package.json
├─ LICENSE
└─ README.md (or README.ja.md for Japanese)git clone https://github.com/yourname/mdstream.git
cd mdstreamcd frontend
npm install- Local Development (connecting to a local API):
npm run dev:local
- By default, the local dev server runs at http://localhost:5173.
- It will load environment variables from
.env.dev(or any.env.*specified).
- Build
npm run build:dev # or npm run build:prod- The build output goes to
frontend/dist/.
- The build output goes to
cd ../backend
npm install- Local Development (serverless-offline):
npm run dev:local
- This will read environment variables such as
BUCKET_NAMEandALLOWED_REFERERfrom.env.devor similar. - The local serverless-offline endpoint (e.g., http://localhost:3000) will serve the API (depending on your
serverless.ymlconfig).
- This will read environment variables such as
- Deploy to AWS Example:
npm run deploy:dev
- Requires your AWS credentials to be configured.
- Deploys the backend as AWS Lambda functions.
- Local (frontend-based):
- Simply place new
.mdfiles underfrontend/public/markdown/. - Import or fetch them in your React components (like
PrivacyPage.tsxorTermsPage.tsx).
- Simply place new
- Backend (S3-based):
- Upload your
.mdfiles to the appropriate S3 bucket. - Update environment variables (
S3_PREFIX, etc.) to point to the correct location. - The
fetchMarkdownListandfetchMarkdownDetailfunctions infrontend/src/services/api.tscall the API endpoints that read from S3.
- Upload your
- Styling:
- Edit SCSS/CSS files in
frontend/src/styles/to change the UI appearance.
- Edit SCSS/CSS files in
- Add Components:
- Create new React components in
frontend/src/components/, and add corresponding routes inApp.tsxas needed.
- Create new React components in
- API Changes:
- Modify logic in
backend/src/handler.tsor theserverless.ymlfile to adjust endpoints, environment variables, AWS settings, etc.
- Modify logic in
- Dependencies:
- Update
frontend/package.jsonorbackend/package.jsonfor any additional libraries. - Run
npm installto install new dependencies.
- Update
- Please open an Issue for bugs or feature requests.
- Pull requests are welcome. For major changes, consider discussing them in an Issue first.
- Released under the GNU GPL v3 license.
- Refer to LICENSE for details.
- For questions or issues, please open an Issue or email info@itc.tokyo.