Skip to content

Commit 1ef279b

Browse files
VikasVikas
authored andcommitted
Add frontend with API proxy for Vercel deployment
1 parent cb584df commit 1ef279b

18 files changed

Lines changed: 1381 additions & 1 deletion

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ examples/test_*.txt
6565

6666
# Google Test build artifacts
6767
_deps/
68-
lib/
68+
/lib/
6969

7070
# Server dependencies
7171
server/node_modules/
7272
server/package-lock.json
73+
74+
# Frontend dependencies
75+
frontend/node_modules/
76+
frontend/.next/
77+
frontend/package-lock.json

frontend/.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ByteCode Compiler Frontend - Environment Variables
2+
# Copy this file to .env.local and update values
3+
4+
# API URL - Your Azure VM backend
5+
NEXT_PUBLIC_API_URL=http://57.159.30.64/api
6+
7+
# GitHub Repository URL
8+
NEXT_PUBLIC_GITHUB_URL=https://github.com/IsVohi/ByteCode-Compiler
9+
10+
# Your Portfolio URL (update this)
11+
NEXT_PUBLIC_PORTFOLIO_URL=https://yourportfolio.com

frontend/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
.next/
6+
out/
7+
8+
# Production
9+
build/
10+
11+
# Debug
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
16+
# Environment files
17+
.env
18+
.env.local
19+
.env.development.local
20+
.env.test.local
21+
.env.production.local
22+
23+
# Vercel
24+
.vercel
25+
26+
# IDE
27+
.idea/
28+
.vscode/
29+
*.swp
30+
*.swo
31+
32+
# OS
33+
.DS_Store
34+
Thumbs.db
35+
36+
# TypeScript
37+
*.tsbuildinfo
38+
next-env.d.ts
39+
40+
# Misc
41+
*.log
42+
*.cache

