Skip to content

Project Structure

Amit Das edited this page Apr 28, 2026 · 1 revision

📁 Project Structure

This page explains the folder structure and architecture used in SecureAuth.

Understanding the project structure helps developers navigate the codebase more efficiently.


🏗️ Project Overview

SecureAuth is built using:

  • React + TypeScript frontend
  • Express.js backend
  • Vite build system
  • Firebase integration
  • Secure authentication architecture

📂 Root Structure

SecureAuth
├── public/
├── src/
├── server.ts
├── package.json
├── vite.config.ts
├── tsconfig.json
├── .env
├── README.md
└── metadata.json

📁 public/

Contains static assets used by the application.

Example:

public/
├── banner.jpg
├── preview.gif
├── favicon.ico
├── apple-touch-icon.png
└── icons/

Purpose

Used for:

  • Images
  • Icons
  • PWA assets
  • Static resources

📁 src/

Main frontend application source code.

Example structure:

src/
├── components/
├── pages/
├── hooks/
├── services/
├── utils/
├── types/
├── contexts/
└── main.tsx

📁 components/

Reusable UI components.

Examples:

components/
├── Button.tsx
├── Modal.tsx
├── Navbar.tsx
└── SessionCard.tsx

Purpose

Used for reusable UI logic and layouts.


📁 pages/

Application pages and route-level views.

Examples:

pages/
├── Login.tsx
├── Dashboard.tsx
├── Settings.tsx
└── Sessions.tsx

📁 hooks/

Custom React hooks.

Examples:

hooks/
├── useAuth.ts
├── useTheme.ts
└── useSession.ts

📁 services/

Handles API communication and external integrations.

Examples:

services/
├── auth.ts
├── api.ts
├── firebase.ts
└── textsnap.ts

📁 utils/

Utility/helper functions.

Examples:

utils/
├── encryption.ts
├── validation.ts
└── formatters.ts

📁 contexts/

Global application state management.

Examples:

contexts/
├── AuthContext.tsx
├── ThemeContext.tsx
└── SessionContext.tsx

📁 types/

TypeScript type definitions.

Examples:

types/
├── auth.ts
├── session.ts
└── account.ts

🖥️ server.ts

Main backend server entry point.

Responsibilities:

  • API routes
  • Authentication handling
  • Session validation
  • OTP verification
  • Database communication

⚙️ vite.config.ts

Vite configuration file.

Used for:

  • Build configuration
  • PWA setup
  • Allowed hosts
  • Development server settings

📦 package.json

Project metadata and dependency configuration.

Contains:

  • Scripts
  • Dependencies
  • Build commands

🔐 .env

Environment variables and secrets.

Contains:

  • JWT secrets
  • Encryption keys
  • Firebase credentials
  • API tokens

⚠️ Never commit this file publicly.


🧠 Architecture Flow

Frontend (React)
        ↓
API Requests
        ↓
Express Backend
        ↓
Authentication Validation
        ↓
Firebase Storage
        ↓
Encrypted Data Handling

🔒 Security Related Files

Important security-related areas:

utils/encryption.ts
services/auth.ts
server.ts
.env

📱 PWA Related Files

PWA support files:

public/icons/
vite.config.ts
manifest configuration
service worker files

🚀 Deployment Related Files

Deployment-related files:

package.json
server.ts
vite.config.ts
Dockerfile
ecosystem.config.cjs

🛠 Recommended Development Practices

  • Keep components reusable
  • Separate API logic into services
  • Store utilities in utils/
  • Use TypeScript types consistently
  • Keep secrets inside .env

⚠️ Important Notes

Never Commit Secrets

Avoid committing:

  • .env
  • API keys
  • Firebase secrets
  • JWT secrets

Keep Components Modular

Avoid large monolithic components.


✅ Next Steps

Continue with:


Secure • Fast • Modern ⚡

Clone this wiki locally