frontend/README.md

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# ByteCode Compiler - Frontend
2+
3+
Professional web interface for the ByteCode Compiler featuring a terminal-style code editor, comprehensive documentation, and Azure backend integration.
4+
5+
## Features
6+
7+
-**Beautiful Landing Page** - Calm, attractive design with smooth animations
8+
- 💻 **Terminal Interface** - Monaco Editor with terminal aesthetics
9+
- 📚 **Documentation Viewer** - Interactive docs with syntax highlighting
10+
- 🎨 **Full Customization** - Dark/Light themes, terminal colors, fonts, sizes
11+
-**Optimized Performance** - Next.js with server-side rendering
12+
- 🔗 **Azure Integration** - Real-time compilation via REST API
13+
14+
## Tech Stack
15+
16+
- **Framework**: Next.js 14 (App Router)
17+
- **Language**: TypeScript
18+
- **Styling**: Tailwind CSS
19+
- **Editor**: Monaco Editor (VS Code editor)
20+
- **Animation**: Framer Motion
21+
- **Icons**: Lucide React
22+
23+
## Quick Start
24+
25+
```bash
26+
# Install dependencies
27+
cd frontend
28+
npm install
29+
30+
# Run development server
31+
npm run dev
32+
33+
# Open http://localhost:3000
34+
```
35+
36+
## Project Structure
37+
38+
```
39+
frontend/
40+
├── app/
41+
│ ├── page.tsx # Landing page
42+
│ ├── layout.tsx # Root layout
43+
│ ├── compiler/
44+
│ │ └── page.tsx # Terminal interface
45+
│ └── docs/
46+
│ └── page.tsx # Documentation viewer
47+
├── components/
48+
│ ├── Header.tsx # Navigation header
49+
│ ├── Footer.tsx # Credits footer
50+
│ ├── ThemeToggle.tsx # Dark/Light mode
51+
│ ├── Terminal.tsx # Code editor
52+
│ └── DocsNav.tsx # Docs sidebar
53+
├── lib/
54+
│ ├── api.ts # Azure API client
55+
│ └── themes.ts # Terminal themes
56+
└── public/
57+
└── (assets)
58+
```
59+
60+
## Environment Variables
61+
62+
Create `.env.local`:
63+
64+
```env
65+
NEXT_PUBLIC_API_URL=http://57.159.30.64/api
66+
NEXT_PUBLIC_GITHUB_URL=https://github.com/IsVohi/ByteCode-Compiler
67+
NEXT_PUBLIC_PORTFOLIO_URL=YOUR_PORTFOLIO_URL
68+
```
69+
70+
## Pages
71+
72+
### Landing Page (`/`)
73+
- Hero section with compiler description
74+
- Two CTA buttons: Open Compiler | Read Docs
75+
- Features showcase
76+
- Footer with credits
77+
78+
### Compiler (`/compiler`)
79+
- Monaco Editor with terminal theme
80+
- Help panel (syntax reference)
81+
- File upload (.src files)
82+
- Command palette
83+
- Output display
84+
- Customization sidebar
85+
86+
### Documentation (`/docs`)
87+
- Navigation sidebar
88+
- Markdown renderer
89+
- Search functionality
90+
- Syntax highlighting
91+
92+
## Header Links
93+
94+
- GitHub Repository
95+
- Portfolio (customizable)
96+
- Theme Toggle dark/Light)
97+
98+
## Footer
99+
100+
Created by **Vikas Sharma** © 2024
101+
All rights reserved.
102+
103+
## Deployment
104+
105+
### Vercel (Recommended)
106+
107+
```bash
108+
# Install Vercel CLI
109+
npm i -g vercel
110+
111+
# Deploy
112+
vercel
113+
114+
# Production
115+
vercel --prod
116+
```
117+
118+
Configuration is in `vercel.json`.
119+
120+
### Environment Variables on Vercel
121+
122+
Add these in Vercel dashboard:
123+
- `NEXT_PUBLIC_API_URL`
124+
- `NEXT_PUBLIC_GITHUB_URL`
125+
- `NEXT_PUBLIC_PORTFOLIO_URL`
126+
127+
## Development
128+
129+
```bash
130+
# Install dependencies
131+
npm install
132+
133+
# Run dev server
134+
npm run dev
135+
136+
# Build for production
137+
npm run build
138+
139+
# Start production server
140+
npm start
141+
142+
# Lint code
143+
npm run lint
144+
```
145+
146+
##Terminal Customization
147+
148+
Users can customize:
149+
- Background colors
150+
- Text colors
151+
- Font family
152+
- Font size
153+
- Cursor style
154+
- Line height
155+
156+
Themes are saved to localStorage.
157+
158+
## API Integration
159+
160+
The frontend connects to your Azure VM API:
161+
162+
```typescript
163+
const response = await fetch(`${API_URL}/compile`, {
164+
method: 'POST',
165+
headers: { 'Content-Type': 'application/json' },
166+
body: JSON.stringify({ code })
167+
});
168+
```
169+
170+
## Performance
171+
172+
- Server-side rendering (SSR)
173+
- Code splitting
174+
- Image optimization
175+
- Font optimization
176+
- Lazy loading
177+
178+
## Browser Support
179+
180+
- Chrome (latest)
181+
- Firefox (latest)
182+
- Safari (latest)
183+
- Edge (latest)
184+
185+
## License
186+
187+
MIT
188+
189+
---
190+
191+
**Note**: This is a professional showcase project demonstrating full-stack development capabilities.

frontend/app/api/compile/route.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NextResponse } from 'next/server';
2+
3+
const BACKEND_URL = 'http://57.159.30.64/api';
4+
5+
export async function POST(request: Request) {
6+
try {
7+
const body = await request.json();
8+
const response = await fetch(`${BACKEND_URL}/compile`, {
9+
method: 'POST',
10+
headers: { 'Content-Type': 'application/json' },
11+
body: JSON.stringify(body),
12+
});
13+
const data = await response.json();
14+
return NextResponse.json(data);
15+
} catch (error) {
16+
return NextResponse.json({ success: false, error: 'Backend unavailable' }, { status: 500 });
17+
}
18+
}

frontend/app/api/health/route.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NextResponse } from 'next/server';
2+
3+
const BACKEND_URL = 'http://57.159.30.64/api';
4+
5+
export async function GET() {
6+
try {
7+
const response = await fetch(`${BACKEND_URL}/health`);
8+
const data = await response.json();
9+
return NextResponse.json(data);
10+
} catch (error) {
11+
return NextResponse.json({ status: 'error' }, { status: 500 });
12+
}
13+
}

0 commit comments

Comments
 (0)